1999-04-16 03:35:26 +02:00
|
|
|
/* Fork a Unix child process, and set up to debug it, for GDB.
|
2004-09-30 22:15:39 +02:00
|
|
|
|
2007-01-09 18:59:20 +01:00
|
|
|
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
|
2010-01-01 08:32:07 +01:00
|
|
|
2001, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
|
|
|
Free Software Foundation, Inc.
|
2004-09-30 22:15:39 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
Contributed by Cygnus Support.
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 22:19:36 +02:00
|
|
|
(at your option) any later version.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "gdb_string.h"
|
|
|
|
#include "inferior.h"
|
2009-05-19 04:46:45 +02:00
|
|
|
#include "terminal.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
#include "target.h"
|
2000-02-09 09:52:47 +01:00
|
|
|
#include "gdb_wait.h"
|
2001-01-31 03:08:23 +01:00
|
|
|
#include "gdb_vfork.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "terminal.h"
|
|
|
|
#include "gdbthread.h"
|
1999-12-07 04:56:43 +01:00
|
|
|
#include "command.h" /* for dont_repeat () */
|
2008-03-11 00:14:06 +01:00
|
|
|
#include "gdbcmd.h"
|
* solib.h (CLEAR_SOLIB, SOLIB_ADD)
(SOLIB_CREATE_INFERIOR_HOOK, SOLIB_REMOVE_INFERIOR_HOOK)
(SOLIB_IN_DYNAMIC_LINKER, SOLIB_RESTART)
(DISABLE_UNSETTABLE_BREAK, PC_SOLIB)
(IN_SOLIB_DYNSYM_RESOLVE_CODE): Remove defines and orphaned
comments.
* breakpoint.c: Include "solib.h".
(insert_bp_location) [!DISABLE_UNSETTABLE_BREAK]: Call
solib_address.
(remove_solib_event_breakpoints, create_solib_event_breakpoint)
(disable_breakpoints_in_shlibs)
(disable_breakpoints_in_unloaded_shlib)
(re_enable_breakpoints_in_shlibs): Compile if SOLIB_ADD isn't
defined. If PC_SOLIB isn't defined, call solib_address.
(_initialize_breakpoint): Unconditionally install observer.
* corelow.c: Include "solib.h".
[SOLIB_ADD] (solib_add_stub): Remove prototype.
(core_close) [!CLEAR_SOLIB]: Call clear_solib.
(solib_add_stub) [!SOLIB_ADD] Call solib_add.
(core_open): Unconditionally call solib_add_stub.
* fork-child.c: Include "solib.h".
(fork_inferior) [!SOLIB_CREATE_INFERIOR_HOOK]: Call
solib_create_inferior_hook.
* infcmd.c: Include "solib.h".
(attach_command) [!SOLIB_ADD]: Call shlib_rescan. Unconditionally
call re_enable_breakpoints_in_shlibs.
* infrun.c: Include "solib.h".
(SOLIB_IN_SYNSYM_RESOLVE_CODE): Don't define if not already
defined.
(stop_on_solib_events, show_stop_on_solib_events): Include
unconditionally.
(follow_exec) [!SOLIB_CREATE_INFERIOR_HOOK]: Call
solib_create_inferior_hook.
(handle_inferior_event) [!SOLIB_ADD]: Call shlib_add.
[!IN_SOLIB_DYNSYM_RESOLVE_CODE]: Call in_solib_dynsym_resolve_code.
(_initialize_infrun): Unconditionally add "stop_on_solib-events"
command.
* remote.c: Include "solib.h".
(remote_open_1): Unconditionally call no_shared_libraries.
[!SOLIB_CREATE_INFERIOR_HOOK] Call solib_create_inferior_hook.
* stack.c: Include "solib.h".
(print_frame) [!PC_SOLIB] Call shlib_for_pc.
* xcoffsolib.c (no_shared_libraries): Remove function.
* Makefile.in (SFILES): Add solib.c.
(ALLDEPFILES): Remove solib.c.
(COMMON_OBS): Add solib.o.
(breakpoint.o, corelow.o, fork-chiled.o, infcmd.o, infrun.o)
(remote.o, stack.o): Update dependencies.
2005-05-12 22:21:18 +02:00
|
|
|
#include "solib.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* This just gets used as a default if we can't find SHELL. */
|
1999-04-16 03:35:26 +02:00
|
|
|
#define SHELL_FILE "/bin/sh"
|
|
|
|
|
|
|
|
extern char **environ;
|
|
|
|
|
2008-03-11 00:14:06 +01:00
|
|
|
static char *exec_wrapper;
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Break up SCRATCH into an argument vector suitable for passing to
|
|
|
|
execvp and store it in ARGV. E.g., on "run a b c d" this routine
|
|
|
|
would get as input the string "a b c d", and as output it would
|
|
|
|
fill in ARGV with the four arguments "a", "b", "c", "d". */
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
static void
|
2000-07-30 03:48:28 +02:00
|
|
|
breakup_args (char *scratch, char **argv)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
char *cp = scratch;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
/* Scan past leading separators */
|
|
|
|
while (*cp == ' ' || *cp == '\t' || *cp == '\n')
|
2004-09-30 22:15:39 +02:00
|
|
|
cp++;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Break if at end of string. */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (*cp == '\0')
|
|
|
|
break;
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Take an arg. */
|
1999-04-16 03:35:26 +02:00
|
|
|
*argv++ = cp;
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Scan for next arg separator. */
|
1999-04-16 03:35:26 +02:00
|
|
|
cp = strchr (cp, ' ');
|
|
|
|
if (cp == NULL)
|
|
|
|
cp = strchr (cp, '\t');
|
|
|
|
if (cp == NULL)
|
|
|
|
cp = strchr (cp, '\n');
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* No separators => end of string => break. */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (cp == NULL)
|
|
|
|
break;
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Replace the separator with a terminator. */
|
1999-04-16 03:35:26 +02:00
|
|
|
*cp++ = '\0';
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Null-terminate the vector. */
|
1999-04-16 03:35:26 +02:00
|
|
|
*argv = NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* When executing a command under the given shell, return non-zero if
|
|
|
|
the '!' character should be escaped when embedded in a quoted
|
2003-05-08 20:08:57 +02:00
|
|
|
command-line argument. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
escape_bang_in_quoted_argument (const char *shell_file)
|
|
|
|
{
|
|
|
|
const int shell_file_len = strlen (shell_file);
|
2004-09-30 22:15:39 +02:00
|
|
|
|
2003-05-08 20:08:57 +02:00
|
|
|
/* Bang should be escaped only in C Shells. For now, simply check
|
|
|
|
that the shell name ends with 'csh', which covers at least csh
|
|
|
|
and tcsh. This should be good enough for now. */
|
|
|
|
|
|
|
|
if (shell_file_len < 3)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (shell_file[shell_file_len - 3] == 'c'
|
|
|
|
&& shell_file[shell_file_len - 2] == 's'
|
|
|
|
&& shell_file[shell_file_len - 1] == 'h')
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Start an inferior Unix child process and sets inferior_ptid to its
|
|
|
|
pid. EXEC_FILE is the file to run. ALLARGS is a string containing
|
|
|
|
the arguments to the program. ENV is the environment vector to
|
|
|
|
pass. SHELL_FILE is the shell file, or NULL if we should pick
|
|
|
|
one. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* This function is NOT reentrant. Some of the variables have been
|
|
|
|
made static to ensure that they survive the vfork call. */
|
2001-03-23 23:48:44 +01:00
|
|
|
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
int
|
2001-03-23 23:48:44 +01:00
|
|
|
fork_inferior (char *exec_file_arg, char *allargs, char **env,
|
2000-08-23 18:37:23 +02:00
|
|
|
void (*traceme_fun) (void), void (*init_trace_fun) (int),
|
2001-03-23 23:48:44 +01:00
|
|
|
void (*pre_trace_fun) (void), char *shell_file_arg)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
char *shell_command;
|
|
|
|
static char default_shell_file[] = SHELL_FILE;
|
|
|
|
int len;
|
|
|
|
/* Set debug_fork then attach to the child while it sleeps, to debug. */
|
|
|
|
static int debug_fork = 0;
|
|
|
|
/* This is set to the result of setpgrp, which if vforked, will be visible
|
|
|
|
to you in the parent process. It's only used by humans for debugging. */
|
|
|
|
static int debug_setpgrp = 657473;
|
2001-03-23 23:48:44 +01:00
|
|
|
static char *shell_file;
|
|
|
|
static char *exec_file;
|
1999-04-16 03:35:26 +02:00
|
|
|
char **save_our_env;
|
|
|
|
int shell = 0;
|
2001-03-23 23:48:44 +01:00
|
|
|
static char **argv;
|
2005-07-06 16:54:37 +02:00
|
|
|
const char *inferior_io_terminal = get_inferior_io_terminal ();
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
struct inferior *inf;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* If no exec file handed to us, get it from the exec-file command
|
|
|
|
-- with a good, common error message if none is specified. */
|
2001-03-23 23:48:44 +01:00
|
|
|
exec_file = exec_file_arg;
|
1999-04-16 03:35:26 +02:00
|
|
|
if (exec_file == 0)
|
|
|
|
exec_file = get_exec_file (1);
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* STARTUP_WITH_SHELL is defined in inferior.h. If 0,e we'll just
|
|
|
|
do a fork/exec, no shell, so don't bother figuring out what
|
|
|
|
shell. */
|
2001-03-23 23:48:44 +01:00
|
|
|
shell_file = shell_file_arg;
|
1999-04-16 03:35:26 +02:00
|
|
|
if (STARTUP_WITH_SHELL)
|
|
|
|
{
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Figure out what shell to start up the user program under. */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (shell_file == NULL)
|
|
|
|
shell_file = getenv ("SHELL");
|
|
|
|
if (shell_file == NULL)
|
|
|
|
shell_file = default_shell_file;
|
|
|
|
shell = 1;
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Multiplying the length of exec_file by 4 is to account for the
|
|
|
|
fact that it may expand when quoted; it is a worst-case number
|
|
|
|
based on every character being '. */
|
1999-07-07 22:19:36 +02:00
|
|
|
len = 5 + 4 * strlen (exec_file) + 1 + strlen (allargs) + 1 + /*slop */ 12;
|
2008-03-11 00:14:06 +01:00
|
|
|
if (exec_wrapper)
|
|
|
|
len += strlen (exec_wrapper) + 1;
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
shell_command = (char *) alloca (len);
|
|
|
|
shell_command[0] = '\0';
|
|
|
|
|
|
|
|
if (!shell)
|
|
|
|
{
|
2004-09-30 22:15:39 +02:00
|
|
|
/* We're going to call execvp. Create argument vector.
|
|
|
|
Calculate an upper bound on the length of the vector by
|
|
|
|
assuming that every other character is a separate
|
|
|
|
argument. */
|
|
|
|
int argc = (strlen (allargs) + 1) / 2 + 2;
|
|
|
|
argv = (char **) xmalloc (argc * sizeof (*argv));
|
1999-04-16 03:35:26 +02:00
|
|
|
argv[0] = exec_file;
|
|
|
|
breakup_args (allargs, &argv[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-30 22:15:39 +02:00
|
|
|
/* We're going to call a shell. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
char *p;
|
|
|
|
int need_to_quote;
|
2003-05-08 20:08:57 +02:00
|
|
|
const int escape_bang = escape_bang_in_quoted_argument (shell_file);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
strcat (shell_command, "exec ");
|
|
|
|
|
2008-03-11 00:14:06 +01:00
|
|
|
/* Add any exec wrapper. That may be a program name with arguments, so
|
|
|
|
the user must handle quoting. */
|
|
|
|
if (exec_wrapper)
|
|
|
|
{
|
|
|
|
strcat (shell_command, exec_wrapper);
|
|
|
|
strcat (shell_command, " ");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now add exec_file, quoting as necessary. */
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Quoting in this style is said to work with all shells. But
|
|
|
|
csh on IRIX 4.0.1 can't deal with it. So we only quote it if
|
|
|
|
we need to. */
|
1999-04-16 03:35:26 +02:00
|
|
|
p = exec_file;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '\'':
|
2002-02-07 07:11:55 +01:00
|
|
|
case '!':
|
1999-04-16 03:35:26 +02:00
|
|
|
case '"':
|
|
|
|
case '(':
|
|
|
|
case ')':
|
|
|
|
case '$':
|
|
|
|
case '&':
|
|
|
|
case ';':
|
|
|
|
case '<':
|
|
|
|
case '>':
|
|
|
|
case ' ':
|
|
|
|
case '\n':
|
|
|
|
case '\t':
|
|
|
|
need_to_quote = 1;
|
|
|
|
goto end_scan;
|
|
|
|
|
|
|
|
case '\0':
|
|
|
|
need_to_quote = 0;
|
|
|
|
goto end_scan;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
end_scan:
|
|
|
|
if (need_to_quote)
|
|
|
|
{
|
|
|
|
strcat (shell_command, "'");
|
|
|
|
for (p = exec_file; *p != '\0'; ++p)
|
|
|
|
{
|
|
|
|
if (*p == '\'')
|
|
|
|
strcat (shell_command, "'\\''");
|
2003-05-08 20:08:57 +02:00
|
|
|
else if (*p == '!' && escape_bang)
|
2002-02-07 07:11:55 +01:00
|
|
|
strcat (shell_command, "\\!");
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
|
|
|
strncat (shell_command, p, 1);
|
|
|
|
}
|
|
|
|
strcat (shell_command, "'");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcat (shell_command, exec_file);
|
|
|
|
|
|
|
|
strcat (shell_command, " ");
|
|
|
|
strcat (shell_command, allargs);
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* On some systems an exec will fail if the executable is open. */
|
1999-04-16 03:35:26 +02:00
|
|
|
close_exec_file ();
|
|
|
|
|
|
|
|
/* Retain a copy of our environment variables, since the child will
|
2004-09-30 22:15:39 +02:00
|
|
|
replace the value of environ and if we're vforked, we have to
|
1999-04-16 03:35:26 +02:00
|
|
|
restore it. */
|
|
|
|
save_our_env = environ;
|
|
|
|
|
|
|
|
/* Tell the terminal handling subsystem what tty we plan to run on;
|
|
|
|
it will just record the information for later. */
|
|
|
|
new_tty_prefork (inferior_io_terminal);
|
|
|
|
|
|
|
|
/* It is generally good practice to flush any possible pending stdio
|
2004-09-30 22:15:39 +02:00
|
|
|
output prior to doing a fork, to avoid the possibility of both
|
|
|
|
the parent and child flushing the same data after the fork. */
|
1999-04-16 03:35:26 +02:00
|
|
|
gdb_flush (gdb_stdout);
|
|
|
|
gdb_flush (gdb_stderr);
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* If there's any initialization of the target layers that must
|
|
|
|
happen to prepare to handle the child we're about fork, do it
|
|
|
|
now... */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (pre_trace_fun != NULL)
|
|
|
|
(*pre_trace_fun) ();
|
|
|
|
|
2004-11-29 09:37:14 +01:00
|
|
|
/* Create the child process. Since the child process is going to
|
2006-09-07 18:22:57 +02:00
|
|
|
exec(3) shortly afterwards, try to reduce the overhead by
|
2004-11-29 09:37:14 +01:00
|
|
|
calling vfork(2). However, if PRE_TRACE_FUN is non-null, it's
|
|
|
|
likely that this optimization won't work since there's too much
|
|
|
|
work to do between the vfork(2) and the exec(3). This is known
|
|
|
|
to be the case on ttrace(2)-based HP-UX, where some handshaking
|
|
|
|
between parent and child needs to happen between fork(2) and
|
|
|
|
exec(2). However, since the parent is suspended in the vforked
|
|
|
|
state, this doesn't work. Also note that the vfork(2) call might
|
|
|
|
actually be a call to fork(2) due to the fact that autoconf will
|
|
|
|
``#define vfork fork'' on certain platforms. */
|
|
|
|
if (pre_trace_fun || debug_fork)
|
1999-04-16 03:35:26 +02:00
|
|
|
pid = fork ();
|
|
|
|
else
|
|
|
|
pid = vfork ();
|
|
|
|
|
|
|
|
if (pid < 0)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
|
|
|
perror_with_name (("vfork"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
|
|
|
if (debug_fork)
|
|
|
|
sleep (debug_fork);
|
|
|
|
|
2008-03-12 15:10:56 +01:00
|
|
|
/* Create a new session for the inferior process, if necessary.
|
|
|
|
It will also place the inferior in a separate process group. */
|
|
|
|
if (create_tty_session () <= 0)
|
|
|
|
{
|
|
|
|
/* No session was created, but we still want to run the inferior
|
|
|
|
in a separate process group. */
|
|
|
|
debug_setpgrp = gdb_setpgid ();
|
|
|
|
if (debug_setpgrp == -1)
|
|
|
|
perror ("setpgrp failed in child");
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Ask the tty subsystem to switch to the one we specified
|
|
|
|
earlier (or to share the current terminal, if none was
|
|
|
|
specified). */
|
1999-04-16 03:35:26 +02:00
|
|
|
new_tty ();
|
|
|
|
|
|
|
|
/* Changing the signal handlers for the inferior after
|
1999-07-07 22:19:36 +02:00
|
|
|
a vfork can also change them for the superior, so we don't mess
|
|
|
|
with signals here. See comments in
|
|
|
|
initialize_signals for how we get the right signal handlers
|
|
|
|
for the inferior. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* "Trace me, Dr. Memory!" */
|
|
|
|
(*traceme_fun) ();
|
2004-09-30 22:15:39 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
/* The call above set this process (the "child") as debuggable
|
2004-09-30 22:15:39 +02:00
|
|
|
by the original gdb process (the "parent"). Since processes
|
|
|
|
(unlike people) can have only one parent, if you are debugging
|
|
|
|
gdb itself (and your debugger is thus _already_ the
|
|
|
|
controller/parent for this child), code from here on out is
|
|
|
|
undebuggable. Indeed, you probably got an error message
|
|
|
|
saying "not parent". Sorry; you'll have to use print
|
|
|
|
statements! */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* There is no execlpe call, so we have to set the environment
|
1999-07-07 22:19:36 +02:00
|
|
|
for our child in the global variable. If we've vforked, this
|
|
|
|
clobbers the parent, but environ is restored a few lines down
|
|
|
|
in the parent. By the way, yes we do need to look down the
|
|
|
|
path to find $SHELL. Rich Pixley says so, and I agree. */
|
1999-04-16 03:35:26 +02:00
|
|
|
environ = env;
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* If we decided above to start up with a shell, we exec the
|
2007-06-13 21:05:00 +02:00
|
|
|
shell, "-c" says to interpret the next arg as a shell command
|
|
|
|
to execute, and this command is "exec <target-program>
|
|
|
|
<args>". */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (shell)
|
|
|
|
{
|
|
|
|
execlp (shell_file, shell_file, "-c", shell_command, (char *) 0);
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* If we get here, it's an error. */
|
1999-04-16 03:35:26 +02:00
|
|
|
fprintf_unfiltered (gdb_stderr, "Cannot exec %s: %s.\n", shell_file,
|
|
|
|
safe_strerror (errno));
|
|
|
|
gdb_flush (gdb_stderr);
|
|
|
|
_exit (0177);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Otherwise, we directly exec the target program with
|
|
|
|
execvp. */
|
1999-04-16 03:35:26 +02:00
|
|
|
int i;
|
|
|
|
char *errstring;
|
1999-06-07 21:19:32 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
execvp (exec_file, argv);
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* If we get here, it's an error. */
|
1999-04-16 03:35:26 +02:00
|
|
|
errstring = safe_strerror (errno);
|
|
|
|
fprintf_unfiltered (gdb_stderr, "Cannot exec %s ", exec_file);
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
while (argv[i] != NULL)
|
|
|
|
{
|
|
|
|
if (i != 1)
|
|
|
|
fprintf_unfiltered (gdb_stderr, " ");
|
|
|
|
fprintf_unfiltered (gdb_stderr, "%s", argv[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
fprintf_unfiltered (gdb_stderr, ".\n");
|
2004-09-30 22:15:39 +02:00
|
|
|
#if 0
|
|
|
|
/* This extra info seems to be useless. */
|
|
|
|
fprintf_unfiltered (gdb_stderr, "Got error %s.\n", errstring);
|
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
gdb_flush (gdb_stderr);
|
|
|
|
_exit (0177);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore our environment in case a vforked child clob'd it. */
|
|
|
|
environ = save_our_env;
|
|
|
|
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
if (!have_inferiors ())
|
|
|
|
init_thread_list ();
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
|
|
|
inf = current_inferior ();
|
|
|
|
|
|
|
|
inferior_appeared (inf, pid);
|
2008-09-22 17:16:51 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Needed for wait_for_inferior stuff below. */
|
|
|
|
inferior_ptid = pid_to_ptid (pid);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2009-05-19 04:46:45 +02:00
|
|
|
new_tty_postfork ();
|
|
|
|
|
2008-09-08 23:22:49 +02:00
|
|
|
/* We have something that executes now. We'll be running through
|
|
|
|
the shell at this point, but the pid shouldn't change. Targets
|
|
|
|
supporting MT should fill this task's ptid with more data as soon
|
|
|
|
as they can. */
|
|
|
|
add_thread_silent (inferior_ptid);
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
/* Now that we have a child process, make it our target, and
|
2004-09-30 22:15:39 +02:00
|
|
|
initialize anything target-vector-specific that needs
|
|
|
|
initializing. */
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
if (init_trace_fun)
|
|
|
|
(*init_trace_fun) (pid);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* We are now in the child process of interest, having exec'd the
|
|
|
|
correct program, and are poised at the first instruction of the
|
|
|
|
new program. */
|
Kill pthread_ops_hack
* target.h (struct target_ops): Make to_attach, to_detach,
to_create_inferior and to_mourn_inferior accept a pointer
to struct target_ops.
(target_attach, target_create_inferior, target_create_inferior):
Convert from macros to function. Find the right target to
invoke a method of.
(find_default_attach, find_default_create_inferior): New parameter
ops.
* corefile.c (core_file_command): Pass target to to_detach.
* corelow.c (core_detach): Add 'ops' parameter.
* fork-child.c (fork_inferior): Return the pid. Allow
init_trace_fun to be NULL.
* inf-ptrace (ptrace_ops_hack): Remove.
(inf_ptrace_him): Remove, moving all logic into....
(inf_ptrace_create_inferior): ... here. Push the target
passed as parameter.
(inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
Push/pop target passed as parameter, no ptrace_ops_hack.
(inf_ptrace_target): Don't remember result.
* inferior.h (fork_inferior): Adjust prototype.
* linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
(linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
Pass it to linux_ops target.
* linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
New parameter ops. Pass it to the target beneath.
* remote.c (remote_mourn, extended_remote_mourn, remote_detach)
(extended_remote_create_inferior): New parameter ops. Pass it
further.
* target.c (debug_to_attach, debug_to_detach)
(debug_to_mourn_inferior): New parameter ops.
(target_create_inferior): New.
(update_current_target): Do not inherit to_attach, to_detach,
to_create_inferiour, to_mourn_inferior. Do not default
to_detach and to_mourn_inferior.
(target_detach): Find the right target to use.
(target_mourn_inferior): New.
(find_default_attach, find_default_create_inferior): New parameter
ops. Pass the found target when calling its method.
(init_dummy_target): Provide fallback definition of to_detach.
(target_attach): New.
(debug_to_attach, debug_to_detach, debug_to_create_inferior)
(debug_to_mourn_inferiour): New parameter ops.
* aix-thread.c: Adjust.
* bsd-uthread.c: Adjust.
* gnu-nat.c: Adjust.
* go32-nat.c: Adjust.
* hpux-thread.c: Adjust.
* inf-ttrace.c: Ajust.
* monitor.c: Adjust.
* nto-procfs.c: Adjust.
* procfs.c: Adjust.
* remote-m32r-sdi.c: Adjust.
* remote-mips.c: Adjust.
* remote-sim.c: Adjust.
* rs6000-nat.c: Adjust.
* sol-thread.c: Adjust.
* win32-nat.c: Adjust.
* dec-thread.c: Adjust.
2008-11-09 12:27:18 +01:00
|
|
|
return pid;
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Accept NTRAPS traps from the inferior. */
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
startup_inferior (int ntraps)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
int pending_execs = ntraps;
|
2004-09-30 22:15:39 +02:00
|
|
|
int terminal_initted = 0;
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
ptid_t resume_ptid;
|
|
|
|
|
|
|
|
if (target_supports_multi_process ())
|
|
|
|
resume_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
|
|
|
|
else
|
|
|
|
resume_ptid = minus_one_ptid;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
/* The process was started by the fork that created it, but it will
|
|
|
|
have stopped one instruction after execing the shell. Here we
|
|
|
|
must get it up to actual execution of the real program. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2008-03-11 00:14:06 +01:00
|
|
|
if (exec_wrapper)
|
|
|
|
pending_execs++;
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
while (1)
|
|
|
|
{
|
2008-09-11 18:09:33 +02:00
|
|
|
int resume_signal = TARGET_SIGNAL_0;
|
2008-10-25 00:01:25 +02:00
|
|
|
ptid_t event_ptid;
|
2008-09-11 18:09:33 +02:00
|
|
|
|
|
|
|
struct target_waitstatus ws;
|
|
|
|
memset (&ws, 0, sizeof (ws));
|
2009-05-21 17:48:42 +02:00
|
|
|
event_ptid = target_wait (resume_ptid, &ws, 0);
|
2008-09-11 18:09:33 +02:00
|
|
|
|
2008-10-25 00:01:25 +02:00
|
|
|
if (ws.kind == TARGET_WAITKIND_IGNORE)
|
|
|
|
/* The inferior didn't really stop, keep waiting. */
|
|
|
|
continue;
|
2008-09-11 18:09:33 +02:00
|
|
|
|
|
|
|
switch (ws.kind)
|
|
|
|
{
|
|
|
|
case TARGET_WAITKIND_SPURIOUS:
|
|
|
|
case TARGET_WAITKIND_LOADED:
|
|
|
|
case TARGET_WAITKIND_FORKED:
|
|
|
|
case TARGET_WAITKIND_VFORKED:
|
|
|
|
case TARGET_WAITKIND_SYSCALL_ENTRY:
|
|
|
|
case TARGET_WAITKIND_SYSCALL_RETURN:
|
|
|
|
/* Ignore gracefully during startup of the inferior. */
|
2008-10-25 00:01:25 +02:00
|
|
|
switch_to_thread (event_ptid);
|
2008-09-11 18:09:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TARGET_WAITKIND_SIGNALLED:
|
|
|
|
target_terminal_ours ();
|
|
|
|
target_mourn_inferior ();
|
|
|
|
error (_("During startup program terminated with signal %s, %s."),
|
|
|
|
target_signal_to_name (ws.value.sig),
|
|
|
|
target_signal_to_string (ws.value.sig));
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TARGET_WAITKIND_EXITED:
|
|
|
|
target_terminal_ours ();
|
|
|
|
target_mourn_inferior ();
|
|
|
|
if (ws.value.integer)
|
|
|
|
error (_("During startup program exited with code %d."),
|
|
|
|
ws.value.integer);
|
|
|
|
else
|
|
|
|
error (_("During startup program exited normally."));
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TARGET_WAITKIND_EXECD:
|
|
|
|
/* Handle EXEC signals as if they were SIGTRAP signals. */
|
|
|
|
xfree (ws.value.execd_pathname);
|
|
|
|
resume_signal = TARGET_SIGNAL_TRAP;
|
2008-10-25 00:01:25 +02:00
|
|
|
switch_to_thread (event_ptid);
|
2008-09-11 18:09:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TARGET_WAITKIND_STOPPED:
|
|
|
|
resume_signal = ws.value.sig;
|
2008-10-25 00:01:25 +02:00
|
|
|
switch_to_thread (event_ptid);
|
2008-09-11 18:09:33 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-08 23:51:18 +02:00
|
|
|
|
2008-09-11 18:09:33 +02:00
|
|
|
if (resume_signal != TARGET_SIGNAL_TRAP)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2008-09-11 18:09:33 +02:00
|
|
|
/* Let shell child handle its own signals in its own way. */
|
|
|
|
target_resume (resume_ptid, 0, resume_signal);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We handle SIGTRAP, however; it means child did an exec. */
|
|
|
|
if (!terminal_initted)
|
|
|
|
{
|
2004-09-30 22:15:39 +02:00
|
|
|
/* Now that the child has exec'd we know it has already
|
|
|
|
set its process group. On POSIX systems, tcsetpgrp
|
|
|
|
will fail with EPERM if we try it before the child's
|
|
|
|
setpgid. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* Set up the "saved terminal modes" of the inferior
|
1999-07-07 22:19:36 +02:00
|
|
|
based on what modes we are starting it with. */
|
1999-04-16 03:35:26 +02:00
|
|
|
target_terminal_init ();
|
|
|
|
|
|
|
|
/* Install inferior's terminal modes. */
|
|
|
|
target_terminal_inferior ();
|
|
|
|
|
|
|
|
terminal_initted = 1;
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:15:39 +02:00
|
|
|
if (--pending_execs == 0)
|
1999-04-16 03:35:26 +02:00
|
|
|
break;
|
|
|
|
|
2008-09-11 18:09:33 +02:00
|
|
|
/* Just make it go on. */
|
|
|
|
target_resume (resume_ptid, 0, TARGET_SIGNAL_0);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
}
|
2008-10-25 00:01:25 +02:00
|
|
|
|
|
|
|
/* Mark all threads non-executing. */
|
* fork-child.c (fork_inferior): Only reset the thread list if this
is the first inferior.
(startup_inferior): If the target support multi-process, tell it
to resume only the new process.
* linux-nat.c (num_lwps): Delete global.
(purge_lwp_list): New function.
(num_lwps): New function.
(add_lwp, delete_lwp): Adjust.
(ptid_match): New.
(iterate_over_lwps): Add filter argument. Handle it.
(linux_nat_attach): Remove FIXME note.
(linux_nat_detach): Adjust to iterate over threads of the inferior
we're detaching from. Adjust to num_lwps being a function. Don't
assume the head of the lwp list is the main thread of the process
we're detaching from. Don't destroy the LWP list.
(resume_callback): Add debug output.
(linux_nat_resume): Handle resuming a single inferior. Allow a
wildcard resume in non-stop mode.
(linux_handle_extended_wait): Don't assume inferior_ptid is the
correct inferior of the parent LWP.
(status_callback): Also check lp->waitstatus.
(select_event_lwp): Add new filter parameter. Handle it.
(linux_nat_filter_event): Adjust to num_lwps being a function.
(linux_nat_wait_1): When adding the first lwp of the inferior, use
an is_lwp check instead of checking for the number of lwps.
(linux_nat_wait_1): Handle waiting for a specific tgid. Handle
pending process exit statuses.
(linux_nat_mourn_inferior): Don't destroy all the LWP info.
Instead delete LWPs of the inferior that we're mourning. Don't
unregister from the event loop here.
(linux_nat_pid_to_str): Use `num_lwps'.
(linux_nat_make_corefile_notes): Adjust to walk over lwps of a
single inferior.
(linux_nat_is_async_p): Check if async was masked out.
(linux_multi_process): New global.
(linux_nat_supports_multi_process): New.
(linux_nat_stop_lwp): Remove LWP filtering. It is done by the
caller.
(linux_nat_stop): Adjust to make iterate_over_lwps itself do the
LWP filtering.
(linux_nat_close): New.
(linux_nat_add_target): Register linux_nat_close and
linux_nat_supports_multi_process.
* linux-nat.h (iterate_over_lwps): Add filter argument.
* linux-thread-db.c (thread_db_handle): Delete.
(proc_handle, thread_agent, td_init_p, td_ta_new_p)
(td_ta_map_id2thr_p, td_ta_map_lwp2thr_p, td_ta_thr_iter_p)
(td_ta_event_addr_p, td_ta_set_event_p, td_ta_event_getmsg_p)
(td_thr_validate_p, td_thr_get_info_p, td_thr_event_enable_p)
(td_thr_tls_get_addr_p, td_create_bp_addr, td_death_bp_addr): No
longer globals, moved to...
(struct thread_db_info): ... this new structure.
(thread_db_list): New.
(add_thread_db_info, get_thread_db_info, delete_thread_db_info):
New.
(have_threads_callback): Filter out threads of all inferiors but
the one specified by the ARGS argument.
(have_threads): Add ptid argument specifying the inferior we're
interested in. Handle it.
(struct thread_get_info_inout): New.
(thread_get_info_callback, thread_from_lwp): Adjust to use it.
(thread_db_attach_lwp): Check that inferior of the passed in
thread is using thread-db. Adjust.
(enable_thread_event): Remove thread_agent parameter. Instead,
get it from the per-inferior thread-db info.
(dladdr_to_soname): Move higher up.
(enable_thread_event_reporting): Adjust to use per-inferior
thread-db info.
(try_thread_db_load_1): Replace `handle' parameter by a
thread_db_info parameter. Adjust to use per-inferior thread-db
info.
(try_thread_db_load): Adjust to use per-inferior thread-db info.
(thread_db_load, disable_thread_event_reporting): Ditto.
(check_for_thread_db): Remove conditional reporting of which
libthread_db is in use.
(thread_db_new_objfile): Add comment about inferior_ptid.
(attach_thread): Adjust to use per-inferior thread-db info.
(thread_db_detach): Adjust to use per-inferior thread-db info.
Remove thread event breakpoints of the current inferior. Only
unpush the thread-db target if there are no more processes using
it.
(check_event): Adjust to use per-inferior thread-db info.
(thread_db_wait): Adjust to use per-inferior thread-db info. Only
unpush the thread-db target if there are no more processes using
it.
(thread_db_mourn_inferior): Adjust to use per-inferior thread-db
info. Mark breakpoints of the current inferior out before
deleting them. Only unpush the thread-db target if there are no
more processes using it.
(find_new_threads_callback): Adjust to use per-inferior thread_db
info.
(thread_db_find_new_threads_1): Add new ptid argument. Adjust to
use per-inferior thread-db info.
(thread_db_find_new_threads): Adjust to use per-inferior thread-db
info.
(thread_db_get_thread_local_address): Adjust.
(thread_db_get_ada_task_ptid): Adjust.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Only unpush the target
if there no more processes left to debug.
* thread.c (set_running, set_executing): Handle resuming all
threads of a single inferior.
* mi/mi-interp.c (mi_output_running_pid): New.
(mi_inferior_count): New.
(mi_on_resume): For backwards compatibility, if resuming all
threads of an inferior, and there is only one inferior, output
"all".
2009-05-18 16:07:18 +02:00
|
|
|
set_executing (resume_ptid, 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2008-03-11 00:14:06 +01:00
|
|
|
|
|
|
|
/* Implement the "unset exec-wrapper" command. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
unset_exec_wrapper_command (char *args, int from_tty)
|
|
|
|
{
|
|
|
|
xfree (exec_wrapper);
|
|
|
|
exec_wrapper = NULL;
|
|
|
|
}
|
|
|
|
|
2008-02-21 Pedro Alves <pedro@codesorcery.com>
Silence a few -Wmissing-prototypes warnings.
PR build/9877:
* amd64-nat.c: Include "amd64-nat.h".
* fork-child.c (_initialize_fork_child): Ditto.
* gcore.c (_initialize_gcore): Ditto.
* inf-ptrace.c: Include "inf-ptrace.h".
(inf_ptrace_store_registers): Make it static.
* linux-nat.c (linux_nat_terminal_ours): Make it static.
(_initialize_linux_nat): Declare before definition.
* linux-tdep.c: Include "linux-tdep.h".
* linux-thread-db.c (_initialize_thread_db): Declare before
definition.
* proc-service.c (_initialize_proc_service): Ditto.
* remote.c (remote_send_printf): Make it static.
* solib.c: Include "solib.h".
* symfile-mem.c (_initialize_symfile_mem): Declare before
definition.
* ada-lang.c (ada_la_decode, ada_match_name)
(ada_suppress_symbol_printing, ada_is_array_type)
(ada_value_ptr_subscript, ada_array_length)
(ada_to_static_fixed_value): Make them static.
(_initialize_ada_language): Declare before definition.
* ada-tasks.c (ada_get_task_number, ada_get_environment_task)
(ada_task_list_changed, ada_new_objfile_observer): Make them
static.
(_initialize_tasks): Declare before definition.
* addrmap.c (_initialize_addrmap): Declare before definition.
* auxv.c (default_auxv_parse): Make it static.
* bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make
them static.
* breakpoint.c (remove_sal): Add line break.
(expand_line_sal_maybe): Make it static.
* cp-name-parser.y: Include "cp-support.h".
* cp-valprint.c (cp_find_class_member): Make it static.
* eval.c (value_f90_subarray): Ditto.
* exceptions.c (print_any_exception): Ditto.
* findcmd.c (_initialize_mem_search): Declare before definition.
* frame.c (frame_observer_target_changed): Make it static.
* gnu-v3-abi.c (gnuv3_find_method_in): Make it static.
* inf-child.c: Include "inf-child.h".
* inferior.h (valid_inferior_id): Rename to ...
(valid_gdb_inferior_id): ... this.
* infrun.c (infrun_thread_stop_requested, siginfo_make_value):
Make them static.
* jv-lang.c (java_language_arch_info): Make it static.
* m2-typeprint.c (m2_get_discrete_bounds): Ditto.
* osdata.c (info_osdata_command): Make it static.
* regcache.c (regcache_observer_target_changed): Make it static.
* reverse.c (_initialize_reverse): Declare before definition.
* stabsread.c (cleanup_undefined_types_noname)
(cleanup_undefined_types_1): Make them static.
* symfile.c (place_section): Make it static.
* symtab.c (find_pc_sect_psymtab_closer): Make it static.
* target-descriptions.c (_initialize_target_descriptions): Declare
before definition.
* target.c (default_get_ada_task_ptid, find_default_can_async_p)
(find_default_is_async_p, find_default_supports_non_stop): Make
them static.
(target_supports_non_stop): Add prototype.
(dummy_pid_to_str): Make it static.
* utils.c (_initialize_utils): Declare before definition.
* ada-exp.y (_initialize_ada_exp): Declare before definition.
* solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype.
* target.h (struct target_ops): Add a prototype to the
to_can_execute_reverse callback.
* macroscope.c (_initialize_macroscope): Declare before definition.
* cp-namespace.c (_initialize_cp_namespace): Declare before definition.
* python/python.c (_initialize_python): Declare before definition.
* tui/tui-command.c: Include "tui/tui-command.h".
* tui/tui-data.c (init_content_element, init_win_info): Make them
static.
* tui/tui-disasm.c: Include "tui/tui-disasm.h".
* tui/tui-interp.c (_initialize_tui_interp): Declare before
definition.
* tui/tui-layout.c: Include "tui/tui-layout.h".
(_initialize_tui_layout): Declare before definition.
* tui/tui-regs.c: Include "tui/tui-regs.h".
(tui_display_reg_element_at_line): Make it static.
(_initialize_tui_regs): Declare before definition.
* tui/tui-stack.c (_initialize_tui_stack): Declare before
definition.
* tui/tui-win.c: Include "tui/tui-win.h".
(_initialize_tui_win): Declare before definition.
(tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH.
* tui/tui-win.h (tui_sigwinch_handler): Delete declaration.
(tui_get_cmd_list): Add a prototype.
* tui/tui-windata.c: Include tui-windata.h.
* tui/tui-wingeneral.c (box_win): Make it static.
* cli/cli-logging.c (show_logging_command): Make it static.
(_initialize_cli_logging): Declare before definition.
* mi/mi-common.c (_initialize_gdb_mi_common): Declare before
definition.
2009-02-21 17:14:50 +01:00
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
|
|
extern initialize_file_ftype _initialize_fork_child;
|
|
|
|
|
2008-03-11 00:14:06 +01:00
|
|
|
void
|
|
|
|
_initialize_fork_child (void)
|
|
|
|
{
|
|
|
|
add_setshow_filename_cmd ("exec-wrapper", class_run, &exec_wrapper, _("\
|
|
|
|
Set a wrapper for running programs.\n\
|
|
|
|
The wrapper prepares the system and environment for the new program."),
|
|
|
|
_("\
|
|
|
|
Show the wrapper for running programs."), NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
&setlist, &showlist);
|
|
|
|
|
|
|
|
add_cmd ("exec-wrapper", class_run, unset_exec_wrapper_command,
|
|
|
|
_("Disable use of an execution wrapper."),
|
|
|
|
&unsetlist);
|
|
|
|
}
|