the last address examined (@pxref{Memory, ,Examining Memory}). Other
commands which provide a default address for @code{x} to examine also
set @code{$_} to that address; these commands include @code{info line}
-and @code{info breakpoint}. The type of @code{$_} is @code{void *}
+and @code{info breakpoint}. The type of @code{$_} is @code{void (*)()}
except when set by the @code{x} command, in which case it is a pointer
to the type of @code{$__}.
}
/* Specify default address for `x' command.
- The `info lines' command uses this. */
+ The `info lines' and `info breakpoints' commands use this. */
void
set_next_address (struct gdbarch *gdbarch, CORE_ADDR addr)
{
- struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+ type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
next_gdbarch = gdbarch;
next_address = addr;
gdb_test "print \$foo" " = 301" \
"print new contents of convenience variable"
+ gdb_test "print \$_" "= void" \
+ "convenience var \$_ is not set yet"
+
+ # "info breakpoints" sets $_ to a (void (*)()).
+ set last_line [gdb_get_line_number "last line"]
+ gdb_breakpoint $last_line
+ gdb_test "info breakpoint" ".*" "info break"
+ delete_breakpoints
+
+ set re_fptr [string_to_regexp "(void (*)())"]
+ gdb_test "print \$_" "= $re_fptr $::hex.*" \
+ "convenience var \$_ is set to a function pointer"
+
gdb_test_no_output "set \$_ = 11" \
"set convenience variable \$_"
gdb_test "print \$_" " = 11" \
"print contents of convenience variable \$_"
+ # "info line" sets $_ to a (void (*)()), too.
+ gdb_test "info line $last_line" ".*"
+ gdb_test "print \$_" "= $re_fptr $::hex.*" \
+ "convenience var \$_ is set to an address again"
+
gdb_test "print \$foo + 10" " = 311" \
"use convenience variable in arithmetic expression"