[PATCH] Enable count for breakpoints

Stan Shebs stanshebs@earthlink.net
Fri Feb 10 02:12:00 GMT 2012


This patch implements a request from Ericsson GDB users, to generalize 
"enable once" so that breakpoints can be disabled after a given number 
of hits instead of the first one.  The command looks like

     enable count <n> [<breakpoint numbers>]

Now in the single-threaded all-stop case, this doesn't have much value; 
after all, you're stopped at the breakpoint, and are free to 
enable/disable as you like.  But in the multi-threaded non-stop case, 
enable-once no longer works so well, since multiple threads may hit the 
breakpoint simultaneously, and if you don't want the first hit, you're 
out of luck, it's already disabled and all the threads are running out 
of control.  But if you don't auto-disable, you could get stacked up 
with hundreds of hit reports that you don't want.

So this patch gives you a way to have a countdown before disabling.  
"enable count 1" is identical to "enable once", so the implementation is 
not conceptually complicated, we just need a struct to package up both 
disposition and countdown to be passed around the mapping functions.

Stan

2012-02-09  Stan Shebs <stan@codesourcery.com>

         * NEWS: Mention enable count command.
         * breakpoint.h (struct breakpoint): New field enable_count.
         * breakpoint.c (enable_breakpoint_disp): Add count argument.
         (enable_breakpoint): Add arg to call.
         (struct disp_data): New struct.
         (do_enable_breakpoint_disp): Interp arg as disp_data and unpack.
         (do_map_enable_once_breakpoint): Create a struct and pass it.
         (do_map_enable_delete_breakpoint): Ditto.
         (do_map_enable_count_breakpoint): New function.
         (enable_count_command): New function.
         (bpstat_stop_status): Decrement enable_count.
         (print_one_breakpoint_location): Report enable count.
         (_initialize_breakpoint): Add enable count command.

         * gdb.texinfo (Disabling Breakpoints): Document enable count.

         * gdb.base/ena-dis-br.exp: Add enable count test.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: enablecount-patch-1
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20120210/bc3e1a1b/attachment.ksh>


More information about the Gdb-patches mailing list