This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
[RFA] deleting breakpoints inside of 'commands'
- To: <gdb at sources dot redhat dot com>
- Subject: [RFA] deleting breakpoints inside of 'commands'
- From: Don Howard <dhoward at redhat dot com>
- Date: Tue, 11 Sep 2001 15:37:22 -0700 (PDT)
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