This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Assertion failure because of missing inferior


From: Tom Tromey [tromey@redhat.com]

>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:

Marc> So, I was thinking that since a frontend shouldn't care which
Marc> inferior is the current one, then '-remove-inferior' could change
Marc> the current inferior to another inferior, before doing the
Marc> removal.  This is pretty much what the frontend would have to do
Marc> anyway.  Removing the very last inferior would not be allowed.

Marc> The patch below does this.  What do you think of this approach?

> This makes sense to me.

Marc> +/* Callback used to find the first inferior other than the
Marc> +   current one. */
Marc> +static int

> Blank line between comment and function start.

Marc> +  if (inf == current_inferior ())
Marc> +    {
Marc> +      struct inferior *new_inferior = iterate_over_inferiors (get_other_inferior, NULL);

> This line should be broken somewhere, probably before the '='.

Marc> +      if (new_inferior == NULL)
Marc> +       error ("Cannot remove last inferior");

> Need _() around the text.

Thanks for the review.  Here is the updated patch.

2010-12-07  Marc Khouzam  <marc.khouzam@ericsson.com>

	* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
	(get_other_inferior): New.


### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178.2.3
diff -u -r1.178.2.3 mi-main.c
--- gdb/mi/mi-main.c    12 Nov 2010 19:04:45 -0000      1.178.2.3
+++ gdb/mi/mi-main.c    8 Dec 2010 01:35:48 -0000
@@ -1623,6 +1623,18 @@
   ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
 }
 
+/* Callback used to find the first inferior other than the
+   current one. */
+   
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+  if (inf == current_inferior ())
+    return 0;
+
+  return 1;
+}
+
 void
 mi_cmd_remove_inferior (char *command, char **argv, int argc)
 {
@@ -1639,6 +1651,16 @@
   if (!inf)
     error ("the specified thread group does not exist");
 
+  if (inf == current_inferior ())
+    {
+      struct inferior *new_inferior 
+       = iterate_over_inferiors (get_other_inferior, NULL);
+      if (new_inferior == NULL)
+       error (_("Cannot remove last inferior"));
+
+      set_current_inferior (new_inferior);
+    }
+
   delete_inferior_1 (inf, 1 /* silent */);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]