aboutsummaryrefslogtreecommitdiff
path: root/gdb/hppah-nat.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2002-11-16 19:22:59 +0000
committerDaniel Jacobowitz <drow@false.org>2002-11-16 19:22:59 +0000
commit47932f85ce27bcf18f485c2492dfafb02132dce9 (patch)
treef64276eec5b4178f035fc9e7f5d4476c18be0c61 /gdb/hppah-nat.c
parent4088142aaeb229390c53957ab465955725d43b17 (diff)
downloadgdb-47932f85ce27bcf18f485c2492dfafb02132dce9.zip
gdb-47932f85ce27bcf18f485c2492dfafb02132dce9.tar.gz
gdb-47932f85ce27bcf18f485c2492dfafb02132dce9.tar.bz2
* breakpoint.c (bpstat_stop_status): Call inferior_has_forked,
inferior_has_vforked, and inferior_has_execd instead of target_has_forked, target_has_vforked, and target_has_execd. * config/pa/nm-hppah.h (CHILD_HAS_FORKED, CHILD_HAS_VFORKED) (CHILD_HAS_EXECD, CHILD_HAS_SYSCALL_EVENT): Don't define. (CHILD_WAIT): Define. (child_wait): Add prototype. * hppah-nat.c (hpux_has_forked): Rename from child_has_forked. Add prototype. (hpux_has_vforked): Likewise, from child_has_vforked. (hpux_has_execd): Likewise, from child_has_execd. (hpux_has_syscall_event): Likewise, from child_has_syscall_event. (not_same_real_pid, child_wait): New, copied from inftarg.c. Call hpux_has_forked, hpux_has_vforked, hpux_has_execd, and hpux_has_syscall_event instead of the target hooks. * infrun.c (inferior_has_forked, inferior_has_vforked) (inferior_has_execd): New functions. * inftarg.c (not_same_real_pid): Remove. (child_wait): Remove references to not_same_real_pid, target_has_forked, target_has_vforked, target_has_execd, and target_has_syscall_event. (child_has_forked, child_has_vforked, child_has_execd) (child_has_syscall_event): Remove. (init_child_ops): Remove references to child_has_forked, child_has_vforked, child_has_execd, and child_has_syscall_event. * infttrace.c (hpux_has_forked): Rename from child_has_forked. (hpux_has_vforked): Likewise, from child_has_vforked. (hpux_has_execd): Likewise, from child_has_execd. (hpux_has_syscall_event): Likewise, from child_has_syscall_event. * target.c (cleanup_target): Remove references to to_has_forked, to_has_vforked, to_has_execd, and to_has_syscall_event. (update_current_target): Likewise. (setup_target_debug): Likewise. (debug_to_has_forked): Remove. (debug_to_has_vforked): Remove. (debug_to_has_execd): Remove. (debug_to_has_syscall_event): Remove. * target.h (struct target_ops): Remove to_has_forked. to_has_vforked, to_has_execd, and to_has_syscall_event. (child_has_forked, child_has_vforked, child_has_execd) (child_has_syscall_event): Remove prototypes. (inferior_has_forked, inferior_has_vforked, inferior_has_execd): Add prototypes. (target_has_forked, target_has_vforked, target_has_execd) (target_has_syscall_event): Remove macros.
Diffstat (limited to 'gdb/hppah-nat.c')
-rw-r--r--gdb/hppah-nat.c138
1 files changed, 134 insertions, 4 deletions
diff --git a/gdb/hppah-nat.c b/gdb/hppah-nat.c
index 5e75d87..5daa14d 100644
--- a/gdb/hppah-nat.c
+++ b/gdb/hppah-nat.c
@@ -35,6 +35,12 @@
extern CORE_ADDR text_end;
+extern int hpux_has_forked (int pid, int *childpid);
+extern int hpux_has_vforked (int pid, int *childpid);
+extern int hpux_has_execd (int pid, char **execd_pathname);
+extern int hpux_has_syscall_event (int pid, enum target_waitkind *kind,
+ int *syscall_id);
+
static void fetch_register (int);
void
@@ -469,6 +475,130 @@ hppa_tid_to_str (ptid_t ptid)
return buf;
}
+/*## */
+/* Enable HACK for ttrace work. In
+ * infttrace.c/require_notification_of_events,
+ * this is set to 0 so that the loop in child_wait
+ * won't loop.
+ */
+int not_same_real_pid = 1;
+/*## */
+
+
+/* Wait for child to do something. Return pid of child, or -1 in case
+ of error; store status through argument pointer OURSTATUS. */
+
+ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
+{
+ int save_errno;
+ int status;
+ char *execd_pathname = NULL;
+ int exit_status;
+ int related_pid;
+ int syscall_id;
+ enum target_waitkind kind;
+ int pid;
+
+ do
+ {
+ set_sigint_trap (); /* Causes SIGINT to be passed on to the
+ attached process. */
+ set_sigio_trap ();
+
+ pid = ptrace_wait (inferior_ptid, &status);
+
+ save_errno = errno;
+
+ clear_sigio_trap ();
+
+ clear_sigint_trap ();
+
+ if (pid == -1)
+ {
+ if (save_errno == EINTR)
+ continue;
+
+ fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
+ safe_strerror (save_errno));
+
+ /* Claim it exited with unknown signal. */
+ ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
+ ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
+ return pid_to_ptid (-1);
+ }
+
+ /* Did it exit?
+ */
+ if (target_has_exited (pid, status, &exit_status))
+ {
+ /* ??rehrauer: For now, ignore this. */
+ continue;
+ }
+
+ if (!target_thread_alive (pid_to_ptid (pid)))
+ {
+ ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
+ return pid_to_ptid (pid);
+ }
+
+ if (hpux_has_forked (pid, &related_pid)
+ && ((pid == PIDGET (inferior_ptid))
+ || (related_pid == PIDGET (inferior_ptid))))
+ {
+ ourstatus->kind = TARGET_WAITKIND_FORKED;
+ ourstatus->value.related_pid = related_pid;
+ return pid_to_ptid (pid);
+ }
+
+ if (hpux_has_vforked (pid, &related_pid)
+ && ((pid == PIDGET (inferior_ptid))
+ || (related_pid == PIDGET (inferior_ptid))))
+ {
+ ourstatus->kind = TARGET_WAITKIND_VFORKED;
+ ourstatus->value.related_pid = related_pid;
+ return pid_to_ptid (pid);
+ }
+
+ if (hpux_has_execd (pid, &execd_pathname))
+ {
+ /* Are we ignoring initial exec events? (This is likely because
+ we're in the process of starting up the inferior, and another
+ (older) mechanism handles those.) If so, we'll report this
+ as a regular stop, not an exec.
+ */
+ if (inferior_ignoring_startup_exec_events)
+ {
+ inferior_ignoring_startup_exec_events--;
+ }
+ else
+ {
+ ourstatus->kind = TARGET_WAITKIND_EXECD;
+ ourstatus->value.execd_pathname = execd_pathname;
+ return pid_to_ptid (pid);
+ }
+ }
+
+ /* All we must do with these is communicate their occurrence
+ to wait_for_inferior...
+ */
+ if (hpux_has_syscall_event (pid, &kind, &syscall_id))
+ {
+ ourstatus->kind = kind;
+ ourstatus->value.syscall_id = syscall_id;
+ return pid_to_ptid (pid);
+ }
+
+ /*## } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */
+/* hack for thread testing */
+ }
+ while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid);
+/*## */
+
+ store_waitstatus (ourstatus, status);
+ return pid_to_ptid (pid);
+}
+
#if !defined (GDB_NATIVE_HPUX_11)
/* The following code is a substitute for the infttrace.c versions used
@@ -890,7 +1020,7 @@ child_remove_vfork_catchpoint (int pid)
}
int
-child_has_forked (int pid, int *childpid)
+hpux_has_forked (int pid, int *childpid)
{
/* This request is only available on HPUX 10.0 and later. */
#if !defined(PT_GET_PROCESS_STATE)
@@ -921,7 +1051,7 @@ child_has_forked (int pid, int *childpid)
}
int
-child_has_vforked (int pid, int *childpid)
+hpux_has_vforked (int pid, int *childpid)
{
/* This request is only available on HPUX 10.0 and later. */
#if !defined(PT_GET_PROCESS_STATE)
@@ -983,7 +1113,7 @@ child_remove_exec_catchpoint (int pid)
}
int
-child_has_execd (int pid, char **execd_pathname)
+hpux_has_execd (int pid, char **execd_pathname)
{
/* This request is only available on HPUX 10.0 and later. */
#if !defined(PT_GET_PROCESS_STATE)
@@ -1022,7 +1152,7 @@ child_reported_exec_events_per_exec_call (void)
}
int
-child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
+hpux_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
{
/* This request is only available on HPUX 10.30 and later, via
the ttrace interface. */