From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Fix regression in "commands"
Date: Fri, 03 Nov 2017 19:07:00 -0000 [thread overview]
Message-ID: <20171103190747.389-1-tom@tromey.com> (raw)
Pedro pointed out a regression in "commands", where trying to clear a
breakpoint's command list would fail:
(top-gdb) commands
Type commands for breakpoint(s) 3, one per line.
End with a line saying just "end".
>end
No breakpoints specified.
(top-gdb)
I believe the bug was introduced by my patch that changes
counted_command_line to be a shared_ptr. This causes the problem
because now the counted_command_line in commands_command_1 can be NULL,
whereas previously it never could be.
The fix here is to track whether commands have been read using a
separate flag.
2017-11-03 Tom Tromey <tom@tromey.com>
* breakpoint.c (commands_command_1): Use a flag to track whether
commands have been read.
2017-11-03 Tom Tromey <tom@tromey.com>
* gdb.base/break.exp: Add test for empty "commands".
---
gdb/ChangeLog | 5 +++++
gdb/breakpoint.c | 7 +++++--
gdb/testsuite/ChangeLog | 4 ++++
gdb/testsuite/gdb.base/break.exp | 5 +++++
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1f823ca..0dc20bf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-03 Tom Tromey <tom@tromey.com>
+
+ * breakpoint.c (commands_command_1): Use a flag to track whether
+ commands have been read.
+
2017-11-03 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (convert_doublest_to_floatformat): Fix uninitialized
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0bf47d5..609f1ed 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1255,6 +1255,7 @@ commands_command_1 (const char *arg, int from_tty,
struct command_line *control)
{
counted_command_line cmd;
+ bool read_commands = false;
std::string new_arg;
@@ -1271,7 +1272,7 @@ commands_command_1 (const char *arg, int from_tty,
map_breakpoint_numbers
(arg, [&] (breakpoint *b)
{
- if (cmd == NULL)
+ if (!read_commands)
{
if (control != NULL)
cmd = copy_command_lines (control->body_list[0]);
@@ -1288,6 +1289,8 @@ commands_command_1 (const char *arg, int from_tty,
? check_tracepoint_command : 0),
b);
}
+
+ read_commands = true;
}
/* If a breakpoint was on the list more than once, we don't need to
@@ -1300,7 +1303,7 @@ commands_command_1 (const char *arg, int from_tty,
}
});
- if (cmd == NULL)
+ if (!read_commands)
error (_("No breakpoints specified."));
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 158fea4..e82d2b9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-03 Tom Tromey <tom@tromey.com>
+
+ * gdb.base/break.exp: Add test for empty "commands".
+
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.mi/list-thread-groups-available.exp: Skip it if XML parsing
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 96e2f35..604d957 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -854,3 +854,8 @@ gdb_test_no_output "set \$foo=81.5" \
gdb_test "break $srcfile:\$foo" \
"Convenience variables used in line specs must have integer values.*" \
"set breakpoint via non-integer convenience variable disallowed"
+
+
+# Test that commands can be cleared without error.
+gdb_test "commands\nend" ">end" "clear breakpoint commands"
+
--
2.9.5
next reply other threads:[~2017-11-03 19:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 19:07 Tom Tromey [this message]
2017-11-07 10:49 ` Pedro Alves
2017-12-01 16:45 ` Tom Tromey
2017-12-04 15:50 ` Pedro Alves
2017-12-07 18:13 ` Tom Tromey
2017-12-07 18:27 ` Pedro Alves
2017-12-01 16:56 ` Tom Tromey
2017-12-04 15:55 ` Pedro Alves
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=20171103190747.389-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).