This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] deleting breakpoints inside of 'commands' [Repost]
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: [RFA] deleting breakpoints inside of 'commands' [Repost]
- From: Don Howard <dhoward at redhat dot com>
- Date: Fri, 21 Sep 2001 16:53:18 -0700 (PDT)
- Cc: Kevin Buettner <kevinb at cygnus dot com>, Fernando Nasser <fnasser at redhat dot com>, Michael Snyder <msnyder at cygnus dot com>, <gdb-patches at sources dot redhat dot com>
One more try. =) This patch adds a new field to struct command_line:
'executing'. If this field is non-zero, free_command_lines() will not
delete that struct command_line. Instead, it increments the value of
'executing'. bpstats_do_action() uses this behavior to see if it needs
to delete the command_line after executing all the statements in the
list.
Comments?
2001-09-21 Don Howard <dhoward@redhat.com>
* cli/cli-script.c (build_command_line): Added initialization of
new field.
(read_next_line): Ditto.
(free_command_lines): Avoid deleting command_line lists while
executing them.
* breakpoint.c (bpstat_do_actions): Ditto.
* defs.h: (struct
command_line): Added new field 'executing'.
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.53
diff -p -u -r1.53 breakpoint.c
--- breakpoint.c 2001/09/18 05:00:48 1.53
+++ breakpoint.c 2001/09/21 23:49:48
@@ -1800,6 +1800,7 @@ bpstat_do_actions (bpstat *bsp)
bpstat bs;
struct cleanup *old_chain;
struct command_line *cmd;
+ struct command_line *cmd_head;
/* Avoid endless recursion if a `source' command is contained
in bs->commands. */
@@ -1824,6 +1825,10 @@ top:
breakpoint_proceeded = 0;
for (; bs != NULL; bs = bs->next)
{
+ cmd_head = bs->commands;
+ if (cmd_head)
+ cmd_head->executing = 1;
+
cmd = bs->commands;
while (cmd != NULL)
{
@@ -1834,6 +1839,15 @@ top:
else
cmd = cmd->next;
}
+
+ if (cmd_head->executing != 1)
+ {
+ cmd_head->executing = 0;
+ free_command_lines (&cmd_head);
+ }
+ else
+ cmd_head->executing = 0;
+
if (breakpoint_proceeded)
/* The inferior is proceeded by the command; bomb out now.
The bpstat chain has been blown away by wait_for_inferior.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.63
diff -p -u -r1.63 defs.h
--- defs.h 2001/09/07 21:33:08 1.63
+++ defs.h 2001/09/21 23:49:51
@@ -832,6 +832,7 @@ struct command_line
enum command_control_type control_type;
int body_count;
struct command_line **body_list;
+ int executing;
};
extern struct command_line *read_command_lines (char *, int);
Index: cli/cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.7
diff -p -u -r1.7 cli-script.c
--- cli-script.c 2001/06/17 15:16:12 1.7
+++ cli-script.c 2001/09/21 23:49:51
@@ -96,6 +96,7 @@ build_command_line (enum command_control
* cmd->body_count);
memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count);
cmd->line = savestring (args, strlen (args));
+ cmd->executing = 0;
return cmd;
}
@@ -775,6 +776,7 @@ read_next_line (struct command_line **co
(*command)->control_type = break_control;
(*command)->body_count = 0;
(*command)->body_list = NULL;
+ (*command)->executing = 0;
}
else if (p1 - p == 13 && !strncmp (p, "loop_continue", 13))
{
@@ -785,6 +787,7 @@ read_next_line (struct command_line **co
(*command)->control_type = continue_control;
(*command)->body_count = 0;
(*command)->body_list = NULL;
+ (*command)->executing = 0;
}
else
{
@@ -796,6 +799,7 @@ read_next_line (struct command_line **co
(*command)->control_type = simple_control;
(*command)->body_count = 0;
(*command)->body_list = NULL;
+ (*command)->executing = 0;
}
/* Nothing special. */
@@ -1015,6 +1019,13 @@ free_command_lines (struct command_line
struct command_line **blist;
int i;
+ /* Avoid deleting command_line lists while executing that list. */
+ if (l && l->executing)
+ {
+ l->executing++;
+ return;
+ }
+
while (l)
{
if (l->body_count > 0)
--
-Don
dhoward@redhat.com
gdb engineering