From b6199126eec56a19b3d4cd365abe3ec29d4911b9 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Wed, 25 Nov 2009 20:43:29 +0000 Subject: [PATCH] PR gdb/8704 * breakpoint.c (find_condition_and_thread): Correct task error message. * c-exp.y (yylex): Stop before "thread N", "task N", or abbreviations of those. doc/ * gdb.texinfo (Thread-Specific Breakpoints): Thread specifiers are allowed after the breakpoint condition. testsuite/ * gdb.base/condbreak.exp: Test combinations of "break *EXP", "if", and "thread". Correct matching in the previous test. --- gdb/ChangeLog | 8 +++++++ gdb/breakpoint.c | 2 +- gdb/c-exp.y | 18 ++++++++++++++++ gdb/doc/ChangeLog | 7 +++++++ gdb/doc/gdb.texinfo | 4 ++-- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.base/condbreak.exp | 31 ++++++++++++++++++++++++++-- 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e69bac29e30..cf5c907ed9a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2009-11-24 Daniel Jacobowitz + + PR gdb/8704 + + * breakpoint.c (find_condition_and_thread): Correct task error message. + * c-exp.y (yylex): Stop before "thread N", "task N", or abbreviations + of those. + 2009-11-24 Joel Brobecker * acinclude.m4: Include ../config/zlib.m4. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8a6813cd866..4340c5ddf6a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -6636,7 +6636,7 @@ find_condition_and_thread (char *tok, CORE_ADDR pc, 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.")); diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8ee323e4b78..d657c923f93 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -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: diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 8571bc9aebc..7c1512412c1 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2009-11-24 Daniel Jacobowitz + + PR gdb/8704 + + * gdb.texinfo (Thread-Specific Breakpoints): Thread specifiers + are allowed after the breakpoint condition. + 2009-11-23 Tom Tromey PR python/10782: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c1ccfc7826e..74cbedffef6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -5214,8 +5214,8 @@ breakpoint, the breakpoint applies to @emph{all} threads of your 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 diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 021466fcf63..fddb912d64a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-11-24 Daniel Jacobowitz + + PR gdb/8704 + + * gdb.base/condbreak.exp: Test combinations of "break *EXP", + "if", and "thread". Correct matching in the previous test. + 2009-11-25 Daniel Jacobowitz * gdb.cp/extern-c.cc, gdb.cp/extern-c.exp: New test. diff --git a/gdb/testsuite/gdb.base/condbreak.exp b/gdb/testsuite/gdb.base/condbreak.exp index 2fdeb6928e2..8a9dfbcc600 100644 --- a/gdb/testsuite/gdb.base/condbreak.exp +++ b/gdb/testsuite/gdb.base/condbreak.exp @@ -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\\." -- 2.30.2