/* 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
+ 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.
This file is part of GDB.
#include <ctype.h>
#include "gdb_assert.h"
#include "observer.h"
+#include "target-descriptions.h"
/* Functions exported for general use, in inferior.h: */
void
post_create_inferior (struct target_ops *target, int from_tty)
{
+ /* If the target hasn't taken care of this already, do it now.
+ Targets which need to access registers during to_open,
+ to_create_inferior, or to_attach should do it earlier; but many
+ don't need to. */
+ target_find_description ();
+
if (exec_bfd)
{
/* Sometimes the platform-specific hook loads initial shared
kill_if_already_running (from_tty);
clear_breakpoint_hit_counts ();
+ /* Clean up any leftovers from other runs. Some other things from
+ this function should probably be moved into target_pre_inferior. */
+ target_pre_inferior (from_tty);
+
/* Purge old solib objfiles. */
objfile_purge_solibs ();
error (_("The \"finish\" command does not take any arguments."));
if (!target_has_execution)
error (_("The program is not running."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
- frame = get_prev_frame (deprecated_selected_frame);
+ frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
if (frame == 0)
error (_("\"finish\" not meaningful in the outermost frame."));
/* Find the function we will return from. */
- function = find_pc_function (get_frame_pc (deprecated_selected_frame));
+ function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
/* Print info on the selected frame, including level number but not
source. */
void
registers_info (char *addr_exp, int fpregs)
{
+ struct frame_info *frame;
int regnum, numregs;
char *end;
if (!target_has_registers)
error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
+ frame = get_selected_frame (NULL);
if (!addr_exp)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, -1, fpregs);
+ frame, -1, fpregs);
return;
}
/* A register name? */
{
- int regnum = frame_map_name_to_regnum (deprecated_selected_frame,
+ int regnum = frame_map_name_to_regnum (frame,
start, end - start);
if (regnum >= 0)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, regnum, fpregs);
+ frame, regnum, fpregs);
continue;
}
}
&& regnum < NUM_REGS + NUM_PSEUDO_REGS)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, regnum, fpregs);
+ frame, regnum, fpregs);
continue;
}
}
if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
group))
gdbarch_print_registers_info (current_gdbarch,
- gdb_stdout, deprecated_selected_frame,
+ gdb_stdout, frame,
regnum, fpregs);
}
continue;
print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
struct frame_info *frame, const char *args)
{
- if (!target_has_registers)
- error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
-
if (gdbarch_print_vector_info_p (gdbarch))
gdbarch_print_vector_info (gdbarch, file, frame, args);
else
static void
vector_info (char *args, int from_tty)
{
- print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
+ if (!target_has_registers)
+ error (_("The program has no registers now."));
+
+ print_vector_info (current_gdbarch, gdb_stdout,
+ get_selected_frame (NULL), args);
}
\f
error (_("Not killed."));
}
+ /* Clean up any leftovers from other runs. Some other things from
+ this function should probably be moved into target_pre_inferior. */
+ target_pre_inferior (from_tty);
+
/* Clear out solib state. Otherwise the solib state of the previous
inferior might have survived and is entirely wrong for the new
- target. This has been observed on Linux using glibc 2.3. How to
- reproduce:
+ target. This has been observed on GNU/Linux using glibc 2.3. How
+ to reproduce:
bash$ ./foo&
[1] 4711
print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
struct frame_info *frame, const char *args)
{
- if (!target_has_registers)
- error (_("The program has no registers now."));
- if (deprecated_selected_frame == NULL)
- error (_("No selected frame."));
-
if (gdbarch_print_float_info_p (gdbarch))
gdbarch_print_float_info (gdbarch, file, frame, args);
else
static void
float_info (char *args, int from_tty)
{
+ if (!target_has_registers)
+ error (_("The program has no registers now."));
+
print_float_info (current_gdbarch, gdb_stdout,
- deprecated_selected_frame, args);
+ get_selected_frame (NULL), args);
}
\f
static void
(see the \"directory\" command). You can also use the \"file\" command\n\
to specify the program, and to load its symbol table."));
- add_com ("detach", class_run, detach_command, _("\
+ add_prefix_cmd ("detach", class_run, detach_command, _("\
Detach a process or file previously attached.\n\
If a process, it is no longer traced, and it continues its execution. If\n\
-you were debugging a file, the file is closed and gdb no longer accesses it."));
+you were debugging a file, the file is closed and gdb no longer accesses it."),
+ &detachlist, "detach ", 0, &cmdlist);
add_com ("disconnect", class_run, disconnect_command, _("\
Disconnect from a target.\n\