From bc28a06cc11e2be1d9bd4f4233b3fbbe5ff30654 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Wed, 27 Oct 1993 19:30:27 +0000 Subject: [PATCH] * fork-child.c (fork_inferior): Set inferior_pid before calling init_trace_fun. Move the code which gets us through the shell to new function startup_inferior. * inferior.h: Declare startup_inferior. * procfs.c (procfs_init_inferior), inftarg.c (ptrace_him): Call startup_inferior. * m3-nat.c (m3_trace_him): Call intercept_exec_calls. * config/nm-m3.h: Don't define STARTUP_INFERIOR. * config/i386/tm-i386m3.h, config/ns32k/tm-ns32k.h, config/mips/tm-mipsm3.h: Don't define START_INFERIOR_TRAPS_EXPECTED. --- gdb/ChangeLog | 11 ++++++++++ gdb/config/i386/tm-i386m3.h | 11 ---------- gdb/config/mips/tm-mipsm3.h | 8 ------- gdb/config/nm-m3.h | 4 ---- gdb/config/ns32k/tm-ns32km3.h | 11 ---------- gdb/fork-child.c | 40 +++++++++++++++++------------------ gdb/m3-nat.c | 3 +++ gdb/procfs.c | 3 +++ 8 files changed, 36 insertions(+), 55 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 07339615731..7408de36210 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ Wed Oct 27 13:43:07 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + * fork-child.c (fork_inferior): Set inferior_pid before calling + init_trace_fun. Move the code which gets us through the shell + to new function startup_inferior. + * inferior.h: Declare startup_inferior. + * procfs.c (procfs_init_inferior), inftarg.c (ptrace_him): + Call startup_inferior. + * m3-nat.c (m3_trace_him): Call intercept_exec_calls. + * config/nm-m3.h: Don't define STARTUP_INFERIOR. + * config/i386/tm-i386m3.h, config/ns32k/tm-ns32k.h, + config/mips/tm-mipsm3.h: Don't define START_INFERIOR_TRAPS_EXPECTED. + * m68k-stub.c: Change vector 13 from SIGFPE to SIGBUS. Tue Oct 26 22:05:03 1993 Jim Kingdon (kingdon@deneb.cygnus.com) diff --git a/gdb/config/i386/tm-i386m3.h b/gdb/config/i386/tm-i386m3.h index f05081cb3c4..e39acc1f4b1 100644 --- a/gdb/config/i386/tm-i386m3.h +++ b/gdb/config/i386/tm-i386m3.h @@ -40,17 +40,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* we can do it */ #define ATTACH_DETACH 1 -/* number of traps that happen between exec'ing the shell - * to run an inferior, and when we finally get to - * the inferior code. This is 2 on most implementations. - * - * On Mach 3.0 it is the number of exec() system calls before - * the task contains the debugged program. It is always 2 when - * using the shell to start up the program. - */ -#undef START_INFERIOR_TRAPS_EXPECTED -#define START_INFERIOR_TRAPS_EXPECTED 2 - /* Define this if the C compiler puts an underscore at the front of external names before giving them to the linker. */ diff --git a/gdb/config/mips/tm-mipsm3.h b/gdb/config/mips/tm-mipsm3.h index 8bad36519ff..cf41679571e 100644 --- a/gdb/config/mips/tm-mipsm3.h +++ b/gdb/config/mips/tm-mipsm3.h @@ -56,14 +56,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "mips/tm-mips.h" -/* - * On Mach 3.0 this is the number of exec() system calls before - * the task contains the debugged program. It is always 2 when - * using the shell to start up the program. - */ -#undef START_INFERIOR_TRAPS_EXPECTED -#define START_INFERIOR_TRAPS_EXPECTED 2 - /* Address of end of user stack space. * for MACH, see */ diff --git a/gdb/config/nm-m3.h b/gdb/config/nm-m3.h index 0d12424fa8a..07bf625d8a7 100644 --- a/gdb/config/nm-m3.h +++ b/gdb/config/nm-m3.h @@ -39,10 +39,6 @@ extern thread_t current_thread; */ extern int must_suspend_thread; -/* Startup the inferior task and suspend it after the correct code is loaded */ - -#define STARTUP_INFERIOR(x) intercept_exec_calls(x) - #define PREPARE_TO_PROCEED(select_it) mach3_prepare_to_proceed(select_it) /* Try to get the privileged host port for authentication to machid diff --git a/gdb/config/ns32k/tm-ns32km3.h b/gdb/config/ns32k/tm-ns32km3.h index e123759b2a2..6cf61618a2c 100644 --- a/gdb/config/ns32k/tm-ns32km3.h +++ b/gdb/config/ns32k/tm-ns32km3.h @@ -43,17 +43,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* we can do it */ #define ATTACH_DETACH 1 -/* number of traps that happen between exec'ing the shell - * to run an inferior, and when we finally get to - * the inferior code. This is 2 on most implementations. - * - * On Mach 3.0 it is the number of exec() system calls before - * the task contains the debugged program. It is always 2 when - * using the shell to start up the program. - */ -#undef START_INFERIOR_TRAPS_EXPECTED -#define START_INFERIOR_TRAPS_EXPECTED 2 - #define INVALID_FLOAT(p, s) isa_NAN(p, s) /* Address of end of stack space. diff --git a/gdb/fork-child.c b/gdb/fork-child.c index e5a16c523cc..62c7a3a1e19 100644 --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -60,8 +60,6 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun) char *shell_file; static char default_shell_file[] = SHELL_FILE; int len; - int pending_execs; - int terminal_initted; /* 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 @@ -241,28 +239,35 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun) init_thread_list(); + inferior_pid = pid; /* Needed for wait_for_inferior stuff below */ + /* Now that we have a child process, make it our target, and initialize anything target-vector-specific that needs initializing. */ (*init_trace_fun)(pid); + /* 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. */ +#ifdef SOLIB_CREATE_INFERIOR_HOOK + SOLIB_CREATE_INFERIOR_HOOK (pid); +#endif +} + +/* Accept NTRAPS traps from the inferior. */ + +void +startup_inferior (ntraps) + int ntraps; +{ + int pending_execs = ntraps; + int terminal_initted; + /* 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. */ - inferior_pid = pid; /* Needed for wait_for_inferior stuff below */ - clear_proceed_status (); - /* We will get a trace trap after one instruction. - Continue it automatically. Eventually (after shell does an exec) - it will get another trace trap. Then insert breakpoints and continue. */ - -#ifdef START_INFERIOR_TRAPS_EXPECTED - pending_execs = START_INFERIOR_TRAPS_EXPECTED; -#else - pending_execs = 2; -#endif - init_wait_for_inferior (); terminal_initted = 0; @@ -301,11 +306,4 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun) } } stop_soon_quietly = 0; - - /* 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. */ -#ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (pid); -#endif } diff --git a/gdb/m3-nat.c b/gdb/m3-nat.c index fcb7b2057ee..f0707d4a5a8 100644 --- a/gdb/m3-nat.c +++ b/gdb/m3-nat.c @@ -1143,6 +1143,9 @@ m3_trace_him (pid) setup_exception_port (); xx_debug ("Now the debugged task is created\n"); + + /* One trap to exec the shell, one to exec the program being debugged. */ + intercept_exec_calls (2); } setup_exception_port () diff --git a/gdb/procfs.c b/gdb/procfs.c index e667c82b634..1c3b6d95808 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1523,6 +1523,9 @@ procfs_init_inferior (pid) create_procinfo (pid); add_thread (pid); /* Setup initial thread */ + + /* One trap to exec the shell, one to exec the program being debugged. */ + startup_inferior (2); } /* -- 2.30.2