Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Don Howard <dhoward@redhat.com>
To: <gdb-patches@sources.redhat.com>
Subject: [RFA] deleting breakpoints inside of 'commands' [Repost]
Date: Mon, 17 Sep 2001 09:34:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.33.0109151001580.1364-100000@theotherone> (raw)

[This is a repost with a few nits fixed, and addressed to the correct
list =) ]

Here is an other variation on how to deal with 'commands' scripts that
delete their own breakpoint.  The patch below makes a copy of the
commands list before executing it and deletes the copy when finished.
Comments?


2001-09-14  Don Howard  <dhoward@redhat.com>

	* breakpoint.c (bpstat_do_actions): Avoid deleting a 'commands'
	list while executing that list.  Thanks to Pierre Muller
	<muller@ics.u-strasbg.fr> for suggesting this implementation.
	* cli/cli-script.c (dup_command_lines): New function.
	* defs.h: Added declaration of new function.


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/17 16:30:46
@@ -1824,7 +1824,8 @@ top:
   breakpoint_proceeded = 0;
   for (; bs != NULL; bs = bs->next)
     {
-      cmd = bs->commands;
+      cmd = dup_command_lines (bs->commands);
+
       while (cmd != NULL)
 	{
 	  execute_control_command (cmd);
@@ -1834,6 +1835,9 @@ top:
 	  else
 	    cmd = cmd->next;
 	}
+
+      free_command_lines (&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.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.63
diff -p -u -w -r1.63 defs.h
--- defs.h	2001/09/07 21:33:08	1.63
+++ defs.h	2001/09/17 16:30:47
@@ -837,6 +837,7 @@ struct command_line
 extern struct command_line *read_command_lines (char *, int);

 extern void free_command_lines (struct command_line **);
+extern struct command_line * dup_command_lines (struct command_line *);

 /* To continue the execution commands when running gdb asynchronously.
    A continuation structure contains a pointer to a function to be called
Index: cli/cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.7
diff -p -u -w -r1.7 cli-script.c
--- cli-script.c	2001/06/17 15:16:12	1.7
+++ cli-script.c	2001/09/17 16:30:47
@@ -1005,6 +1005,59 @@ read_command_lines (char *prompt_arg, in
   return (head);
 }

+/* Duplicate a chain of struct command_line's */
+
+struct command_line *
+dup_command_lines (struct command_line *l)
+{
+  struct command_line *dup = NULL;
+  register struct command_line *next = NULL;
+
+
+  for (; l ; l = l->next)
+    {
+      if (next == NULL)
+	{
+	  dup = next = (struct command_line *)
+	    xmalloc (sizeof (struct command_line));
+	}
+      else
+	{
+	  next->next = (struct command_line *)
+	    xmalloc (sizeof (struct command_line));
+
+	  next = next->next;
+	}
+
+
+      if (next == NULL)
+	return NULL;
+
+
+      next->next = NULL;
+      next->line = xstrdup (l->line);
+      next->control_type = l->control_type;
+      next->body_count = l->body_count;
+
+
+      if (l->body_count > 0)
+	{
+	  int i;
+	  struct command_line **blist = l->body_list;
+
+	  next->body_list =
+	    (struct command_line **) xmalloc (sizeof (struct command_line *)
+					      * l->body_count);
+
+	  for (i = 0; i < l->body_count; i++, blist++)
+	    next->body_list[i] = dup_command_lines (*blist);
+	}
+    }
+
+  return dup;
+}
+
+
 /* Free a chain of struct command_line's.  */

 void


-- 
-Don
dhoward@redhat.com
gdb engineering






             reply	other threads:[~2001-09-17  9:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-17  9:34 Don Howard [this message]
2001-09-17 15:39 ` Michael Snyder
2001-09-18  6:56   ` Fernando Nasser
2001-09-18  7:56     ` Andrew Cagney
2001-09-18  8:09       ` Fernando Nasser
2001-09-18 10:34       ` Michael Snyder
2001-09-18 17:47         ` Andrew Cagney
2001-09-18 18:03           ` Michael Snyder
2001-09-19  7:20             ` Fernando Nasser
2001-09-19  8:17               ` Andrew Cagney
2001-09-19  9:22                 ` Fernando Nasser
2001-09-19 11:44                   ` PRMS not TODO: " Andrew Cagney
2001-09-19  9:33                 ` Don Howard
2001-09-19 12:08                   ` Kevin Buettner
2001-09-19 12:18                     ` Michael Snyder
2001-09-19 13:09                       ` Kevin Buettner
     [not found]                     ` <3BA905AD.5F8F1A68@redhat.com>
2001-09-19 14:22                       ` Kevin Buettner
2001-09-19 14:44                         ` Fernando Nasser
2001-09-20 15:24                 ` Don Howard
2001-09-20 18:05                   ` Andrew Cagney
     [not found] <Pine.LNX.4.33.0109211638230.1755-100000@theotherone>
2001-09-24 17:10 ` Kevin Buettner
2001-09-24 17:33   ` Kevin Buettner
2001-09-24 18:52   ` Andrew Cagney
2001-09-26 13:07     ` Fernando Nasser
2001-09-26 14:20       ` Kevin Buettner
2001-09-26 14:57         ` Fernando Nasser
2001-09-26 15:09           ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.33.0109151001580.1364-100000@theotherone \
    --to=dhoward@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox