Index: breakpoint.c =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-5/gdb/breakpoint.c,v retrieving revision 1.1.1.1.2.3.2.9 diff -c -3 -p -r1.1.1.1.2.3.2.9 breakpoint.c *** breakpoint.c 29 Aug 2002 16:41:28 -0000 1.1.1.1.2.3.2.9 --- breakpoint.c 11 Dec 2002 17:08:52 -0000 *************** bpstat_clear (bpstat *bsp) *** 1686,1692 **** q = p->next; if (p->old_val != NULL) value_free (p->old_val); - free_command_lines (&p->commands); xfree (p); p = q; } --- 1686,1691 ---- *************** bpstat_do_actions (bpstat *bsp) *** 1827,1832 **** --- 1826,1832 ---- bpstat bs; struct cleanup *old_chain; struct command_line *cmd; + struct command_line *saved_cmd; /* Avoid endless recursion if a `source' command is contained in bs->commands. */ *************** top: *** 1852,1857 **** --- 1852,1858 ---- for (; bs != NULL; bs = bs->next) { cmd = bs->commands; + saved_cmd = cmd; while (cmd != NULL) { execute_control_command (cmd); *************** top: *** 1861,1866 **** --- 1862,1877 ---- else cmd = cmd->next; } + + /* Deallocate the commands line that we just executed. We can not + deallocate directly the commands line in bs, as bs may have + changed while inside excecute_command_control if the command + caused the inferior to resume. Note that there is no memory + leak when an error is raised inside execute_control_command, + because the error catching mechanism automatically deallocates + it from the global stop_bpstat. */ + free_command_lines (&saved_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. *************** top: *** 1868,1874 **** to look at, so start over. */ goto top; else ! free_command_lines (&bs->commands); } do_cleanups (old_chain); } --- 1879,1889 ---- to look at, so start over. */ goto top; else ! /* Since we deallocated the command_lines above, make sure ! to reset the commands in the bpstat, so make sure we do ! not leave any dangling pointer. */ ! bs->commands = NULL; ! } do_cleanups (old_chain); } *************** bpstat_stop_status (CORE_ADDR *pc, int n *** 2643,2651 **** /* We will stop here */ if (b->disposition == disp_disable) b->enable_state = bp_disabled; - bs->commands = copy_command_lines (b->commands); if (b->silent) bs->print = 0; if (bs->commands && (STREQ ("silent", bs->commands->line) || (xdb_commands && STREQ ("Q", bs->commands->line)))) --- 2658,2666 ---- /* We will stop here */ if (b->disposition == disp_disable) b->enable_state = bp_disabled; if (b->silent) bs->print = 0; + bs->commands = b->commands; if (bs->commands && (STREQ ("silent", bs->commands->line) || (xdb_commands && STREQ ("Q", bs->commands->line)))) *************** bpstat_stop_status (CORE_ADDR *pc, int n *** 2653,2658 **** --- 2668,2677 ---- bs->commands = bs->commands->next; bs->print = 0; } + /* Copy the part of the command lines that will be executed, + as the breakpoint may disappear before or during its + execution. */ + bs->commands = copy_command_lines (bs->commands); } } /* Print nothing for this entry if we dont stop or if we dont print. */