aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorMarc Khouzam <marc.khouzam@ericsson.com>2010-12-18 02:10:05 +0000
committerMarc Khouzam <marc.khouzam@ericsson.com>2010-12-18 02:10:05 +0000
commit57bf2d7ed85a9edec723fbfb4871c78b29143c2d (patch)
treed071682bbe0e92efa8f2459c66bc16d37552823e /gdb/mi
parentb3422a0d89b53878bd912c570369227e91519776 (diff)
downloadfsf-binutils-gdb-57bf2d7ed85a9edec723fbfb4871c78b29143c2d.zip
fsf-binutils-gdb-57bf2d7ed85a9edec723fbfb4871c78b29143c2d.tar.gz
fsf-binutils-gdb-57bf2d7ed85a9edec723fbfb4871c78b29143c2d.tar.bz2
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
(get_other_inferior): New.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-main.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 48e907f..b03a8b9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1744,6 +1744,18 @@ mi_cmd_add_inferior (char *command, char **argv, int argc)
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)
{
@@ -1760,6 +1772,22 @@ mi_cmd_remove_inferior (char *command, char **argv, int argc)
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct thread_info *tp = 0;
+ 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);
+ if (new_inferior->pid != 0)
+ tp = any_thread_of_process (new_inferior->pid);
+ switch_to_thread (tp ? tp->ptid : null_ptid);
+ set_current_program_space (new_inferior->pspace);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}