diff mbox

[RFAv2,1/2] Fix regression for multi breakpoints command line clearing.

Message ID 20180826154708.28601-2-philippe.waroquiers@skynet.be
State New
Headers show

Commit Message

Philippe Waroquiers Aug. 26, 2018, 3:47 p.m. UTC
breakpoint.c is modified to fix the regression introduced
when clearing the commands of several breakpoints by giving an empty
list of commands, by just typing "end".
GDB should read an empty list of command once, but it reads
it for each breakpoint, as an empty list of command is NULL,
and NULL is interpreted as 'not having read the command list yet'.

The fix consists in having a boolean set to true once the
command list has been read.


2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* breakpoint.c (commands_command_1): New boolean cmd_read
	to detect cmd was already read.
 gdb/breakpoint.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)


Tom Tromey Aug. 28, 2018, 3:58 p.m. UTC | #1
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:

Philippe> 2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

Philippe> 	* breakpoint.c (commands_command_1): New boolean cmd_read
Philippe> 	to detect cmd was already read.

Thanks for doing this.
This is ok.  I think it should go on the 8.2 branch as well.

Philippe Waroquiers Aug. 28, 2018, 9:37 p.m. UTC | #2
On Tue, 2018-08-28 at 09:58 -0600, Tom Tromey wrote
> This is ok.  I think it should go on the 8.2 branch as well.

Pushed the series to master and 8.2 branch.

Thanks to Pedro and Tom for the reviews.

diff mbox


diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8f0feaa474..4e7dac5157 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1219,6 +1219,10 @@  commands_command_1 (const char *arg, int from_tty,
 		    struct command_line *control)
   counted_command_line cmd;
+  /* cmd_read will be true once we have read cmd.  Note that cmd might still be
+     NULL after the call to read_command_lines if the user provides an empty
+     list of command by just typing "end".  */
+  bool cmd_read = false;
   std::string new_arg;
@@ -1235,8 +1239,9 @@  commands_command_1 (const char *arg, int from_tty,
     (arg, [&] (breakpoint *b)
-       if (cmd == NULL)
+       if (!cmd_read)
+	   gdb_assert (cmd == NULL);
 	   if (control != NULL)
 	     cmd = control->body_list_0;
@@ -1256,6 +1261,7 @@  commands_command_1 (const char *arg, int from_tty,
 	       cmd = read_command_lines (str.c_str (), from_tty, 1, validator);
+	   cmd_read = true;
        /* If a breakpoint was on the list more than once, we don't need to