This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Keep breakpoints always inserted.
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 3 Apr 2008 17:32:23 +0400
- Subject: Re: [RFA] Keep breakpoints always inserted.
- References: <200802281717.14766.vladimir@codesourcery.com> <200803151312.15051.vladimir@codesourcery.com> <20080317222041.GC1309@caradoc.them.org>
On Tuesday 18 March 2008 01:20:41 Daniel Jacobowitz wrote:
> On Sat, Mar 15, 2008 at 01:12:14PM +0300, Vladimir Prus wrote:
> > > This patch is OK, if you will add the missing pieces: a NEWS entry and
> > > documentation for the new command, and a testcase that enables
> > > always-inserted and verifies that it isn't a brick.
> >
> > I've added NEW and documentation.
> >
> > I'm still not sure how to test this adequately.
>
> This version is OK when Eli is happy with the documentation.
>
> For a testcase, I agree that we need to run the whole testsuite in
> this mode to get full coverage. But it's useful to have a single
> test that runs in this mode even if the rest of the testsuite
> doesn't, in case someone completely breaks it. That's why the
> gdb.server tests run for native targets that build gdbserver,
> even when the rest of the testsuite uses "run".
>
> Could you write a test that uses "set break always-inserted" and does
> something simple like running to a function and then continuing past
> it to another breakpoint?
How about the attached? It depends on my previous patch to introduce
some testsuite helper functions.
> > + /* We're allowing a thread to run past a breakpoint it has
> > + hit, by single-stepping the thread with the breakpoint
> > + removed. In which case, we need to single-step only this
> > + thread, and keep others stopped, as they can miss this
> > + breakpoint if allowed to run.
> > +
> > + The current code actually removes all breakpoints when
> > + doing this, not just the one being stepped over, so if we
> > + let other threads run, we can actually miss any
> > + breakpoint, not just the one at PC. */
>
> Extra spacing here?
Yes, I've fixed this.
- Volodya
commit 87e70184c2c39b198f857ae6367696c7d10ec3e6
Author: Vladimir Prus <vladimir@codesourcery.com>
Date: Fri Nov 30 21:35:52 2007 +0300
Keep breakpoints always inserted.
[gdb]
* breakpoint.h (bp_location_p): New typedef.
Register a vector of bp_location_p.
* breakpoint.c (always_inserted_mode)
(show_always_inserted_mode): New.
(unlink_locations_from_global_list): Remove.
(update_global_location_list)
(update_global_location_list_nothrow): New.
(update_watchpoint): Don't free locations.
(should_insert_location): New.
(insert_bp_location): Use should_insert_location.
(insert_breakpoint_locations): Copied from
insert_breakpoints.
(insert_breakpoint): Use insert_breakpoint_locations.
(bpstat_stop_status): Call update_global_location_list
when disabling breakpoint.
(allocate_bp_location): Don't add to bp_location_chain.
(set_raw_breakpoint)
(create_longjmp_breakpoint, enable_longjmp_breakpoint)
(disable_longjmp_breakpoint, create_overlay_event_breakpoint)
(enable_overlay_breakpoints, disable_overlay_breakpoints)
(set_longjmp_resume_breakpoint)
(enable_watchpoints_after_interactive_call_stop)
(disable_watchpoints_before_interactive_call_start)
(create_internal_breakpoint)
(create_fork_vfork_event_catchpoint)
(create_exec_event_catchpoint, set_momentary_breakpoint)
(create_breakpoints, break_command_1, watch_command_1)
(create_exception_catchpoint)
(handle_gnu_v3_exceptions)
(disable_breakpoint, breakpoint_re_set_one)
(create_thread_event_breakpoint, create_solib_event_breakpoint)
(create_ada_exception_breakpoint): : Don't call check_duplicates.
Call update_global_location_list.
(delete_breakpoint): Don't remove locations and don't
try to reinsert them. Call update_global_location_list.
(update_breakpoint_locations): Likewise.
(restore_always_inserted_mode): New.
(update_breakpoints_after_exec): Temporary disable
always inserted mode.
* Makefile.in: Update dependencies.
* infrun.c (proceed): Remove breakpoints while stepping
over breakpoint.
(handle_inferior_event): Don't remove or insert
breakpoints.
* linux-fork.c (checkpoint_command): Remove breakpoints
before fork and insert after.
(linux_fork_context): Remove breakpoints before switch
and insert after.
* target.c (target_disconnect, target_detach): Remove
breakpoints from target.
[gdb/testsuite]
* lib/gdb.exp (gdb_continue_to_breakpoint): Allow the caller
to specify regexp for the location to stop at.
* gdb.base/break-always.c: New.
* gdb.base/break-always.exp: New.
diff --git a/gdb/testsuite/gdb.base/break-always.c b/gdb/testsuite/gdb.base/break-always.c
new file mode 100644
index 0000000..ad79c34
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-always.c
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int bar ()
+{
+ return 1; /* break in bar */
+}
+
+int foo ()
+{
+ return bar ();
+}
+
+int main ()
+{
+ foo ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp
new file mode 100644
index 0000000..6161943
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-always.exp
@@ -0,0 +1,32 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that 'set breakpoint always-inserted 1' is not a brick
+
+if { [prepare_for_testing break-always.exp break-always break-always.c] } {
+ return -1
+}
+
+set bar_location [gdb_get_line_number "break in bar" break-always.c]
+
+gdb_test "set breakpoint always-inserted 1" ""
+
+runto foo
+
+gdb_test "break bar" "Breakpoint 2.*" "set breakpoint on bar"
+gdb_continue_to_breakpoint "bar" ".*/break-always.c:$bar_location.*"
+
+
+
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8814e24..31e9feb 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -430,13 +430,13 @@ proc runto_main { } {
### worked. Use NAME as part of the test name; each call to
### continue_to_breakpoint should use a NAME which is unique within
### that test file.
-proc gdb_continue_to_breakpoint {name} {
+proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
global gdb_prompt
set full_name "continue to breakpoint: $name"
send_gdb "continue\n"
gdb_expect {
- -re "Breakpoint .* at .*\r\n$gdb_prompt $" {
+ -re "Breakpoint .* at $location_pattern\r\n$gdb_prompt $" {
pass $full_name
}
-re ".*$gdb_prompt $" {