/* Memory-access and commands for "inferior" process, for GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GDB.
if (!args)
{
- if (event_loop_p && target_can_async_p ())
+ if (target_can_async_p ())
async_disable_stdin ();
}
else
/* If we get a request for running in the bg but the target
doesn't support it, error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we don't get a request of running in the bg, then we need
to simulate synchronous (fg) execution. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution */
async_disable_stdin ();
/* If we must run in the background, but the target can't do it,
error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we are not asked to run in the bg, then prepare to run in the
foreground, synchronously. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution */
async_disable_stdin ();
/* If we get a request for running in the bg but the target
doesn't support it, error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we don't get a request of running in the bg, then we need
to simulate synchronous (fg) execution. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution */
async_disable_stdin ();
if (!single_inst || skip_subroutines) /* leave si command alone */
{
enable_longjmp_breakpoint ();
- if (!event_loop_p || !target_can_async_p ())
+ if (!target_can_async_p ())
cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
else
make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
}
/* In synchronous case, all is well, just use the regular for loop. */
- if (!event_loop_p || !target_can_async_p ())
+ if (!target_can_async_p ())
{
for (; count > 0; count--)
{
and handle them one at the time, through step_once(). */
else
{
- if (event_loop_p && target_can_async_p ())
+ if (target_can_async_p ())
step_once (skip_subroutines, single_inst, count);
}
}
/* If we must run in the background, but the target can't do it,
error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we are not asked to run in the bg, then prepare to run in the
foreground, synchronously. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution */
async_disable_stdin ();
/* If we must run in the background, but the target can't do it,
error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we are not asked to run in the bg, then prepare to run in the
foreground, synchronously. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution */
async_disable_stdin ();
/* If we must run in the background, but the target can't do it,
error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we are not asked to run in the bg, then prepare to run in the
foreground, synchronously. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution. */
async_disable_stdin ();
until_break_command (arg, from_tty, 1);
}
\f
-
-static struct value *
-legacy_return_value (int struct_return, struct type *value_type)
-{
- struct value *value;
-
- if (!struct_return)
- {
- /* The return value can be found in the inferior's registers. */
- return register_value_being_returned (value_type, stop_registers);
- }
-
- if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
- {
- CORE_ADDR addr;
-
- addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (stop_registers);
- if (!addr)
- error ("Function return value unknown.");
- return value_at (value_type, addr, NULL);
- }
-
- /* It is "struct return" yet the value is being extracted,
- presumably from registers, using EXTRACT_RETURN_VALUE. This
- doesn't make sense. Unfortunately, the legacy interfaces allowed
- this behavior. Sigh! */
- value = allocate_value (value_type);
- CHECK_TYPEDEF (value_type);
- /* If the function returns void, don't bother fetching the return
- value. */
- EXTRACT_RETURN_VALUE (value_type, stop_registers,
- VALUE_CONTENTS_RAW (value));
- return value;
-}
-
/* Print the result of a function at the end of a 'finish' command. */
static void
struct gdbarch *gdbarch = current_gdbarch;
struct cleanup *old_chain;
struct ui_stream *stb;
- struct value *value = NULL;
+ struct value *value;
+
+ gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
/* FIXME: 2003-09-27: When returning from a nested inferior function
call, it's possible (with no help from the architecture vector)
inferior function call code. In fact, when inferior function
calls are made async, this will likely be made the norm. */
- if (gdbarch_return_value_p (gdbarch))
+ switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
{
- switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
- {
- case RETURN_VALUE_REGISTER_CONVENTION:
- case RETURN_VALUE_ABI_RETURNS_ADDRESS:
- value = allocate_value (value_type);
- CHECK_TYPEDEF (value_type);
- gdbarch_return_value (current_gdbarch, value_type, stop_registers,
- VALUE_CONTENTS_RAW (value), NULL);
- break;
-
- case RETURN_VALUE_STRUCT_CONVENTION:
- break;
- }
+ case RETURN_VALUE_REGISTER_CONVENTION:
+ case RETURN_VALUE_ABI_RETURNS_ADDRESS:
+ value = allocate_value (value_type);
+ CHECK_TYPEDEF (value_type);
+ gdbarch_return_value (current_gdbarch, value_type, stop_registers,
+ value_contents_raw (value), NULL);
+ break;
+ case RETURN_VALUE_STRUCT_CONVENTION:
+ value = NULL;
+ break;
+ default:
+ internal_error (__FILE__, __LINE__, "bad switch");
}
- else
- value = legacy_return_value (struct_return, value_type);
if (value)
{
/* If we must run in the background, but the target can't do it,
error out. */
- if (event_loop_p && async_exec && !target_can_async_p ())
+ if (async_exec && !target_can_async_p ())
error ("Asynchronous execution not supported on this target.");
/* If we are not asked to run in the bg, then prepare to run in the
foreground, synchronously. */
- if (event_loop_p && !async_exec && target_can_async_p ())
+ if (!async_exec && target_can_async_p ())
{
/* Simulate synchronous execution. */
async_disable_stdin ();
breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
- if (!event_loop_p || !target_can_async_p ())
+ if (!target_can_async_p ())
old_chain = make_cleanup_delete_breakpoint (breakpoint);
else
old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
if (from_tty)
{
printf_filtered ("Run till exit from ");
- print_stack_frame (get_selected_frame (), 1, LOCATION);
+ print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
}
/* If running asynchronously and the target support asynchronous
execution, set things up for the rest of the finish command to be
completed later on, when gdb has detected that the target has
stopped, in fetch_inferior_event. */
- if (event_loop_p && target_can_async_p ())
+ if (target_can_async_p ())
{
arg1 =
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
/* Do this only if not running asynchronously or if the target
cannot do async execution. Otherwise, complete this command when
the target actually stops, in fetch_inferior_event. */
- if (!event_loop_p || !target_can_async_p ())
+ if (!target_can_async_p ())
{
/* Did we stop at our breakpoint? */
if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
target_files_info ();
printf_filtered ("Program stopped at %s.\n",
- local_hex_string ((unsigned long) stop_pc));
+ hex_string ((unsigned long) stop_pc));
if (stop_step)
printf_filtered ("It stopped after being stepped.\n");
else if (num != 0)
const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
char buffer[MAX_REGISTER_SIZE];
- if (DEPRECATED_DO_REGISTERS_INFO_P ())
- {
- DEPRECATED_DO_REGISTERS_INFO (regnum, print_all);
- return;
- }
-
for (i = 0; i < numregs; i++)
{
/* Decide between printing all regs, non-float / vector regs, or
file, 0, 1, 0, Val_pretty_default);
fprintf_filtered (file, "\t(raw 0x");
- for (j = 0; j < DEPRECATED_REGISTER_RAW_SIZE (i); j++)
+ for (j = 0; j < register_size (current_gdbarch, i); j++)
{
int idx;
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
idx = j;
else
- idx = DEPRECATED_REGISTER_RAW_SIZE (i) - 1 - j;
+ idx = register_size (current_gdbarch, i) - 1 - j;
fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
}
fprintf_filtered (file, ")");
error ("Not killed.");
}
+ /* 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:
+
+ bash$ ./foo&
+ [1] 4711
+ bash$ ./foo&
+ [1] 4712
+ bash$ gdb ./foo
+ [...]
+ (gdb) attach 4711
+ (gdb) detach
+ (gdb) attach 4712
+ Cannot access memory at address 0xdeadbeef
+ */
+#ifdef CLEAR_SOLIB
+ CLEAR_SOLIB ();
+#endif
+
target_attach (args, from_tty);
/* Set up the "saved terminal modes" of the inferior
based on what modes we are starting it with. */
target_terminal_init ();
- /* Install inferior's terminal modes. */
- target_terminal_inferior ();
-
/* Set up execution context to know that we should return from
wait_for_inferior as soon as the target reports a stop. */
init_wait_for_inferior ();
*/
target_post_attach (PIDGET (inferior_ptid));
+ /* Install inferior's terminal modes. */
+ target_terminal_inferior ();
+
normal_stop ();
if (deprecated_attach_hook)
static void
detach_command (char *args, int from_tty)
{
- dont_repeat (); /* Not for the faint of heart */
+ dont_repeat (); /* Not for the faint of heart. */
target_detach (args, from_tty);
#if defined(SOLIB_RESTART)
SOLIB_RESTART ();
void
interrupt_target_command (char *args, int from_tty)
{
- if (event_loop_p && target_can_async_p ())
+ if (target_can_async_p ())
{
dont_repeat (); /* Not for the faint of heart */
target_stop ();
static void
float_info (char *args, int from_tty)
{
- print_float_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
+ print_float_info (current_gdbarch, gdb_stdout,
+ deprecated_selected_frame, args);
}
\f
static void
&setlist);
set_cmd_completer (c, filename_completer);
set_cmd_sfunc (c, notice_args_set);
- c = add_show_from_set (c, &showlist);
+ c = deprecated_add_show_from_set (c, &showlist);
set_cmd_sfunc (c, notice_args_read);
c = add_cmd