From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16470 invoked by alias); 26 Jan 2009 13:14:20 -0000 Received: (qmail 16415 invoked by uid 22791); 26 Jan 2009 13:14:18 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_40,J_CHICKENPOX_37,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Jan 2009 13:13:59 +0000 Received: (qmail 13915 invoked from network); 26 Jan 2009 13:13:57 -0000 Received: from unknown (HELO wind.local) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Jan 2009 13:13:57 -0000 From: Vladimir Prus To: gdb-patches@sources.redhat.com, Nick Roberts , Marc Khouzam Subject: [RFC/RFA] -break-insert -d Date: Mon, 26 Jan 2009 13:14:00 -0000 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_xcbfJOn3V5WpHbi" Message-Id: <200901261614.25050.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00499.txt.bz2 --Boundary-00=_xcbfJOn3V5WpHbi Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 729 Presently, the -break-insert command always creates enabled breakpoint. Marc has noticed that in Eclipse, with non-stop mode, this case lead to races. Specifically, if a breakpoint is disabled in UI, then Eclipse first inserts a breakpoint, and then makes it disabled. So, there's a window when the breakpoint is inserted in the target. One possible solution is to modify Eclipse to never insert disabled breakpoint in GDB. However, this special-casing has to be done in every frontend, and GDB-side solution is better. The below patch implements new -d option to the -break-insert command, which causes the newly created breakpoints to be disabled. Is the breakpoint.c change OK. Any comments on MI changes? Thanks, Volodya --Boundary-00=_xcbfJOn3V5WpHbi Content-Type: text/x-diff; charset="iso 8859-15"; name="break_insert_d.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="break_insert_d.diff" Content-length: 7869 commit 32e2250c8755748d4a9d98343f9ba9b903d366a7 Author: Vladimir Prus Date: Mon Jan 26 16:10:17 2009 +0300 Make it possible to create disabled breakpoint with -break-insert. gdb/ * breakpoint.c (create_breakpoint, create_breakpoints) (break_command_really, set_breakpoint): New parameter enabled. (create_breakpoint, break_command_really): Make breakpoint disabled if so requested. * breakpoint.h (set_breakpoint): New parameter enabled. * mi/mi-cmd-break.c (mi_cmd_break_insert): Handle the -d option. gdb/doc/ * gdb.texinfo (GDB/MI Breakpoint Commands): Document the -d option to -break-insert. gdb/testsuite/ * gdb.mi/mi-break.exp (test_disabled_creation): New. Call it. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 65bbca9..1463bfb 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5090,7 +5090,7 @@ create_breakpoint (struct symtabs_and_lines sals, char *addr_string, char *cond_string, enum bptype type, enum bpdisp disposition, int thread, int ignore_count, - struct breakpoint_ops *ops, int from_tty) + struct breakpoint_ops *ops, int from_tty, int enabled) { struct breakpoint *b = NULL; int i; @@ -5124,7 +5124,7 @@ create_breakpoint (struct symtabs_and_lines sals, char *addr_string, b->cond_string = cond_string; b->ignore_count = ignore_count; - b->enable_state = bp_enabled; + b->enable_state = enabled ? bp_enabled : bp_disabled; b->disposition = disposition; loc = b->loc; @@ -5299,7 +5299,8 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string, char *cond_string, enum bptype type, enum bpdisp disposition, int thread, int ignore_count, - struct breakpoint_ops *ops, int from_tty) + struct breakpoint_ops *ops, int from_tty, + int enabled) { int i; for (i = 0; i < sals.nelts; ++i) @@ -5309,7 +5310,7 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string, create_breakpoint (expanded, addr_string[i], cond_string, type, disposition, - thread, ignore_count, ops, from_tty); + thread, ignore_count, ops, from_tty, enabled); } update_global_location_list (1); @@ -5481,7 +5482,8 @@ break_command_really (char *arg, char *cond_string, int thread, int ignore_count, enum auto_boolean pending_break_support, struct breakpoint_ops *ops, - int from_tty) + int from_tty, + int enabled) { struct gdb_exception e; struct symtabs_and_lines sals; @@ -5614,7 +5616,7 @@ break_command_really (char *arg, char *cond_string, int thread, hardwareflag ? bp_hardware_breakpoint : bp_breakpoint, tempflag ? disp_del : disp_donttouch, - thread, ignore_count, ops, from_tty); + thread, ignore_count, ops, from_tty, enabled); } else { @@ -5635,6 +5637,7 @@ break_command_really (char *arg, char *cond_string, int thread, b->disposition = tempflag ? disp_del : disp_donttouch; b->condition_not_parsed = 1; b->ops = ops; + b->enable_state = enabled ? bp_enabled : bp_disabled; update_global_location_list (1); mention (b); @@ -5669,7 +5672,8 @@ break_command_1 (char *arg, int flag, int from_tty) 0 /* Ignore count */, pending_break_support, NULL /* breakpoint_ops */, - from_tty); + from_tty, + 1 /* enabled */); } @@ -5677,7 +5681,7 @@ void set_breakpoint (char *address, char *condition, int hardwareflag, int tempflag, int thread, int ignore_count, - int pending) + int pending, int enabled) { break_command_really (address, condition, thread, 0 /* condition and thread are valid. */, @@ -5685,7 +5689,7 @@ set_breakpoint (char *address, char *condition, ignore_count, pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE, - NULL, 0); + NULL, 0, enabled); } /* Adjust SAL to the first instruction past the function prologue. @@ -6536,7 +6540,8 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string, tempflag, 0, 0, AUTO_BOOLEAN_TRUE /* pending */, - &gnu_v3_exception_catchpoint_ops, from_tty); + &gnu_v3_exception_catchpoint_ops, from_tty, + 1 /* enabled */); return 1; } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index b2db9eb..94287de 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -705,7 +705,8 @@ extern void tbreak_command (char *, int); extern void set_breakpoint (char *address, char *condition, int hardwareflag, int tempflag, int thread, int ignore_count, - int pending); + int pending, + int enabled); extern void insert_breakpoints (void); diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 583d96c..18996e9 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19911,7 +19911,7 @@ N.A. @subsubheading Synopsis @smallexample - -break-insert [ -t ] [ -h ] [ -f ] + -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -c @var{condition} ] [ -i @var{ignore-count} ] [ -p @var{thread} ] [ @var{location} ] @end smallexample @@ -19946,6 +19946,8 @@ refers to unknown files or functions), create a pending breakpoint. Without this flag, @value{GDBN} will report an error, and won't create a breakpoint, if @var{location} cannot be parsed. +@item -d +Create a disabled breakpoint. @end table @subsubheading Result diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index af14b0a..0de08ce 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -71,12 +71,14 @@ mi_cmd_break_insert (char *command, char **argv, int argc) int ignore_count = 0; char *condition = NULL; int pending = 0; + int enabled = 1; + struct gdb_exception e; struct gdb_events *old_hooks; enum opt { HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT, - IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT + IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT }; static struct mi_opt opts[] = { @@ -86,6 +88,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc) {"i", IGNORE_COUNT_OPT, 1}, {"p", THREAD_OPT, 1}, {"f", PENDING_OPT, 0}, + {"d", DISABLE_OPT, 0}, { 0, 0, 0 } }; @@ -123,6 +126,8 @@ mi_cmd_break_insert (char *command, char **argv, int argc) case PENDING_OPT: pending = 1; break; + case DISABLE_OPT: + enabled = 0; } } @@ -151,13 +156,13 @@ mi_cmd_break_insert (char *command, char **argv, int argc) set_breakpoint (address, condition, 0 /*hardwareflag */ , temp_p, thread, ignore_count, - pending); + pending, enabled); break; case HW_BP: set_breakpoint (address, condition, 1 /*hardwareflag */ , temp_p, thread, ignore_count, - pending); + pending, enabled); break; #if 0 case REGEXP_BP: diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index 84dcf0a..6ea59fc 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -183,6 +183,20 @@ proc test_error {} { "update varobj for function call" } +proc test_disabled_creation {} { + global mi_gdb_prompt + global hex + global line_callee2_body + + mi_gdb_test "-break-insert -d basics.c:callee2" \ + "\\^done,bkpt=\{number=\"6\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",fullname=\".*\",line=\"$line_callee2_body\",times=\"0\",original-location=\".*\"\}" \ + "test disabled creation" + + mi_gdb_test "-break-delete" \ + "\\^done" \ + "test disabled creation: cleanup" +} + test_tbreak_creation_and_listing test_rbreak_creation_and_listing @@ -190,5 +204,7 @@ test_ignore_count test_error +test_disabled_creation + mi_gdb_exit return 0 --Boundary-00=_xcbfJOn3V5WpHbi--