From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Howard To: Pierre Muller Cc: Subject: Re: [RFA] deleting breakpoints inside of 'commands' Date: Thu, 13 Sep 2001 13:50:00 -0000 Message-id: References: <4.2.0.58.20010913094436.00c609e0@ics.u-strasbg.fr> X-SW-Source: 2001-09/msg00114.html I've attempted to implement your sugesstion in the patch below. I need some feedback from folks who are familiar with the breakpoint code. I think it maybe as you say, that a copy of the commands list should be allocated. With this patch, gdb no longer dumps core when a command list deletes it's breakpoint, but commands lists get lost after hitting the associated breakpoint once or twice. If someone can explain to me what gdb does with bpstat structures when the target continues, (and how that may interact with this patch) that would be most useful. 2001-09-12 Don Howard * breakpoint.c (bpstat_do_actions): Avoid deleting a 'commands' list while executing that list. Thanks to Pierre Muller for suggesting this implementation. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.52 diff -p -u -w -r1.52 breakpoint.c --- breakpoint.c 2001/08/02 11:58:28 1.52 +++ breakpoint.c 2001/09/13 20:16:18 @@ -1824,7 +1824,24 @@ top: breakpoint_proceeded = 0; for (; bs != NULL; bs = bs->next) { - cmd = bs->commands; + /* 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!). + + Pierre Muller + suggested that the commands list could be disconnected from + it's associated breakpoint structure during execution of the + list. Once execution is complete, we check for the + non-existence of the breakpoint. If the breakpoint has been + deleted, we free the associated command list. */ + + struct command_line *head_cmd; + + head_cmd = cmd = bs->commands; + bs->commands = NULL; + if (bs->breakpoint_at) + bs->breakpoint_at->commands = NULL; + while (cmd != NULL) { execute_control_command (cmd); @@ -1834,6 +1851,31 @@ top: else cmd = cmd->next; } + + /* Detect if the command list has deleted the current + breakpoint. */ + { + int deleted = 1; + struct breakpoint *b; + + ALL_BREAKPOINTS (b) + if (bs->breakpoint_at == b) + { + deleted = 0; + break; + } + + if (deleted) + free_command_lines (&head_cmd); + else + { + bs->commands = head_cmd; + if (bs->breakpoint_at) + bs->breakpoint_at->commands = head_cmd; + } + } + + if (breakpoint_proceeded) /* The inferior is proceeded by the command; bomb out now. The bpstat chain has been blown away by wait_for_inferior. -- -Don dhoward@redhat.com gdb engineering