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.
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.
+
+2016-01-13 Pedro Alves <palves@redhat.com>
+
PR breakpoints/19388
* frame.c (get_current_frame): Use validate_registers_access.
* gdbthread.h (validate_registers_access): Declare.
*** Changes since GDB 7.10
+* The new convenience variable $_inferior holds the number of the
+ current inferior.
+
* Record btrace now supports non-stop mode.
* Support for tracepoints on aarch64-linux was added in GDBserver.
+2016-01-13 Pedro Alves <palves@redhat.com>
+
+ * gdb.texinfo (Inferiors and Programs): Document the $_inferior
+ convenience variable.
+ (Convenience Vars): Likewise.
+
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
in the first field of the @samp{info inferiors} display.
@end table
+@vindex $_inferior@r{, convenience variable}
+The debugger convenience variable @samp{$_inferior} contains the
+number of the current inferior. You may find this useful in writing
+breakpoint conditional expressions, command scripts, and so forth.
+@xref{Convenience Vars,, Convenience Variables}, for general
+information on convenience variables.
You can get multiple executables into a debugging session via the
@code{add-inferior} and @w{@code{clone-inferior}} commands. On some
@xref{General Query Packets}.
This variable contains the address of the thread information block.
+@item $_inferior
+The number of the current inferior. @xref{Inferiors and
+Programs, ,Debugging Multiple Inferiors and Programs}.
+
@end table
@node Convenience Funs
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
+};
+
\f
void
show_print_inferior_events,
&setprintlist, &showprintlist);
+ create_internalvar_type_lazy ("_inferior", &inferior_funcs, NULL);
}
2016-01-13 Pedro Alves <palves@redhat.com>
+ * gdb.base/default.exp: Expect $_inferior as well.
+ * gdb.multi/base.exp: Test $_inferior.
+
+2016-01-13 Pedro Alves <palves@redhat.com>
+
PR breakpoints/19388
* gdb.base/catch-signal-siginfo-cond.c: New file.
* gdb.base/catch-signal-siginfo-cond.exp: New file.
{$_sdata = void} \
{$_siginfo = void} \
{$_thread = 0} \
+ {$_inferior = 1} \
{$_exception = <error: No frame selected>} \
{$_probe_argc = <error: No frame selected>} \
{$_probe_arg0 = <error: No frame selected>} \
clean_restart ${exec1}
+gdb_test {print $_inferior} " = 1"
+
# Add an empty inferior, switch to it, and load a main executable into
# it.
gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2"
gdb_test "file ${binfile2}" ".*" "load ${exec2} file in inferior 2"
+gdb_test {print $_inferior} " = 2" "print \$_inferior after switching"
+
# Add a new inferior and load a main executable into it in one
# command.
gdb_test "add-inferior -exec ${binfile3}" \