/* 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, 2005
+ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
#include "defs.h"
#include <signal.h>
#include "solib.h"
#include <ctype.h>
#include "gdb_assert.h"
+#include "observer.h"
/* Functions exported for general use, in inferior.h: */
/* File name for default use for standard in/out in the inferior. */
-char *inferior_io_terminal;
+static char *inferior_io_terminal;
/* Pid of our debugged inferior, or 0 if no inferior now.
Since various parts of infrun.c test this to see whether there is a program
\f
/* Accessor routines. */
+void
+set_inferior_io_terminal (const char *terminal_name)
+{
+ if (inferior_io_terminal)
+ xfree (inferior_io_terminal);
+
+ if (!terminal_name)
+ inferior_io_terminal = NULL;
+ else
+ inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
+}
+
+const char *
+get_inferior_io_terminal (void)
+{
+ return inferior_io_terminal;
+}
+
char *
get_inferior_args (void)
{
if (file == 0)
error_no_arg (_("terminal name for running target process"));
- inferior_io_terminal = savestring (file, strlen (file));
+ set_inferior_io_terminal (file);
+}
+
+/* Common actions to take after creating any sort of inferior, by any
+ means (running, attaching, connecting, et cetera). The target
+ should be stopped. */
+
+void
+post_create_inferior (struct target_ops *target, int from_tty)
+{
+ if (exec_bfd)
+ {
+ /* 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. */
+#ifdef SOLIB_ADD
+ SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
+#else
+ solib_add (NULL, from_tty, target, auto_solib_add);
+#endif
+
+ /* Create the hooks to handle shared library load and unload
+ events. */
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
+ SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+#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);
}
/* Kill the inferior if already running. This function is designed
the value now. */
target_create_inferior (exec_file, get_inferior_args (),
environ_vector (inferior_environ), from_tty);
+
+ post_create_inferior (¤t_target, from_tty);
+
+ /* Start the target running. */
+ proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
}
struct ui_stream *stb;
struct value *value;
+ CHECK_TYPEDEF (value_type);
gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
/* FIXME: 2003-09-27: When returning from a nested inferior function
{
case RETURN_VALUE_REGISTER_CONVENTION:
case RETURN_VALUE_ABI_RETURNS_ADDRESS:
+ case RETURN_VALUE_ABI_PRESERVES_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;
{
int i;
const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
- char buffer[MAX_REGISTER_SIZE];
+ gdb_byte buffer[MAX_REGISTER_SIZE];
for (i = 0; i < numregs; i++)
{
reread_symbols ();
}
-#ifdef SOLIB_ADD
- /* Add shared library symbols from the newly attached process, if any. */
- SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
-#else
- solib_add (NULL, from_tty, ¤t_target, auto_solib_add);
-#endif
- re_enable_breakpoints_in_shlibs ();
-
/* Take any necessary post-attaching actions for this platform.
*/
target_post_attach (PIDGET (inferior_ptid));
+ post_create_inferior (¤t_target, from_tty);
+
/* Install inferior's terminal modes. */
target_terminal_inferior ();
void
_initialize_infcmd (void)
{
- struct cmd_list_element *c;
-
- c = add_com ("tty", class_run, tty_command,
- _("Set terminal for future runs of program being debugged."));
- set_cmd_completer (c, filename_completer);
+ struct cmd_list_element *c = NULL;
+
+ /* add the filename of the terminal connected to inferior I/O */
+ add_setshow_filename_cmd ("inferior-tty", class_run,
+ &inferior_io_terminal, _("\
+Set terminal for future runs of program being debugged."), _("\
+Show terminal for future runs of program being debugged."), _("\
+Usage: set inferior-tty /dev/pts/1"), NULL, NULL, &setlist, &showlist);
+ add_com_alias ("tty", "set inferior-tty", class_alias, 0);
add_setshow_optional_filename_cmd ("args", class_run,
&inferior_args, _("\