Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Chris Moller <cmoller@redhat.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: PR10179, Add support to set a breakpoint at every function in  a file
Date: Wed, 21 Apr 2010 02:56:00 -0000	[thread overview]
Message-ID: <4BCE694E.9060101@redhat.com> (raw)
In-Reply-To: <m3d3xtgb95.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

I don't recall that I've ever ever updated any of the doc files before, 
so, in case anyone wants to look at them, I've attached a new patch that 
include doc updates.

On 04/20/10 15:44, Tom Tromey wrote:
>>>>>> "Chris" == Chris Moller<cmoller@redhat.com>  writes:
>>>>>>              
>
> Chris>  +2010-04-20  Chris Moller<cmoller@redhat.com>
> Chris>  +	PR filename-filtered rbreak/10179
>
> This particular syntax probably won't have the desired effect.
> The commit script only recognizes a few specific formats.
> It should be just "PR category/NNNN", like "PR breakpoints/10179".
>
> Chris>  +	* symtab.c (rbreak_command): Added code to detect a filename
> Chris>  +	specification in conjunction with the function specification (in
> Chris>  +	the form of "filename : regex", checking to make sure that the
> Chris>  +	colon isn't part of a qualified function name).  If the filename
> Chris>  +	is discovered, it's passed to search_symbols.
>
> The description is too long.  It should only describe what is changing.
> Any further details belong in the code.
>
> Chris>  +      char * colon = strchr (regexp, ':');
>
> Extra space after "*".
>
> Chris>  +	  int ix;
> Chris>  +	  char * ta;
>
> I agree with Michael about the names.
>
> Chris>  +	  while (isspace (ta[ix])) { ta[ix--] = 0; }
>
> As Michael, this isn't our style.
>
> This requires a documentation and NEWS patch.
>
> Tom
>    


[-- Attachment #2: pr10179r2.patch --]
[-- Type: text/x-patch, Size: 9078 bytes --]

? doc/gdb.aux
? doc/gdb.log
? testsuite/gdb.base/pr10179
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	21 Apr 2010 02:52:30 -0000
@@ -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-19  Pedro Alves  <pedro@codesourcery.com>
 
 	* ada-lang.c (print_recreate_exception)
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.373
diff -u -r1.373 NEWS
--- NEWS	19 Apr 2010 00:48:43 -0000	1.373
+++ NEWS	21 Apr 2010 02:52:34 -0000
@@ -47,6 +47,10 @@
   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: 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	21 Apr 2010 02:52:37 -0000
@@ -3248,8 +3248,31 @@
   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: doc/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
retrieving revision 1.1051
diff -u -r1.1051 ChangeLog
--- doc/ChangeLog	19 Apr 2010 01:08:25 -0000	1.1051
+++ doc/ChangeLog	21 Apr 2010 02:52:43 -0000
@@ -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 ilename-qualified rbreak.
+
 2010-04-19  Pedro Alves  <pedro@codesourcery.com>
 
 	PR breakpoints/8554.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.708
diff -u -r1.708 gdb.texinfo
--- doc/gdb.texinfo	19 Apr 2010 00:48:44 -0000	1.708
+++ doc/gdb.texinfo	21 Apr 2010 02:53:10 -0000
@@ -3355,7 +3355,7 @@
 
 @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 @@
 (@value{GDBP}) rbreak .
 @end smallexample
 
+@item rbreak @var{filename:regex}
+If @code{rbreak} is called with a filename qualification, it limits
+the search for functions matching the given regular expression to the
+specified file.  This can be used, for example, to set breakponts 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: doc/refcard.tex
===================================================================
RCS file: /cvs/src/src/gdb/doc/refcard.tex,v
retrieving revision 1.7
diff -u -r1.7 refcard.tex
--- doc/refcard.tex	1 Jan 2010 11:20:05 -0000	1.7
+++ doc/refcard.tex	21 Apr 2010 02:53:11 -0000
@@ -325,7 +325,8 @@
 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: 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	21 Apr 2010 02:53:27 -0000
@@ -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-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	21 Apr 2010 02:53:28 -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	21 Apr 2010 02:53:28 -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	21 Apr 2010 02:53:28 -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	21 Apr 2010 02:53:28 -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\]*.*"

  reply	other threads:[~2010-04-21  2:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-20 19:21 Chris Moller
2010-04-20 19:23 ` Michael Snyder
2010-04-20 19:25   ` Chris Moller
2010-04-20 19:27     ` Michael Snyder
2010-04-20 19:30       ` Chris Moller
2010-04-20 19:35         ` Michael Snyder
2010-04-20 19:44 ` Tom Tromey
2010-04-21  2:56   ` Chris Moller [this message]
2010-04-21 21:24     ` Michael Snyder
2010-04-21 22:27     ` Tom Tromey
2010-04-23  9:30     ` Eli Zaretskii
2010-04-23 12:09       ` Chris Moller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BCE694E.9060101@redhat.com \
    --to=cmoller@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox