Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* [RFA] deleting breakpoints inside of 'commands'
@ 2001-09-11 15:38 Don Howard
  2001-09-12  1:47 ` Pierre Muller
  0 siblings, 1 reply; 6+ messages in thread
From: Don Howard @ 2001-09-11 15:38 UTC (permalink / raw)
  To: gdb

The following patch addresses a core-dump that occurs when a 'commands'
script deletes the current breakpoint:

(gdb) commands
>clear
>step
>end
(gdb) break foo
(gdb) continue
	.
	.
	.
warning: Invalid control type in command structure.
Segmentation fault (core dumped)

What happens is the breakpoint (and the associated 'commands' script) is
deleted when first statement of the script is executed.  GDB runs into a
core dump when it attempts to execute the remaining (deleted)
statements.

The patch below detects if the current breakpoint has been deleted and
terminates execution of the associated 'commands' script and issues a
warning.




Index: breakpoint.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/breakpoint.c,v
retrieving revision 1.315
diff -p -u -r1.315 breakpoint.c
--- breakpoint.c        2001/07/13 23:55:47     1.315
+++ breakpoint.c        2001/09/11 22:29:40
@@ -1826,12 +1826,41 @@ top:
       cmd = bs->commands;
       while (cmd != NULL)
        {
+         int number = bs->breakpoint_at->number;
+
          execute_control_command (cmd);

          if (breakpoint_proceeded)
            break;
          else
-           cmd = cmd->next;
+           {
+             /* It is possible that the list of commands we are
+                executing includes a command to delete the current
+                breakpoint, which will also delete the current
+                command list (oops!).
+
+                If this happens we stop processing of this command
+                chain and issue a warning.
+             */
+
+             struct command_line *next_cmd = cmd->next;
+             struct breakpoint *b;
+             ALL_BREAKPOINTS (b)
+               {
+                 if (bs->breakpoint_at == b)
+                   {
+                     cmd = next_cmd;
+                     break;
+                   }
+                 else
+                   {
+                     cmd = NULL;
+                   }
+               }
+             if (cmd == NULL)
+               warning ("Breakpoint %d deleted while executing commands.",
+                        number);
+           }
        }
       if (breakpoint_proceeded)
        /* The inferior is proceeded by the command; bomb out now.



-- 
-Don
dhoward@redhat.com
gdb engineering







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-09-14 18:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-11 15:38 [RFA] deleting breakpoints inside of 'commands' Don Howard
2001-09-12  1:47 ` Pierre Muller
2001-09-13  1:01   ` Pierre Muller
2001-09-13 13:50     ` Don Howard
2001-09-13 14:14       ` Andrew Cagney
2001-09-14 18:09       ` Don Howard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox