public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/11371] New: Request: add support for conditional watchpoint
@ 2010-03-11  7:43 danny dot geist at gmail dot com
  2010-06-01 14:51 ` [Bug gdb/11371] " cmoller at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: danny dot geist at gmail dot com @ 2010-03-11  7:43 UTC (permalink / raw)
  To: gdb-prs

Hi there,
I needed a conditional watchpoint. I looked at the code and saw that although
its undocumented, there is already infrastructure for it.

I tried it out and hit a seg violation. I debugged the problem and added a very
minor fix (10 lines) and then it WORKED!. Below is the diff of file breakpoint.c
(from gdb 7.0) that fixes the problem. I would like to get it installed in the
code somehow.
Thanks,
Danny

breakpoint.c
============================================
380a381,387
> /* Return whether a watchpoint is disabled due to an interactive call.  */
> static int
> watchpoint_call_disabled (struct breakpoint *b)
> {
>   return (b->enable_state == bp_call_disabled);
> }
> 
914a922,926
>   /* dont free a watchpoint in the middle of an inferior call 
>      most probably we are evaluating its condition */
>   if(watchpoint_call_disabled(b))
>       return; 
>

-- 
           Summary: Request: add support for conditional watchpoint
           Product: gdb
           Version: 7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: gdb
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: danny dot geist at gmail dot com
                CC: gdb-prs at sourceware dot org
  GCC host triplet: i686-pc-linux-gnu


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
@ 2010-06-01 14:51 ` cmoller at redhat dot com
  2010-06-01 14:59 ` cmoller at redhat dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cmoller at redhat dot com @ 2010-06-01 14:51 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cmoller at redhat dot com  2010-06-01 14:51 -------
Conditional watchpoints work fine for me.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|cmoller at redhat dot com
                   |org                         |
             Status|UNCONFIRMED                 |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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
  2010-06-01 14:51 ` [Bug gdb/11371] " cmoller at redhat dot com
@ 2010-06-01 14:59 ` cmoller at redhat dot com
  2010-06-02  8:43 ` danny dot geist at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cmoller at redhat dot com @ 2010-06-01 14:59 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cmoller at redhat dot com  2010-06-01 14:59 -------
Note sent to the reporter of the bug asking for a failing t/c.

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


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
  2010-06-01 14:51 ` [Bug gdb/11371] " cmoller at redhat dot com
  2010-06-01 14:59 ` cmoller at redhat dot com
@ 2010-06-02  8:43 ` danny dot geist at gmail dot com
  2010-06-05 14:14 ` jan dot kratochvil at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: danny dot geist at gmail dot com @ 2010-06-02  8:43 UTC (permalink / raw)
  To: gdb-prs


------- 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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
                   ` (2 preceding siblings ...)
  2010-06-02  8:43 ` danny dot geist at gmail dot com
@ 2010-06-05 14:14 ` jan dot kratochvil at redhat dot com
  2010-08-14  2:29 ` [Bug breakpoints/11371] " pedro at codesourcery dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-06-05 14:14 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan dot kratochvil at redhat
                   |                            |dot com


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
                   ` (3 preceding siblings ...)
  2010-06-05 14:14 ` jan dot kratochvil at redhat dot com
@ 2010-08-14  2:29 ` pedro at codesourcery dot com
  2010-08-14  3:22 ` pedro at codesourcery dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-14  2:29 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|gdb                         |breakpoints


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
                   ` (4 preceding siblings ...)
  2010-08-14  2:29 ` [Bug breakpoints/11371] " pedro at codesourcery dot com
@ 2010-08-14  3:22 ` pedro at codesourcery dot com
  2010-08-17 21:18 ` pedro at codesourcery dot com
  2010-08-17 21:18 ` pedro at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-14  3:22 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pedro at codesourcery dot com  2010-08-14 03:22 -------
http://sourceware.org/ml/gdb-patches/2010-08/msg00158.html

-- 


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
                   ` (5 preceding siblings ...)
  2010-08-14  3:22 ` pedro at codesourcery dot com
@ 2010-08-17 21:18 ` pedro at codesourcery dot com
  2010-08-17 21:18 ` pedro at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-17 21:18 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pedro at codesourcery dot com  2010-08-17 21:18 -------
Fix checked in.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/11371] Request: add support for conditional watchpoint
  2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
                   ` (6 preceding siblings ...)
  2010-08-17 21:18 ` pedro at codesourcery dot com
@ 2010-08-17 21:18 ` pedro at codesourcery dot com
  7 siblings, 0 replies; 9+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-17 21:18 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2010-08-17 20:59 -------
