This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
PR10179, Add support to set a breakpoint at every function in a file
- From: Chris Moller <cmoller at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 20 Apr 2010 15:21:09 -0400
- Subject: PR10179, Add support to set a breakpoint at every function in a file
Allows the argument to rbreak to specify a file to which to limit the
regex search for function names. This allows, e.g.,
rbr file.c : .*
which sets bps in every function in the specified file.
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11638
diff -u -r1.11638 ChangeLog
--- ChangeLog 19 Apr 2010 17:06:08 -0000 1.11638
+++ ChangeLog 20 Apr 2010 19:14:05 -0000
@@ -1,3 +1,13 @@
+2010-04-20 Chris Moller <cmoller@redhat.com>
+
+ PR filename-filtered rbreak/10179
+
+ * symtab.c (rbreak_command): Added code to detect a filename
+ specification in conjunction with the function specification (in
+ the form of "filename : regex", checking to make sure that the
+ colon isn't part of a qualified function name). If the filename
+ is discovered, it's passed to search_symbols.
+
2010-04-19 Pedro Alves <pedro@codesourcery.com>
* ada-lang.c (print_recreate_exception)
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.231
diff -u -r1.231 symtab.c
--- symtab.c 9 Apr 2010 15:31:41 -0000 1.231
+++ symtab.c 20 Apr 2010 19:14:09 -0000
@@ -3248,8 +3248,30 @@
struct cleanup *old_chain;
char *string = NULL;
int len = 0;
+ char **files = NULL;
+ int nfiles = 0;
- search_symbols (regexp, FUNCTIONS_DOMAIN, 0, (char **) NULL, &ss);
+ if (regexp)
+ {
+ char * colon = strchr (regexp, ':');
+ if (colon && *(colon + 1) != ':')
+ {
+ int ix;
+ char * ta;
+
+ ix = colon - regexp;
+ ta = alloca (ix + 1);
+ memcpy (ta, regexp, ix);
+ ta[ix--] = 0;
+ while (isspace (ta[ix])) { ta[ix--] = 0; }
+ files = &ta;
+ nfiles = 1;
+ regexp = colon + 1;
+ while (isspace (*regexp)) { regexp++; }
+ }
+ }
+
+ search_symbols (regexp, FUNCTIONS_DOMAIN, nfiles, files, &ss);
old_chain = make_cleanup_free_search_symbols (ss);
make_cleanup (free_current_contents, &string);
Index: testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v
retrieving revision 1.2237
diff -u -r1.2237 ChangeLog
--- testsuite/ChangeLog 19 Apr 2010 03:13:06 -0000 1.2237
+++ testsuite/ChangeLog 20 Apr 2010 19:14:25 -0000
@@ -1,3 +1,12 @@
+2010-04-20 Chris Moller <cmoller@redhat.com>
+
+ PR filename-filtered rbreak/10179
+
+ * gdb.base/Makefile.in (EXECUTABLES): Added pr10179.
+ * gdb.base/pr10179-a.c:
+ * gdb.base/pr10179-b.c:
+ * gdb.base/pr10179.exp: New files.
+
2010-04-19 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/solib-display.exp: Replace gdb_exit, gdb_start,
Index: testsuite/gdb.base/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/Makefile.in,v
retrieving revision 1.5
diff -u -r1.5 Makefile.in
--- testsuite/gdb.base/Makefile.in 15 Sep 2009 03:30:08 -0000 1.5
+++ testsuite/gdb.base/Makefile.in 20 Apr 2010 19:14:26 -0000
@@ -12,7 +12,8 @@
scope section_command setshow setvar shmain sigall signals \
solib solib_sl so-impl-ld so-indr-cl \
step-line step-test structs structs2 \
- twice-tmp varargs vforked-prog watchpoint whatis catch-syscall
+ twice-tmp varargs vforked-prog watchpoint whatis catch-syscall \
+ pr10179
MISCELLANEOUS = coremmap.data ../foobar.baz \
shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl
Index: testsuite/gdb.base/pr10179-a.c
===================================================================
RCS file: testsuite/gdb.base/pr10179-a.c
diff -N testsuite/gdb.base/pr10179-a.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/pr10179-a.c 20 Apr 2010 19:14:26 -0000
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+extern int foo2();
+
+int
+foo1()
+{
+}
+
+int
+bar1()
+{
+}
+
+main()
+{
+}
Index: testsuite/gdb.base/pr10179-b.c
===================================================================
RCS file: testsuite/gdb.base/pr10179-b.c
diff -N testsuite/gdb.base/pr10179-b.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/pr10179-b.c 20 Apr 2010 19:14:26 -0000
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int
+foo2()
+{
+}
Index: testsuite/gdb.base/pr10179.exp
===================================================================
RCS file: testsuite/gdb.base/pr10179.exp
diff -N testsuite/gdb.base/pr10179.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/pr10179.exp 20 Apr 2010 19:14:26 -0000
@@ -0,0 +1,38 @@
+# Copyright 2010 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/>.
+
+set testname pr10179
+set sources "pr10179-a.c pr10179-b.c"
+
+if {[build_executable ${testname}.exp $testname $sources {debug}] == -1} {
+ return -1
+}
+
+clean_restart ${testname}
+
+if ![runto_main] {
+ untested pr10179
+ return -1
+}
+
+gdb_test "rbreak foo.*" "Breakpoint \[0-9\]+\[^\\n\]*\\nint foo\[12\]\[^\\n\]*\\nBreakpoint \[0-9\]+\[^\\n\]*\\nint foo\[12\].*"
+
+gdb_test "delete breakpoints" ".*" "" "Delete all breakpoints.*" "y"
+
+gdb_test "rbreak pr10179-a.c:foo.*" "Breakpoint \[0-9\]+\[^\\n\]*\\nint foo.*"
+
+gdb_test "delete breakpoints" ".*" "" "Delete all breakpoints.*" "y"
+
+gdb_test "rbreak pr10179-a.c : .*" "Breakpoint \[0-9\]+\[^\\n\]*\\nint bar1\[^\\n\]*\\nBreakpoint \[0-9\]+\[^\\n\]*\\nint foo1\[^\\n\]*\\nBreakpoint \[0-9\]+\[^\\n\]*\\nint main\[^\\n\]*.*"
--- virgin.sum 2010-04-20 07:57:00.781326349 -0400
+++ patched.sum 2010-04-20 14:58:34.042326421 -0400
@@ -1,4 +1,4 @@
-Test Run By moller on Tue Apr 20 07:47:19 2010
+Test Run By moller on Tue Apr 20 13:49:38 2010
Native configuration is i686-pc-linux-gnu
=== gdb tests ===
@@ -5982,6 +5982,10 @@
PASS: gdb.base/pointers.exp: ptype pppppC
PASS: gdb.base/pointers.exp: ptype ppppppC
PASS: gdb.base/pointers.exp: p instance.array_variable + 0
+Running ../../../src/gdb/testsuite/gdb.base/pr10179.exp ...
+PASS: gdb.base/pr10179.exp: rbreak foo.*
+PASS: gdb.base/pr10179.exp: rbreak pr10179-a.c:foo.*
+PASS: gdb.base/pr10179.exp: rbreak pr10179-a.c : .*
Running ../../../src/gdb/testsuite/gdb.base/pr11022.exp ...
PASS: gdb.base/pr11022.exp: set breakpoint
PASS: gdb.base/pr11022.exp: set watchpoint
@@ -16452,7 +16456,7 @@
PASS: gdb.threads/watchthreads.exp: successfully compiled posix threads test case
PASS: gdb.threads/watchthreads.exp: watch args[0]
PASS: gdb.threads/watchthreads.exp: watch args[1]
-PASS: gdb.threads/watchthreads.exp: disable 3
+PASS: gdb.threads/watchthreads.exp: disable 2
PASS: gdb.threads/watchthreads.exp: threaded watch loop
PASS: gdb.threads/watchthreads.exp: first watchpoint on args[0] hit
PASS: gdb.threads/watchthreads.exp: first watchpoint on args[1] hit
@@ -16733,7 +16737,7 @@
=== gdb Summary ===
-# of expected passes 15909
+# of expected passes 15912
# of unexpected failures 19
# of expected failures 44
# of untested testcases 4