On 12/11, K.Prasad wrote:
>
> On Fri, Dec 11, 2009 at 04:59:44PM +0100, Oleg Nesterov wrote:
> >
> > Yes. I straced gdb to be sure it really does PTRACE_SET_DEBUGREF to
> > use the hardware watchpoint.
> >
> > There is something strange though. gdb does PTRACE_SINGLESTEP and only
> > then PTRACE_CONT after "watch xxx".
> >
>
> I haven't taken a good look at the testcase...although I suspect that
> the use of PTRACE_SINGLESTEP vs PTRACE_SET_DEBUGREG during your trials
> is due to the way "watch <var>" is being set.
>
> For instance, here are two screenlogs taken from a PPC64 (Power5 box
> running RHEL 5.3 2.6.18-128.el5). It can be seen that hw-breakpoints are
> used only during the second-run of GDB vs single-stepping done in the
> first...wondering if you used it in similar ways.

        # cat T.c
        #include <stdio.h>

        int volatile var;

        int main(void)
        {
                printf("without this printf dabr works\n");

                var = 0xfff;

                return 0;
        }

then,

        # cc -Wall -O2 -g -o t T.c && gdb ./t
        GNU gdb (GDB) Fedora (6.8.50.20090811-2.el6)
        Copyright (C) 2009 Free Software Foundation, Inc.
        License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law.  Type "show 
copying"
        and "show warranty" for details.
        This GDB was configured as "ppc64-redhat-linux-gnu".
        For bug reporting instructions, please see:
        <http://www.gnu.org/software/gdb/bugs/>...
        (gdb) b main
        Breakpoint 1 at 0x10000534: file T.c, line 7.
        (gdb) r
        Starting program: /root/TST/t 

        Breakpoint 1, main () at T.c:7
        7               printf("without this printf dabr works\n");
        Missing separate debuginfos, use: debuginfo-install 
glibc-2.10.90-26.ppc64
        (gdb) watch var
        Hardware watchpoint 2: var
        (gdb) c
        Continuing.
        without this printf dabr works

        Program exited normally.
        (gdb)

strace shows that "c" after "watch var" does:

        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_SINGLESTEP, 26680, 0x1, SIG_0) = 0
        --- SIGCHLD (Child exited) @ 0 (0) ---
        ptrace(0x4202 /* PTRACE_??? */, 26680, 0, 0x131390d0) = 0
        ptrace(PTRACE_PEEKUSER, 26680, NIP, [0x10000538]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000538, [0xf8010010f821ff91]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000538, [0xf8010010f821ff91]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, r1, [0xffffffff160]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10010b40, [0]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0x10000530, [0x7c0802a6e8628020]) = 0
        ptrace(PTRACE_POKEDATA, 26680, 0x10000530, 0x7c0802a67d821008) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0xfffb7fd6300, [0x4e80002000000000]) = 0
        ptrace(PTRACE_PEEKTEXT, 26680, 0xfffb7fd6300, [0x4e80002000000000]) = 0
        ptrace(PTRACE_POKEDATA, 26680, 0xfffb7fd6300, 0x7d82100800000000) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(PTRACE_PEEKUSER, 26680, MSR, [0x800000005010d032]) = 0
        ptrace(0x1a /* PTRACE_??? */, 26680, 0, 0x10010b46) = 0         
<======= SET_DEBUGREG
        ptrace(PTRACE_CONT, 26680, 0x1, SIG_0)  = 0

Oleg.

Reply via email to