PR 10179
authorChris Moller <cmoller@cygnus>
Fri, 23 Apr 2010 12:08:07 +0000 (12:08 +0000)
committerChris Moller <cmoller@cygnus>
Fri, 23 Apr 2010 12:08:07 +0000 (12:08 +0000)
* symtab.c (rbreak_command): Added code to include a filename
specification in the rbreak argument.
* NEWS: Added a brief description of filename-qualified rbreak.
* gdb.base/Makefile.in (EXECUTABLES): Added pr10179.
* gdb.base/pr10179-a.c:
* gdb.base/pr10179-b.c:
* gdb.base/pr10179.exp: New files.
* gdb.texinfo (Setting Breakpoints): Added description of
filename-qualified rbreak.
* refcard.tex (Breakpoints and Watchpoints): Added brief
description of filename-qualified rbreak.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/doc/refcard.tex
gdb/symtab.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/Makefile.in
gdb/testsuite/gdb.base/pr10179-a.c [new file with mode: 0644]
gdb/testsuite/gdb.base/pr10179-b.c [new file with mode: 0644]
gdb/testsuite/gdb.base/pr10179.exp [new file with mode: 0644]

index e0e3353..12057a4 100644 (file)
@@ -1,3 +1,11 @@
+2010-04-20  Chris Moller  <cmoller@redhat.com>
+
+       PR 10179
+
+       * symtab.c (rbreak_command): Added code to include a filename
+       specification in the rbreak argument.
+       * NEWS: Added a brief description of filename-qualified rbreak.
+
 2010-04-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Fix crashes on dangling display expressions.
index 4d0e061..cbdfa74 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -47,6 +47,10 @@ qGetTIBAddr
   single `break' command creates multiple breakpoints (e.g.,
   breakpoints on overloaded c++ functions).
 
+* The `rbreak' command now accepts a filename specification as part of
+  its argument, limiting the functions selected by the regex to those
+  in the specified file.
+
 * New commands
 
 save breakpoints <filename>
index 268f3a7..a96ce2f 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-20  Chris Moller  <cmoller@redhat.com>
+
+       * gdb.texinfo (Setting Breakpoints): Added description of
+       filename-qualified rbreak.
+       * refcard.tex (Breakpoints and Watchpoints): Added brief
+       description of filename-qualified rbreak.
+
 2010-04-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb.texinfo (Data): New @menu reference to Pretty Printing.
index d53d521..5ff37a2 100644 (file)
@@ -3355,7 +3355,7 @@ See also @ref{Conditions, ,Break Conditions}.
 
 @kindex rbreak
 @cindex regular expression
-@cindex breakpoints in functions matching a regexp
+@cindex breakpoints at functions matching a regexp
 @cindex set breakpoints in many functions
 @item rbreak @var{regex}
 Set breakpoints on all functions matching the regular expression
@@ -3385,6 +3385,19 @@ The @code{rbreak} command can be used to set breakpoints in
 (@value{GDBP}) rbreak .
 @end smallexample
 
+@item rbreak @var{file}:@var{regex}
+If @code{rbreak} is called with a filename qualification, it limits
+the search for functions matching the given regular expression to the
+specified @var{file}.  This can be used, for example, to set breakpoints on
+every function in a given file:
+
+@smallexample
+(@value{GDBP}) rbreak file.c:.
+@end smallexample
+
+The colon separating the filename qualifier from the regex may
+optionally be surrounded by spaces.
+
 @kindex info breakpoints
 @cindex @code{$_} and @code{info breakpoints}
 @item info breakpoints @r{[}@var{n}@r{]}
index ff10d1b..3d6303f 100644 (file)
@@ -325,7 +325,8 @@ break $\ldots$ if {\it expr}&break conditionally on nonzero {\it expr}\cr
 cond {\it n} \opt{\it expr}&new conditional expression on breakpoint
 {\it n}; make unconditional if no {\it expr}\cr
 tbreak $\ldots$&temporary break; disable when reached\cr
-rbreak {\it regex}&break on all functions matching {\it regex}\cr
+rbreak \opt{\it file\tt:}{\it regex}&break on all functions matching {\it
+regex} \opt{in \it file}\cr
 watch {\it expr}&set a watchpoint for expression {\it expr}\cr
 catch {\it event}&break at {\it event}, which may be {\tt catch}, {\tt throw},
 {\tt exec}, {\tt fork}, {\tt vfork}, {\tt load}, or {\tt unload}.\cr
index 28084e7..1d6b648 100644 (file)
@@ -3248,8 +3248,31 @@ rbreak_command (char *regexp, int from_tty)
   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 colon_index;
+         char * file_name;
+
+         colon_index = colon - regexp;
+         file_name = alloca (colon_index + 1);
+         memcpy (file_name, regexp, colon_index);
+         file_name[colon_index--] = 0;
+         while (isspace (file_name[colon_index]))
+           file_name[colon_index--] = 0; 
+         files = &file_name;
+         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 025e50d..b663907 100644 (file)
@@ -1,3 +1,12 @@
+2010-04-20  Chris Moller  <cmoller@redhat.com>
+
+       PR 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-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Fix crashes on dangling display expressions.
index 12db521..5e8e385 100644 (file)
@@ -12,7 +12,8 @@ EXECUTABLES = all-types annota1 bitfields break \
        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
diff --git a/gdb/testsuite/gdb.base/pr10179-a.c b/gdb/testsuite/gdb.base/pr10179-a.c
new file mode 100644 (file)
index 0000000..de5dcde
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+extern int foo2();
+
+int
+foo1()
+{
+}
+
+int
+bar1()
+{
+}
+
+main()
+{
+}
diff --git a/gdb/testsuite/gdb.base/pr10179-b.c b/gdb/testsuite/gdb.base/pr10179-b.c
new file mode 100644 (file)
index 0000000..dcc5d9b
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int
+foo2()
+{
+}
diff --git a/gdb/testsuite/gdb.base/pr10179.exp b/gdb/testsuite/gdb.base/pr10179.exp
new file mode 100644 (file)
index 0000000..b8bacaf
--- /dev/null
@@ -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\]*.*"