From 8bd10a10b3917698e13bb1101d13c93d8c1db3a1 Mon Sep 17 00:00:00 2001 From: Chris Moller Date: Fri, 23 Apr 2010 12:08:07 +0000 Subject: [PATCH] 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. * 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 | 8 +++++++ gdb/NEWS | 4 ++++ gdb/doc/ChangeLog | 7 ++++++ gdb/doc/gdb.texinfo | 15 +++++++++++- gdb/doc/refcard.tex | 3 ++- gdb/symtab.c | 25 +++++++++++++++++++- gdb/testsuite/ChangeLog | 9 +++++++ gdb/testsuite/gdb.base/Makefile.in | 3 ++- gdb/testsuite/gdb.base/pr10179-a.c | 17 +++++++++++++ gdb/testsuite/gdb.base/pr10179-b.c | 6 +++++ gdb/testsuite/gdb.base/pr10179.exp | 38 ++++++++++++++++++++++++++++++ 11 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 gdb/testsuite/gdb.base/pr10179-a.c create mode 100644 gdb/testsuite/gdb.base/pr10179-b.c create mode 100644 gdb/testsuite/gdb.base/pr10179.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e0e3353a7b6..12057a4d003 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2010-04-20 Chris Moller + + 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 Fix crashes on dangling display expressions. diff --git a/gdb/NEWS b/gdb/NEWS index 4d0e0611ea8..cbdfa742d42 100644 --- 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 diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 268f3a73356..a96ce2f1037 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2010-04-20 Chris Moller + + * 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 * gdb.texinfo (Data): New @menu reference to Pretty Printing. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d53d5216f7e..5ff37a28a17 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -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{]} diff --git a/gdb/doc/refcard.tex b/gdb/doc/refcard.tex index ff10d1b9c8b..3d6303f6da2 100644 --- a/gdb/doc/refcard.tex +++ b/gdb/doc/refcard.tex @@ -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 diff --git a/gdb/symtab.c b/gdb/symtab.c index 28084e766f6..1d6b648a64f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 025e50d7844..b66390742fb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2010-04-20 Chris Moller + + 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 Fix crashes on dangling display expressions. diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in index 12db5212889..5e8e38593fc 100644 --- a/gdb/testsuite/gdb.base/Makefile.in +++ b/gdb/testsuite/gdb.base/Makefile.in @@ -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 index 00000000000..de5dcdeb031 --- /dev/null +++ b/gdb/testsuite/gdb.base/pr10179-a.c @@ -0,0 +1,17 @@ +#include + +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 index 00000000000..dcc5d9bb8b3 --- /dev/null +++ b/gdb/testsuite/gdb.base/pr10179-b.c @@ -0,0 +1,6 @@ +#include + +int +foo2() +{ +} diff --git a/gdb/testsuite/gdb.base/pr10179.exp b/gdb/testsuite/gdb.base/pr10179.exp new file mode 100644 index 00000000000..b8bacafd020 --- /dev/null +++ b/gdb/testsuite/gdb.base/pr10179.exp @@ -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 . + +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\]*.*" -- 2.39.2