This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/11371] Request: add support for conditional watchpoint


------- Additional Comments From danny dot geist at gmail dot com  2010-06-02 08:43 -------
Hi Chris,
Below is a short testcase (test.c) that exemplifies the problem
To manifest the bug:
1. Compile test.c and run it within gdb
2. Type "break test.c:13"
3. Type "run"
on the breakpoint 
4. Type "delete 1" (to remove the breakpoint)
5. Type "watch i if f(i)" (this is the conditional watchpoint)
6. TYpe "continue"

What happens to me is that the watchpoint never stops execution although it
should. The execution reaches the end of the loop and then gdb itself crashes.

A. I ran it with a clean gdb 7.0 and the watchpoint didnt work and gdb crashed.
B. I ran it with gdb 7.1 (latest release). Same outcome: watchpoint does not
work and it crashes
C. I ran it with MY PATCH to gdb-7.0 and it worked like a charm. The watchpoint
stopped execution 10 times as it should and the execution ended normally.

Heres the version of gdb when I type gdb -v
Copyright (C) 2010 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 "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

As to the bug: it was a few months ago that I worked on it and it was painful
since I used printfs to debug. I root caused it to the following:
When you have a function call as a condition then it calls run_inferior to
evaluate it. It eventually calls the function "update_watchpoint" (line 908 of
breakpoint.c in gdb-7.0). That function does something bad to the list of
watchpoints. I dont remember exactly what but I think it frees the watchpoint
memory (theres an xfree there somewhere). I came to the conclusion that if I
disable update watchpoint in this situation all I am risking is a very minor
memory leak (in fact this may have fixed it perfectly but I dont know). So I put
a check in the beginning of update watchpoint (line 914). The check was easy to
do. The details are in my original posting. I think your job is to make sure I
didnt do any damage.

I looked at update_watchpoint in gdb version 7.1 - its changed but like I said -
the problem is still there. Now heres test .c
Regards,
Danny

      1 #include <stdio.h>
      2 int f(int i)
      3 {
      4   if((i%10) == 0) return 1;
      5   printf(" i is not stopping %d", i);
      6   return 0;
      7 }
      8 
      9 
     10 int main()
     11 {
     12    int i = 0;
     13    while (i < 100) {
     14        printf(" i is %d\n", i);
     15        i = i +1;
     16    }
     17    return 0;
     18 }




-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED


http://sourceware.org/bugzilla/show_bug.cgi?id=11371

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]