/* Memory-access and commands for "inferior" process, for GDB.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
- Free Software Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdb_assert.h"
#include "observer.h"
#include "target-descriptions.h"
+#include "user-regs.h"
/* Functions exported for general use, in inferior.h: */
static void nofp_registers_info (char *, int);
-static void print_return_value (int struct_return, struct type *value_type);
+static void print_return_value (struct type *value_type);
static void finish_command_continuation (struct continuation_arg *);
{
/* Sometimes the platform-specific hook loads initial shared
libraries, and sometimes it doesn't. Try to do so first, so
- that we can add them with the correct value for FROM_TTY. */
+ that we can add them with the correct value for FROM_TTY.
+ If we made all the inferior hook methods consistent,
+ this call could be removed. */
#ifdef SOLIB_ADD
SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
#else
#else
solib_create_inferior_hook ();
#endif
-
- /* Enable any breakpoints which were disabled when the
- underlying shared library was deleted. */
- re_enable_breakpoints_in_shlibs ();
}
observer_notify_inferior_created (target, from_tty);
/* Purge old solib objfiles. */
objfile_purge_solibs ();
- do_run_cleanups (NULL);
+ clear_solib ();
/* The comment here used to read, "The exec file is re-read every
time we do a generic_mourn_inferior, so we just have to worry
target_create_inferior (exec_file, get_inferior_args (),
environ_vector (inferior_environ), from_tty);
- post_create_inferior (¤t_target, from_tty);
+ /* Pass zero for FROM_TTY, because at this point the "run" command
+ has done its thing; now we are setting up the running program. */
+ post_create_inferior (¤t_target, 0);
/* Start the target running. */
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
if (from_tty)
{
printf_filtered (_("Continuing at "));
- deprecated_print_address_numeric (addr, 1, gdb_stdout);
+ fputs_filtered (paddress (addr), gdb_stdout);
printf_filtered (".\n");
}
/* Print the result of a function at the end of a 'finish' command. */
static void
-print_return_value (int struct_return, struct type *value_type)
+print_return_value (struct type *value_type)
{
struct gdbarch *gdbarch = current_gdbarch;
struct cleanup *old_chain;
case RETURN_VALUE_ABI_RETURNS_ADDRESS:
case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
value = allocate_value (value_type);
- gdbarch_return_value (current_gdbarch, value_type, stop_registers,
+ gdbarch_return_value (gdbarch, value_type, stop_registers,
value_contents_raw (value), NULL);
break;
case RETURN_VALUE_STRUCT_CONVENTION:
&& function != NULL)
{
struct type *value_type;
- int struct_return;
- int gcc_compiled;
value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
if (!value_type)
internal_error (__FILE__, __LINE__,
_("finish_command: function has no target type"));
- if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
- {
- do_exec_cleanups (cleanups);
- return;
- }
-
- CHECK_TYPEDEF (value_type);
- gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
- struct_return = using_struct_return (value_type, gcc_compiled);
-
- print_return_value (struct_return, value_type);
+ if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
+ print_return_value (value_type);
}
do_exec_cleanups (cleanups);
&& function != NULL)
{
struct type *value_type;
- int struct_return;
- int gcc_compiled;
value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
if (!value_type)
internal_error (__FILE__, __LINE__,
_("finish_command: function has no target type"));
- /* FIXME: Shouldn't we do the cleanups before returning? */
- if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
- return;
-
- CHECK_TYPEDEF (value_type);
- gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
- struct_return = using_struct_return (value_type, gcc_compiled);
-
- print_return_value (struct_return, value_type);
+ if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
+ print_return_value (value_type);
}
do_cleanups (old_chain);
int regnum, int print_all)
{
int i;
- const int numregs = gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch);
+ const int numregs = gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
gdb_byte buffer[MAX_REGISTER_SIZE];
for (i = 0; i < numregs; i++)
/* If the register name is empty, it is undefined for this
processor, so don't display anything. */
- if (gdbarch_register_name (current_gdbarch, i) == NULL
- || *(gdbarch_register_name (current_gdbarch, i)) == '\0')
+ if (gdbarch_register_name (gdbarch, i) == NULL
+ || *(gdbarch_register_name (gdbarch, i)) == '\0')
continue;
- fputs_filtered (gdbarch_register_name (current_gdbarch, i), file);
+ fputs_filtered (gdbarch_register_name (gdbarch, i), file);
print_spaces_filtered (15 - strlen (gdbarch_register_name
- (current_gdbarch, i)), file);
+ (gdbarch, i)), file);
/* Get the data in raw format. */
if (! frame_register_read (frame, i, buffer))
/* If virtual format is floating, print it that way, and in raw
hex. */
- if (TYPE_CODE (register_type (current_gdbarch, i)) == TYPE_CODE_FLT)
+ if (TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_FLT)
{
int j;
- val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+ val_print (register_type (gdbarch, i), buffer, 0, 0,
file, 0, 1, 0, Val_pretty_default);
fprintf_filtered (file, "\t(raw 0x");
- for (j = 0; j < register_size (current_gdbarch, i); j++)
+ for (j = 0; j < register_size (gdbarch, i); j++)
{
int idx;
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
idx = j;
else
- idx = register_size (current_gdbarch, i) - 1 - j;
+ idx = register_size (gdbarch, i) - 1 - j;
fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
}
fprintf_filtered (file, ")");
else
{
/* Print the register in hex. */
- val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+ val_print (register_type (gdbarch, i), buffer, 0, 0,
file, 'x', 1, 0, Val_pretty_default);
/* If not a vector register, print it also according to its
natural format. */
- if (TYPE_VECTOR (register_type (current_gdbarch, i)) == 0)
+ if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
{
fprintf_filtered (file, "\t");
- val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+ val_print (register_type (gdbarch, i), buffer, 0, 0,
file, 0, 1, 0, Val_pretty_default);
}
}
registers_info (char *addr_exp, int fpregs)
{
struct frame_info *frame;
+ struct gdbarch *gdbarch;
int regnum, numregs;
char *end;
if (!target_has_registers)
error (_("The program has no registers now."));
frame = get_selected_frame (NULL);
+ gdbarch = get_frame_arch (frame);
if (!addr_exp)
{
- gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ gdbarch_print_registers_info (gdbarch, gdb_stdout,
frame, -1, fpregs);
return;
}
while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
addr_exp++;
end = addr_exp;
-
+
/* Figure out what we've found and display it. */
/* A register name? */
{
- int regnum = frame_map_name_to_regnum (frame,
- start, end - start);
+ int regnum = frame_map_name_to_regnum (frame, start, end - start);
if (regnum >= 0)
{
- gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- frame, regnum, fpregs);
+ /* User registers lie completely outside of the range of
+ normal registers. Catch them early so that the target
+ never sees them. */
+ if (regnum >= gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch))
+ {
+ struct value *val = value_of_user_reg (regnum, frame);
+
+ printf_filtered ("%s: ", start);
+ print_scalar_formatted (value_contents (val),
+ check_typedef (value_type (val)),
+ 'x', 0, gdb_stdout);
+ printf_filtered ("\n");
+ }
+ else
+ gdbarch_print_registers_info (gdbarch, gdb_stdout,
+ frame, regnum, fpregs);
continue;
}
}
-
+
/* A register number? (how portable is this one?). */
{
char *endptr;
int regnum = strtol (start, &endptr, 0);
if (endptr == end
&& regnum >= 0
- && regnum < gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch))
+ && regnum < gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch))
{
- gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ gdbarch_print_registers_info (gdbarch, gdb_stdout,
frame, regnum, fpregs);
continue;
}
/* A register group? */
{
struct reggroup *group;
- for (group = reggroup_next (current_gdbarch, NULL);
+ for (group = reggroup_next (gdbarch, NULL);
group != NULL;
- group = reggroup_next (current_gdbarch, group))
+ group = reggroup_next (gdbarch, group))
{
/* Don't bother with a length check. Should the user
enter a short register group name, go with the first
{
int regnum;
for (regnum = 0;
- regnum < gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch);
+ regnum < gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
regnum++)
{
- if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
- group))
- gdbarch_print_registers_info (current_gdbarch,
+ if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
+ gdbarch_print_registers_info (gdbarch,
gdb_stdout, frame,
regnum, fpregs);
}
int printed_something = 0;
for (regnum = 0;
- regnum < gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch);
+ regnum < gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
regnum++)
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
(gdb) attach 4712
Cannot access memory at address 0xdeadbeef
*/
-#ifdef CLEAR_SOLIB
- CLEAR_SOLIB ();
-#else
- clear_solib ();
-#endif
+ clear_solib ();
target_attach (args, from_tty);
int printed_something = 0;
for (regnum = 0;
- regnum < gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch);
+ regnum < gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
regnum++)
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))