Subject: Bug 11371

CVSROOT:	/cvs/src
Module name:	src
Changes by:	palves@sourceware.org	2010-08-17 20:59:04

Modified files:
	gdb            : ChangeLog breakpoint.c breakpoint.h 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.base: watch-cond-infcall.c 
	                        watch-cond-infcall.exp 

Log message:
	gdb/
	2010-08-17  Pedro Alves  <pedro@codesourcery.com>
	
	PR breakpoints/11371
	
	* breakpoint.c (breakpoint_init_inferior): Decrement the
	location's reference count instead of deleting right away.
	(bpstat_free): Decrement the location's reference count.  Make
	static.
	(bpstat_copy): Increment the location's reference count.
	(bpstat_find_breakpoint): Adjust.
	(bpstat_num): Adjust.
	(print_it_typical): Adjust.  Use the breakpoint pointer in the
	bpstat instead of the location's owner.
	(bpstat_alloc): Remove const qualifier from the 'bl' parameter.
	Adjust to record the location's owner in the bpstat.
	(watchpoint_check): Use the breakpoint pointer in the bpstat
	instead of the location's owner.
	(bpstat_check_breakpoint_conditions): Don't handle
	bp_watchpoint_scope here.  Use the breakpoint pointer in the
	bpstat instead of the location's owner.
	(bpstat_stop_status): Defer inferior function calls to after
	building the bpstat list.  Handle bp_watchpoint_scope here.  Use
	the breakpoint pointer in the bpstat instead of the location's
	owner.
	(bpstat_what): Use the breakpoint pointer in the bpstat instead of
	the location's owner.
	(free_bp_location): Don't walk bpstats clearing locations.
	(incref_bp_location): New.
	(decref_bp_location): New.
	(breakpoint_auto_delete): Use the breakpoint pointer in the bpstat
	instead of the location's owner.
	(update_global_location_list): Clear the location's owner, and
	decrement the location's reference count instead of deleting it
	right away.
	(breakpoint_retire_moribund): Decrement the location's reference
	count instead of deleting it right away.
	(bpstat_remove_bp_location): Delete.
	(bpstat_remove_breakpoint): New.
	(bpstat_remove_bp_location_callback): Delete.
	(bpstat_remove_breakpoint_callback): New.
	(delete_breakpoint): Iterate over all threads' stop_bpstat's
	clearing references to the breakpoint that is being deleted.
	
	* breakpoint.h (struct bp_location) <refc>: New field.
	<owner>: Update comments.
	(bpstat_free): Delete declaration.
	(struct bpstats): Change the type of the breakpoint_at field to
	struct breakpoint point, from struct bp_location pointer.  Add new
	field bp_location_at.
	
	gdb/testsuite/
	2010-08-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
	Pedro Alves  <pedro@codesourcery.com>
	
	PR breakpoints/11371
	
	* gdb.base/watch-cond-infcall.exp: New file.
	* gdb.base/watch-cond-infcall.c: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12088&r2=1.12089
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/breakpoint.c.diff?cvsroot=src&r1=1.508&r2=1.509
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/breakpoint.h.diff?cvsroot=src&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2411&r2=1.2412
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/watch-cond-infcall.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/watch-cond-infcall.exp.diff?cvsroot=src&r1=NONE&r2=1.1



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|cmoller at redhat dot com   |pedro at codesourcery dot
                   |                            |com


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-08-17 21:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11  7:43 [Bug gdb/11371] New: Request: add support for conditional watchpoint danny dot geist at gmail dot com
2010-06-01 14:51 ` [Bug gdb/11371] " cmoller at redhat dot com
2010-06-01 14:59 ` cmoller at redhat dot com
2010-06-02  8:43 ` danny dot geist at gmail dot com
2010-06-05 14:14 ` jan dot kratochvil at redhat dot com
2010-08-14  2:29 ` [Bug breakpoints/11371] " pedro at codesourcery dot com
2010-08-14  3:22 ` pedro at codesourcery dot com
2010-08-17 21:18 ` pedro at codesourcery dot com
2010-08-17 21:18 ` pedro at codesourcery dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).