From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: Hui Zhu <hui_zhu@mentor.com>, Tom Tromey <tromey@redhat.com>,
Hui Zhu <teawater@gmail.com>,
gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Fix create pending breakpoint handle extra_string issue if not parse_condition_and_thread
Date: Mon, 08 Apr 2013 17:54:00 -0000 [thread overview]
Message-ID: <5162D104.6050500@redhat.com> (raw)
In-Reply-To: <5160987A.5030308@redhat.com>
On 04/06/2013 10:49 PM, Keith Seitz wrote:
> It looks good to me.
> Thank you again for your review of my review. Hopefully next time I'll be a bit better at it!
You're too hard on yourself. :-)
> (...) This function has two major
> - modes of operations, selected by the PARSE_CONDITION_AND_THREAD
> - parameter. If non-zero, the function will parse arg, extracting
> - breakpoint location, address and thread. Otherwise, ARG is just
I noticed that "address" in "location, address and thread" must
be a typo for "condition". I've fixed that too now, and checked it all in.
----------
Subject: create_breapoint / explicit mode: Error out if there's garbage after the breakpoint location.
If !PARSE_CONDITION_AND_THREAD, then ARG is just the location, nothing
else. The fact that the describing comment of create_breakpoint
doesn't mention this just looks like an oversight of when extra_string
was added. "parse_condition_and_thread" has been a misnomer ever
since extra_string was added -- better rename it avoid more confusion.
This makes it "parse_arg", as that'll remain stable even if/when more
explicit parameters are added.
gdb/
2013-04-08 Pedro Alves <palves@redhat.com>
Keith Seitz <keiths@redhat.com>
* breakpoint.c (create_breakpoint): Rename
"parse_condition_and_thread" parameter to "parse_arg". Update
describing comment. If !PARSE_ARG, then error out if ARG is not
the empty string after extracting the location.
* breakpoint.h (create_breakpoint): Rename
"parse_condition_and_thread" parameter to "parse_arg".
gdb/testsuite/
2013-04-08 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-break.exp (test_error): Add tests with garbage after
the location.
---
gdb/breakpoint.c | 25 ++++++++++++++-----------
gdb/breakpoint.h | 2 +-
gdb/testsuite/gdb.mi/mi-break.exp | 12 ++++++++++++
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5ba1f2f..667bedd 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9510,20 +9510,20 @@ decode_static_tracepoint_spec (char **arg_p)
/* Set a breakpoint. This function is shared between CLI and MI
functions for setting a breakpoint. This function has two major
- modes of operations, selected by the PARSE_CONDITION_AND_THREAD
- parameter. If non-zero, the function will parse arg, extracting
- breakpoint location, address and thread. Otherwise, ARG is just
- the location of breakpoint, with condition and thread specified by
- the COND_STRING and THREAD parameters. If INTERNAL is non-zero,
- the breakpoint number will be allocated from the internal
- breakpoint count. Returns true if any breakpoint was created;
- false otherwise. */
+ modes of operations, selected by the PARSE_ARG parameter. If
+ non-zero, the function will parse ARG, extracting location,
+ condition, thread and extra string. Otherwise, ARG is just the
+ breakpoint's location, with condition, thread, and extra string
+ specified by the COND_STRING, THREAD and EXTRA_STRING parameters.
+ If INTERNAL is non-zero, the breakpoint number will be allocated
+ from the internal breakpoint count. Returns true if any breakpoint
+ was created; false otherwise. */
int
create_breakpoint (struct gdbarch *gdbarch,
char *arg, char *cond_string,
int thread, char *extra_string,
- int parse_condition_and_thread,
+ int parse_arg,
int tempflag, enum bptype type_wanted,
int ignore_count,
enum auto_boolean pending_break_support,
@@ -9641,7 +9641,7 @@ create_breakpoint (struct gdbarch *gdbarch,
lsal = VEC_index (linespec_sals, canonical.sals, 0);
- if (parse_condition_and_thread)
+ if (parse_arg)
{
char *rest;
/* Here we only parse 'arg' to separate condition
@@ -9660,6 +9660,9 @@ create_breakpoint (struct gdbarch *gdbarch,
}
else
{
+ if (*arg != '\0')
+ error (_("Garbage '%s' at end of location"), arg);
+
/* Create a private copy of condition string. */
if (cond_string)
{
@@ -9699,7 +9702,7 @@ create_breakpoint (struct gdbarch *gdbarch,
init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops);
b->addr_string = copy_arg;
- if (parse_condition_and_thread)
+ if (parse_arg)
b->cond_string = NULL;
else
{
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 68f3ed9..d740625 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1269,7 +1269,7 @@ enum breakpoint_create_flags
extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
char *cond_string, int thread,
char *extra_string,
- int parse_condition_and_thread,
+ int parse_arg,
int tempflag, enum bptype wanted_type,
int ignore_count,
enum auto_boolean pending_break_support,
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 9cf0126..d5d58c7 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -196,6 +196,18 @@ proc test_error {} {
mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\\\]" \
"update varobj for function call"
+
+ # Try setting breakpoints with garbage after the location.
+
+ # "if" only works in the CLI. It's not supposed to be accepted by
+ # MI. The way to specify a condition is with -c.
+ mi_gdb_test "-break-insert \"callme if i < 4\"" \
+ ".*\\^error,msg=\"Garbage 'if i < 4' at end of location\"" \
+ "breakpoint with garbage after location"
+
+ mi_gdb_test "-break-insert -c i==4 \"callme if i < 4\"" \
+ ".*\\^error,msg=\"Garbage 'if i < 4' at end of location\"" \
+ "conditional breakpoint with garbage after location"
}
proc test_disabled_creation {} {
prev parent reply other threads:[~2013-04-08 14:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 12:05 Hui Zhu
2013-03-25 0:53 ` Keith Seitz
2013-03-25 7:54 ` Hui Zhu
2013-03-25 16:14 ` Yao Qi
2013-03-25 16:27 ` Hui Zhu
2013-03-25 19:32 ` Tom Tromey
2013-03-25 19:58 ` Keith Seitz
2013-03-26 11:16 ` Hui Zhu
2013-04-05 19:18 ` Pedro Alves
2013-04-08 7:56 ` Keith Seitz
2013-04-08 17:54 ` Pedro Alves [this message]
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=5162D104.6050500@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=hui_zhu@mentor.com \
--cc=keiths@redhat.com \
--cc=teawater@gmail.com \
--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