From f6de8ec2620da62f46cb4e3887b981677cdd9cdb Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 8 Apr 2013 14:09:30 +0000 Subject: [PATCH] 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 Keith Seitz * 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 * gdb.mi/mi-break.exp (test_error): Add tests with garbage after the location. --- gdb/ChangeLog | 10 ++++++++++ gdb/breakpoint.c | 25 ++++++++++++++----------- gdb/breakpoint.h | 2 +- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.mi/mi-break.exp | 12 ++++++++++++ 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81e4e85f1e2..89c7807e41f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2013-04-08 Pedro Alves + Keith Seitz + + * 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". + 2013-04-08 Aleksandar Ristovski 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 68f3ed9abeb..d740625e985 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/ChangeLog b/gdb/testsuite/ChangeLog index e7da3055423..27deae32364 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-08 Pedro Alves + + * gdb.mi/mi-break.exp (test_error): Add tests with garbage after + the location. + 2013-04-04 Sandra Loosemore * gdb.cp/cplabel.exp: Allow empty directory in file reported diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index 9cf0126dc90..d5d58c78301 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 {} { -- 2.30.2