aboutsummaryrefslogtreecommitdiff
path: root/gdb/inferior.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-01-13 10:56:05 +0000
committerPedro Alves <palves@redhat.com>2016-01-13 10:56:05 +0000
commite3940304fe75c91f99e260a89fe8c45ece7e373f (patch)
tree676ba36c91a97c1c80964bc8ef566d1cc424b4bb /gdb/inferior.c
parenta911d87ad714cbfbbc5c5752cb8b445a7e70196c (diff)
Add a new $_inferior convenience variable
Like $_thread, but holds the current inferior number. gdb/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * NEWS: Mention $_inferior. * inferior.c (inferior_id_make_value): New. (inferior_funcs): New. (_initialize_inferior): Create $_inferior variable. gdb/testsuite/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * gdb.base/default.exp: Expect $_inferior as well. * gdb.multi/base.exp: Test $_inferior. gdb/doc/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * gdb.texinfo (Inferiors and Programs): Document the $_inferior convenience variable. (Convenience Vars): Likewise.
Diffstat (limited to 'gdb/inferior.c')
-rw-r--r--gdb/inferior.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/inferior.c b/gdb/inferior.c
index e71104d6e9..8f9ac3358b 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -1008,6 +1008,26 @@ show_print_inferior_events (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("Printing of inferior events is %s.\n"), value);
}
+/* Return a new value for the selected inferior's id. */
+
+static struct value *
+inferior_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+ void *ignore)
+{
+ struct inferior *inf = current_inferior ();
+
+ return value_from_longest (builtin_type (gdbarch)->builtin_int, inf->num);
+}
+
+/* Implementation of `$_inferior' variable. */
+
+static const struct internalvar_funcs inferior_funcs =
+{
+ inferior_id_make_value,
+ NULL,
+ NULL
+};
+
void
@@ -1071,4 +1091,5 @@ Show printing of inferior events (e.g., inferior start and exit)."), NULL,
show_print_inferior_events,
&setprintlist, &showprintlist);
+ create_internalvar_type_lazy ("_inferior", &inferior_funcs, NULL);
}