This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-8.2-branch] Fix regression for multi breakpoints command line clearing.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5dc5ecd1fde2c3eba2f0c870ad12c4cb120224d0

commit 5dc5ecd1fde2c3eba2f0c870ad12c4cb120224d0
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Thu Aug 2 23:13:22 2018 +0200

    Fix regression for multi breakpoints command line clearing.
    
    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.
    
    gdb/ChangeLog
    
    2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
    
    	* breakpoint.c (commands_command_1): New boolean cmd_read
    	to detect cmd was already read.

Diff:
---
 gdb/breakpoint.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 77c4638..2c031c0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1221,6 +1221,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;
 
@@ -1237,8 +1241,9 @@ commands_command_1 (const char *arg, int from_tty,
   map_breakpoint_numbers
     (arg, [&] (breakpoint *b)
      {
-       if (cmd == NULL)
+       if (!cmd_read)
 	 {
+	   gdb_assert (cmd == NULL);
 	   if (control != NULL)
 	     cmd = control->body_list_0;
 	   else
@@ -1258,6 +1263,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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]