From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Howard To: Subject: [RFA] deleting breakpoints inside of 'commands' Date: Tue, 11 Sep 2001 15:38:00 -0000 Message-id: X-SW-Source: 2001-09/msg00107.html 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