Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Andrew Stubbs <ams@codesourcery.com>,
	gdb-patches@sourceware.org,
		"Maciej W. Rozycki" <macro@codesourcery.com>,
		Vladimir Prus <vladimir@codesourcery.com>,
		Eli Zaretskii <eliz@gnu.org>
Subject: Re: RFC: Fix "break *EXP thread NUM"
Date: Tue, 24 Nov 2009 15:05:00 -0000	[thread overview]
Message-ID: <20091124150533.GA8964@caradoc.them.org> (raw)
In-Reply-To: <20091124145422.GA26004@adacore.com>

On Tue, Nov 24, 2009 at 06:54:22AM -0800, Joel Brobecker wrote:
> I'm a little tied up at the moment, but I can take care of this.

Thanks!

Meanwhile, here's a patch that handles "t" and "task".  I talked to
Andrew about this, and I still think we can get away without "+N" and
"-N"; they're only accepted by an accident of strtol.

-- 
Daniel Jacobowitz
CodeSourcery

2009-11-23  Daniel Jacobowitz  <dan@codesourcery.com>

	* breakpoint.c (find_condition_and_thread): Correct task error message.
	* c-exp.y (yylex): Stop before "thread N", "task N", or abbreviations
	of those.

	* gdb.texinfo (Thread-Specific Breakpoints): Thread specifiers
	are allowed after the breakpoint condition.

	* gdb.base/condbreak.exp: Test combinations of "break *EXP",
	"if", and "thread".  Correct matching in the previous test.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.435
diff -u -p -r1.435 breakpoint.c
--- breakpoint.c	22 Nov 2009 15:38:58 -0000	1.435
+++ breakpoint.c	24 Nov 2009 15:03:10 -0000
@@ -6635,7 +6635,7 @@ find_condition_and_thread (char *tok, CO
 	  if (tok == tmptok)
 	    error (_("Junk after task keyword."));
 	  if (!valid_task_id (*task))
-	    error (_("Unknown task %d\n"), *task);
+	    error (_("Unknown task %d."), *task);
 	}
       else
 	error (_("Junk at end of arguments."));
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.65
diff -u -p -r1.65 c-exp.y
--- c-exp.y	11 Nov 2009 16:45:46 -0000	1.65
+++ c-exp.y	24 Nov 2009 15:03:10 -0000
@@ -2250,6 +2250,24 @@ yylex (void)
       return 0;
     }
 
+  /* For the same reason (breakpoint conditions), "thread N"
+     terminates the expression.  "thread" could be an identifier, but
+     an identifier is never followed by a number without intervening
+     punctuation.  "task" is similar.  Handle abbreviations of these,
+     similarly to breakpoint.c:find_condition_and_thread.  */
+  if (namelen >= 1
+      && (strncmp (tokstart, "thread", namelen) == 0
+	  || strncmp (tokstart, "task", namelen) == 0)
+      && (tokstart[namelen] == ' ' || tokstart[namelen] == '\t')
+      && ! scanning_macro_expansion ())
+    {
+      char *p = tokstart + namelen + 1;
+      while (*p == ' ' || *p == '\t')
+	p++;
+      if (*p >= '0' && *p <= '9')
+	return 0;
+    }
+
   lexptr += namelen;
 
   tryname:
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.642
diff -u -p -r1.642 gdb.texinfo
--- doc/gdb.texinfo	23 Nov 2009 18:44:10 -0000	1.642
+++ doc/gdb.texinfo	24 Nov 2009 15:03:15 -0000
@@ -5214,8 +5214,8 @@ breakpoint, the breakpoint applies to @e
 program.
 
 You can use the @code{thread} qualifier on conditional breakpoints as
-well; in this case, place @samp{thread @var{threadno}} before the
-breakpoint condition, like this:
+well; in this case, place @samp{thread @var{threadno}} before or
+after the breakpoint condition, like this:
 
 @smallexample
 (@value{GDBP}) break frik.c:13 thread 28 if bartab > lim
Index: testsuite/gdb.base/condbreak.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/condbreak.exp,v
retrieving revision 1.13
diff -u -p -r1.13 condbreak.exp
--- testsuite/gdb.base/condbreak.exp	3 Jan 2009 05:58:03 -0000	1.13
+++ testsuite/gdb.base/condbreak.exp	24 Nov 2009 15:03:15 -0000
@@ -207,10 +207,10 @@ gdb_expect {
 setup_xfail hppa2.0w-*-* 11512CLLbs
 send_gdb "continue\n"
 gdb_expect {
-    -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
 	pass "run until breakpoint at marker2"
     }
-    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
 	xfail "run until breakpoint at marker2"
     }
     -re "$gdb_prompt $" {
@@ -220,3 +220,30 @@ gdb_expect {
 	fail "(timeout) run until breakpoint at marker2"
     }
 }
+
+# Test combinations of conditional and thread-specific breakpoints.
+gdb_test "break main if (1==1) thread 999" \
+    "Unknown thread 999\\."
+gdb_test "break main thread 999 if (1==1)" \
+    "Unknown thread 999\\."
+
+# Verify that both if and thread can be distinguished from a breakpoint
+# address expression.
+gdb_test "break *main if (1==1) thread 999" \
+    "Unknown thread 999\\."
+gdb_test "break *main thread 999 if (1==1)" \
+    "Unknown thread 999\\."
+
+# Similarly for task.
+gdb_test "break *main if (1==1) task 999" \
+    "Unknown task 999\\."
+gdb_test "break *main task 999 if (1==1)" \
+    "Unknown task 999\\."
+
+# GDB accepts abbreviations for "thread" and "task".
+gdb_test "break *main if (1==1) t 999" \
+    "Unknown thread 999\\."
+gdb_test "break *main if (1==1) th 999" \
+    "Unknown thread 999\\."
+gdb_test "break *main if (1==1) ta 999" \
+    "Unknown task 999\\."


  reply	other threads:[~2009-11-24 15:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23 21:27 Daniel Jacobowitz
2009-11-24  0:21 ` Joel Brobecker
2009-11-24 10:33 ` Andrew Stubbs
2009-11-24 14:24   ` Daniel Jacobowitz
2009-11-24 14:54     ` Joel Brobecker
2009-11-24 15:05       ` Daniel Jacobowitz [this message]
2009-11-25 20:43         ` Daniel Jacobowitz
2009-12-01 19:53           ` Maciej W. Rozycki
2009-12-01 20:04             ` Daniel Jacobowitz
2010-01-01  6:31           ` [commit] Fix "break *EXP thread/task NUM" for Ada (was: "Re: RFC: Fix "break *EXP thread NUM"") Joel Brobecker
2009-11-24 17:08     ` RFC: Fix "break *EXP thread NUM" Tom Tromey

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=20091124150533.GA8964@caradoc.them.org \
    --to=drow@false.org \
    --cc=ams@codesourcery.com \
    --cc=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@codesourcery.com \
    --cc=vladimir@codesourcery.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