/* Low level Unix child interface to ttrace, for GDB when running under HP-UX.
- Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
- Free Software Foundation, Inc.
+
+ Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+ 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdb_string.h"
#include "gdb_wait.h"
#include "command.h"
+#include "gdbthread.h"
+#include "infttrace.h"
+
+/* We need pstat functionality so that we can get the exec file
+ for a process we attach to.
+
+ According to HP, we should use the 64bit interfaces, so we
+ define _PSTAT64 to achieve this. */
+#define _PSTAT64
+#include <sys/pstat.h>
/* Some hackery to work around a use of the #define name NO_FLAGS
* in both gdb and HPUX (bfd.h and /usr/include/machine/vmparam.h).
#undef NO_FLAGS
#endif
-#ifdef USG
-#include <sys/types.h>
-#endif
-
#include <sys/param.h>
#include <sys/dir.h>
#include <signal.h>
#endif
#include "gdbcore.h"
-#ifndef NO_SYS_FILE
+#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
static int vforking_child_pid = 0;
static int vfork_in_flight = 0;
-/* To support PREPARE_TO_PROCEED (hppa_prepare_to_proceed).
- */
-static pid_t old_gdb_pid = 0;
-static pid_t reported_pid = 0;
-static int reported_bpt = 0;
-
/* 1 if ok as results of a ttrace or ttrace_wait call, 0 otherwise.
*/
#define TT_OK( _status, _errno ) \
static thread_info_header deleted_threads =
{0, NULL, NULL};
-static saved_real_pid = 0;
+static ptid_t saved_real_ptid;
\f
/*************************************************
thread_info *p;
int thread_count_of_pid;
- new_p = malloc (sizeof (thread_info));
+ new_p = xmalloc (sizeof (thread_info));
new_p->pid = pid;
new_p->tid = tid;
new_p->have_signal = 0;
if (debug_on)
printf ("First thread, pid %d tid %d!\n", pid, tid);
#endif
- saved_real_pid = inferior_pid;
+ saved_real_ptid = inferior_ptid;
}
else
{
{
q = p;
p = p->next;
- free (q);
+ xfree (q);
}
thread_head.head = NULL;
{
q = p;
p = p->next;
- free (q);
+ xfree (q);
}
deleted_threads.head = NULL;
for (p = thread_head.head; p; p = p->next)
{
/* Is this an "unseen" thread which really happens to be a process?
- If so, is it inferior_pid and is a vfork in flight? If yes to
+ If so, is it inferior_ptid and is a vfork in flight? If yes to
all, then DON'T REMOVE IT! We're in the midst of moving a vfork
operation, which is a multiple step thing, to the point where we
can touch the parent again. We've most likely stopped to examine
* in the multi-process future. Use tid as thread,
* probably dooming this to failure. FIX!
*/
- if (saved_real_pid != 0)
+ if (! ptid_equal (saved_real_ptid, null_ptid))
{
#ifdef THREAD_DEBUG
if (debug_on)
- printf ("...using saved pid %d\n", saved_real_pid);
+ printf ("...using saved pid %d\n",
+ PIDGET (saved_real_ptid));
#endif
- real_pid = saved_real_pid;
+ real_pid = PIDGET (saved_real_ptid);
real_tid = gdb_tid;
}
if (debug_on)
{
printf ("Translated thread request to process request\n");
- if (saved_real_pid == 0)
+ if (ptid_equal (saved_real_ptid, null_ptid))
printf ("...but there's no saved pid\n");
else
{
- if (gdb_tid != saved_real_pid)
+ if (gdb_tid != PIDGET (saved_real_ptid))
printf ("...but have the wrong pid (%d rather than %d)\n",
- gdb_tid, saved_real_pid);
+ gdb_tid, PIDGET (saved_real_ptid));
}
}
#endif
have its threads examined.
*/
#define CHILD_VFORKED(evt,pid) \
- (((evt) == TTEVT_VFORK) && ((pid) != inferior_pid))
+ (((evt) == TTEVT_VFORK) && ((pid) != PIDGET (inferior_ptid)))
#define CHILD_URPED(evt,pid) \
((((evt) == TTEVT_EXEC) || ((evt) == TTEVT_EXIT)) && ((pid) != vforking_child_pid))
#define PARENT_VFORKED(evt,pid) \
- (((evt) == TTEVT_VFORK) && ((pid) == inferior_pid))
+ (((evt) == TTEVT_VFORK) && ((pid) == PIDGET (inferior_ptid)))
static int
can_touch_threads_of_process (int pid, ttevents_t stopping_event)
thread descriptor.
This caches the state. The implementation of queries like
- target_has_execd can then use this cached state, rather than
+ hpux_has_execd can then use this cached state, rather than
be forced to make an explicit ttrace call to get it.
(Guard against the condition that this is the first time we've
* Note: used by core gdb and so uses the pseudo-pid (really tid).
*/
int
-ptrace_wait (int pid, int *status)
+ptrace_wait (ptid_t ptid, int *status)
{
ttstate_t tsp;
int ttwait_return;
if (errno == ESRCH)
{
*status = 0; /* WIFEXITED */
- return inferior_pid;
+ return PIDGET (inferior_ptid);
}
warning ("Call of ttrace_wait returned with errno %d.",
errno);
*status = ttwait_return;
- return inferior_pid;
+ return PIDGET (inferior_ptid);
}
real_pid = tsp.tts_pid;
#ifdef THREAD_DEBUG
if (debug_on)
printf ("Pid %d has zero'th thread %d; inferior pid is %d\n",
- real_pid, real_tid, inferior_pid);
+ real_pid, real_tid, PIDGET (inferior_ptid));
#endif
add_tthread (real_pid, real_tid);
* a new thread if for some reason it's never
* seen the main thread before.
*/
- inferior_pid = map_to_gdb_tid (real_tid); /* HACK, FIX */
+ inferior_ptid = pid_to_ptid (map_to_gdb_tid (real_tid)); /* HACK, FIX */
*status = 0 | (tsp.tts_u.tts_exit.tts_exitcode);
}
*status = _SIGTRAP;
}
- target_post_wait (tsp.tts_pid, *status);
-
-
#ifdef THREAD_DEBUG
if (debug_on)
printf ("Done waiting, pid is %d, tid %d\n", real_pid, real_tid);
*/
return_pid = map_to_gdb_tid (real_tid);
- /* Remember this for later use in "hppa_prepare_to_proceed".
- */
- old_gdb_pid = inferior_pid;
- reported_pid = return_pid;
- reported_bpt = ((tsp.tts_event & TTEVT_SIGNAL) && (5 == tsp.tts_u.tts_signal.tts_signo));
-
if (real_tid == 0 || return_pid == 0)
{
warning ("Internal error: process-wait failed.");
child_acknowledge_created_inferior.)
*/
int
-parent_attach_all (void)
+parent_attach_all (int p1, PTRACE_ARG3_TYPE p2, int p3)
{
int tt_status;
* the process safely to ask what it is. Anyway, we'll
* add it when it gets the EXEC event.
*/
- add_thread (pid); /* in thread.c */
+ add_thread (pid_to_ptid (pid)); /* in thread.c */
/* We can now set the child's ttrace event mask.
*/
* calling require_notification_of_events.
*/
void
-child_post_startup_inferior (int real_pid)
+child_post_startup_inferior (ptid_t ptid)
{
- require_notification_of_events (real_pid);
+ require_notification_of_events (PIDGET (ptid));
}
/* From here on, we should expect tids rather than pids.
}
#endif
-#if defined(CHILD_HAS_FORKED)
-
/* Q: Do we need to map the returned process ID to a thread ID?
* A: I don't think so--here we want a _real_ pid. Any later
* start the mapping.
*/
int
-child_has_forked (int tid, int *childpid)
+hpux_has_forked (int tid, int *childpid)
{
int tt_status;
ttstate_t ttrace_state;
return 0;
}
-#endif
-
-#if defined(CHILD_HAS_VFORKED)
-
-/* See child_has_forked for pid discussion.
+/* See hpux_has_forked for pid discussion.
*/
int
-child_has_vforked (int tid, int *childpid)
+hpux_has_vforked (int tid, int *childpid)
{
int tt_status;
ttstate_t ttrace_state;
return 0;
}
-#endif
-
-
-#if defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC)
-int
-child_can_follow_vfork_prior_to_exec (void)
-{
- /* ttrace does allow this.
-
- ??rehrauer: However, I had major-league problems trying to
- convince wait_for_inferior to handle that case. Perhaps when
- it is rewritten to grok multiple processes in an explicit way...
- */
- return 0;
-}
-#endif
#if defined(CHILD_INSERT_EXEC_CATCHPOINT)
#endif
-#if defined(CHILD_HAS_EXECD)
int
-child_has_execd (int tid, char **execd_pathname)
+hpux_has_execd (int tid, char **execd_pathname)
{
int tt_status;
ttstate_t ttrace_state;
return 0;
}
-#endif
-#if defined(CHILD_HAS_SYSCALL_EVENT)
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)
{
int tt_status;
ttstate_t ttrace_state;
*syscall_id = ttrace_state.tts_scno;
return 1;
}
-#endif
\f
* May need a FIXME for that reason.
*/
int
-child_thread_alive (lwpid_t gdb_tid)
+child_thread_alive (ptid_t ptid)
{
+ lwpid_t gdb_tid = PIDGET (ptid);
lwpid_t tid;
/* This spins down the lists twice.
there's no need for any "break" statements.
*/
case PT_SETTRC:
- return parent_attach_all ();
+ return parent_attach_all (0, 0, 0);
case PT_RUREGS:
tt_status = read_from_register_save_state (gdb_tid,
thread_info **paranoia;
int para_count, i;
- if (inferior_pid == 0)
+ if (PIDGET (inferior_ptid) == 0)
return;
/* Walk the list of "threads", some of which are "pseudo threads",
- aka "processes". For each that is NOT inferior_pid, stop it,
+ aka "processes". For each that is NOT inferior_ptid, stop it,
and detach it.
You see, we may not have just a single process to kill. If we're
zaps the target vector.
*/
- paranoia = (thread_info **) malloc (thread_head.count *
- sizeof (thread_info *));
+ paranoia = (thread_info **) xmalloc (thread_head.count *
+ sizeof (thread_info *));
para_count = 0;
t = thread_head.head;
}
para_count++;
- if (t->am_pseudo && (t->pid != inferior_pid))
+ if (t->am_pseudo && (t->pid != PIDGET (inferior_ptid)))
{
- /* TT_PROC_STOP doesn't require a subsequent ttrace_wait, as it
- * generates no event.
- */
- call_ttrace (TT_PROC_STOP,
+ call_ttrace (TT_PROC_EXIT,
t->pid,
TT_NIL,
TT_NIL,
TT_NIL);
-
- call_ttrace (TT_PROC_DETACH,
- t->pid,
- TT_NIL,
- (TTRACE_ARG_TYPE) TARGET_SIGNAL_0,
- TT_NIL);
}
t = t->next;
}
- free (paranoia);
+ xfree (paranoia);
- call_ttrace (TT_PROC_STOP,
- inferior_pid,
+ call_ttrace (TT_PROC_EXIT,
+ PIDGET (inferior_ptid),
TT_NIL,
TT_NIL,
TT_NIL);
}
-#ifndef CHILD_RESUME
+#ifndef DEPRECATED_CHILD_RESUME
/* Sanity check a thread about to be continued.
*/
* state.tts_flags & TTS_STATEMASK == TTS_WASSUSPENDED
*/
if (debug_on)
- if (state.tts_flags & TTS_STATEMASK != TTS_WASSUSPENDED)
+ if ((state.tts_flags & TTS_STATEMASK) != TTS_WASSUSPENDED)
printf ("About to continue non-stopped thread %d\n", scan_tid);
#endif
#ifdef THREAD_DEBUG
if (debug_on)
- if (state.tts_flags & TTS_STATEMASK != TTS_WASSUSPENDED)
+ if ((state.tts_flags & TTS_STATEMASK) != TTS_WASSUSPENDED)
warning ("About to continue non-stopped thread %d\n", scan_tid);
#endif
}
#endif
-#ifndef CHILD_RESUME
+#ifndef DEPRECATED_CHILD_RESUME
/* Resume execution of the inferior process.
* -1 | Step current Continue all threads
* | thread and (but which gets any
* | continue others signal?--We look at
- * | "inferior_pid")
+ * | "inferior_ptid")
* |
* N | Step _this_ thread Continue _this_ thread
* | and leave others and leave others
* | user command.
*/
void
-child_resume (lwpid_t gdb_tid, int step, enum target_signal signal)
+child_resume (ptid_t ptid, int step, enum target_signal signal)
{
int resume_all_threads;
lwpid_t tid;
process_state_t new_process_state;
+ lwpid_t gdb_tid = PIDGET (ptid);
resume_all_threads =
(gdb_tid == INFTTRACE_ALL_THREADS) ||
if (vfork_in_flight)
tid = vforking_child_pid;
else
- tid = map_from_gdb_tid (inferior_pid);
+ tid = map_from_gdb_tid (PIDGET (inferior_ptid));
}
else
tid = map_from_gdb_tid (gdb_tid);
else
{
- /* TT_LWP_CONTINUE can pass signals to threads,
- * TT_PROC_CONTINUE can't. So if there are any
- * signals to pass, we have to use the (slower)
- * loop over the stopped threads.
- *
- * Equally, if we have to not continue some threads,
- * due to saved events, we have to use the loop.
- */
- if ((signal != 0) || saved_signals_exist ())
+ /* TT_LWP_CONTINUE can pass signals to threads, TT_PROC_CONTINUE can't.
+ Therefore, we really can't use TT_PROC_CONTINUE here.
+
+ Consider a process which stopped due to signal which gdb decides
+ to handle and not pass on to the inferior. In that case we must
+ clear the pending signal by restarting the inferior using
+ TT_LWP_CONTINUE and pass zero as the signal number. Else the
+ pending signal will be passed to the inferior. interrupt.exp
+ in the testsuite does this precise thing and fails due to the
+ unwanted signal delivery to the inferior. */
+ /* drow/2002-12-05: However, note that we must use TT_PROC_CONTINUE
+ if we are tracing a vfork. */
+ if (vfork_in_flight)
+ {
+ call_ttrace (TT_PROC_CONTINUE, tid, TT_NIL, TT_NIL, TT_NIL);
+ clear_all_handled ();
+ clear_all_stepping_mode ();
+ }
+ else if (resume_all_threads)
{
- if (resume_all_threads)
- {
-
-#ifdef THREAD_DEBUG
- if (debug_on)
- printf ("Doing a continue by loop of all threads\n");
-#endif
-
- threads_continue_all_with_signals (tid, signal);
-
- clear_all_handled ();
- clear_all_stepping_mode ();
- }
-
- else
- {
#ifdef THREAD_DEBUG
- printf ("Doing a continue w/signal of just thread %d\n", tid);
+ if (debug_on)
+ printf ("Doing a continue by loop of all threads\n");
#endif
- threads_continue_one_with_signal (tid, signal);
+ threads_continue_all_with_signals (tid, signal);
- /* Clear the "handled" state of this thread, because
- * we'll soon get a new event for it. Other events
- * can stay as they were.
- */
- clear_handled (tid);
- clear_stepping_mode (tid);
- }
+ clear_all_handled ();
+ clear_all_stepping_mode ();
}
-
else
{
- /* No signals to send.
- */
- if (resume_all_threads)
- {
-#ifdef THREAD_DEBUG
- if (debug_on)
- printf ("Doing a continue by process of process %d\n", tid);
-#endif
-
- if (more_events_left > 0)
- {
- warning ("Losing buffered events on continue.");
- more_events_left = 0;
- }
-
- call_ttrace (TT_PROC_CONTINUE,
- tid,
- TT_NIL,
- TT_NIL,
- TT_NIL);
-
- clear_all_handled ();
- clear_all_stepping_mode ();
- }
-
- else
- {
#ifdef THREAD_DEBUG
- if (debug_on)
- {
- printf ("Doing a continue of just thread %d\n", tid);
- if (is_terminated (tid))
- printf ("Why are we continuing a dead thread? (5)\n");
- }
+ printf ("Doing a continue w/signal of just thread %d\n", tid);
#endif
- call_ttrace (TT_LWP_CONTINUE,
- tid,
- TT_NIL,
- TT_NIL,
- TT_NIL);
+ threads_continue_one_with_signal (tid, signal);
- /* Clear the "handled" state of this thread, because
- * we'll soon get a new event for it. Other events
- * can stay as they were.
- */
- clear_handled (tid);
- clear_stepping_mode (tid);
- }
+ /* Clear the "handled" state of this thread, because we
+ will soon get a new event for it. Other events can
+ stay as they were. */
+ clear_handled (tid);
+ clear_stepping_mode (tid);
}
}
#endif
}
-#endif /* CHILD_RESUME */
+#endif /* DEPRECATED_CHILD_RESUME */
\f
-
-#ifdef ATTACH_DETACH
/*
* Like it says.
*
- * One worry is that we may not be attaching to "inferior_pid"
+ * One worry is that we may not be attaching to "inferior_ptid"
* and thus may not want to clear out our data. FIXME?
*
*/
*
* We don't need to do mapping here, as we know this
* is the first thread and thus gets the real pid
- * (and is "inferior_pid").
+ * (and is "inferior_ptid").
*
* NOTE: it probably isn't the originating thread,
* but that doesn't matter (we hope!).
if (NULL == p) /* ?We just added it! */
error ("Internal error adding a thread on attach.");
- copy_ttstate_t (&p->last_stop_state, thread_state);
+ copy_ttstate_t (&p->last_stop_state, &thread_state);
p->have_state = 1;
if (DO_ATTACH_CONTINUE == kind_of_go)
}
}
- add_thread (tid); /* in thread.c */
+ add_thread (pid_to_ptid (pid)); /* in thread.c */
}
#ifdef PARANOIA
attach_flag = 1;
}
-#endif /* ATTACH_DETACH */
\f
-#ifdef ATTACH_DETACH
/* Start debugging the process whose number is PID.
* (A _real_ pid).
*/
{
errno = 0;
call_ttrace (TT_PROC_DETACH,
- inferior_pid,
+ PIDGET (inferior_ptid),
TT_NIL,
(TTRACE_ARG_TYPE) signal,
TT_NIL);
/* Process-state? */
}
-#endif /* ATTACH_DETACH */
\f
/* Default the type of the ttrace transfer to int. */
to debugger memory starting at MYADDR. Copy to inferior if
WRITE is nonzero. TARGET is ignored.
- Returns the length copied, which is either the LEN argument or zero.
- This xfer function does not do partial moves, since child_ops
- doesn't allow memory operations to cross below us in the target stack
- anyway. */
+ Returns the length copied, which is either the LEN argument or
+ zero. This xfer function does not do partial moves, since
+ deprecated_child_ops doesn't allow memory operations to cross below
+ us in the target stack anyway. */
int
child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib,
struct target_ops *target)
{
- register int i;
+ int i;
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (TTRACE_XFER_TYPE);
+ CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (TTRACE_XFER_TYPE);
/* Round ending address up; get number of longwords that makes. */
- register int count
+ int count
= (((memaddr + len) - addr) + sizeof (TTRACE_XFER_TYPE) - 1)
/ sizeof (TTRACE_XFER_TYPE);
/* Allocate buffer of that many longwords. */
- register TTRACE_XFER_TYPE *buffer
- = (TTRACE_XFER_TYPE *) alloca (count * sizeof (TTRACE_XFER_TYPE));
+ /* FIXME (alloca): This code, cloned from infptrace.c, is unsafe
+ because it uses alloca to allocate a buffer of arbitrary size.
+ For very large xfers, this could crash GDB's stack. */
+ TTRACE_XFER_TYPE *buffer
+ = (TTRACE_XFER_TYPE *) alloca (count * sizeof (TTRACE_XFER_TYPE));
if (write)
{
{
/* Need part of initial word -- fetch it. */
buffer[0] = call_ttrace (TT_LWP_RDTEXT,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
TT_NIL,
TT_NIL);
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1] = call_ttrace (TT_LWP_RDTEXT,
- inferior_pid,
+ PIDGET (inferior_ptid),
((TTRACE_ARG_TYPE)
(addr + (count - 1) * sizeof (TTRACE_XFER_TYPE))),
TT_NIL,
{
errno = 0;
call_ttrace (TT_LWP_WRDATA,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
(TTRACE_ARG_TYPE) buffer[i],
TT_NIL);
Gould NP1, at least. */
errno = 0;
call_ttrace (TT_LWP_WRTEXT,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
(TTRACE_ARG_TYPE) buffer[i],
TT_NIL);
{
errno = 0;
buffer[i] = call_ttrace (TT_LWP_RDTEXT,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
TT_NIL,
TT_NIL);
printf_filtered ("%04x:", udot_off);
}
udot_val = call_ttrace (TT_LWP_RUREGS,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) udot_off,
TT_NIL,
TT_NIL);
}
#endif /* !defined (CHILD_XFER_MEMORY). */
+
/* TTrace version of "target_pid_to_exec_file"
*/
char *
child_pid_to_exec_file (int tid)
{
- static char exec_file_buffer[1024];
int tt_status;
- CORE_ADDR top_of_stack;
- char four_chars[4];
- int name_index;
- int i;
- int done;
- int saved_inferior_pid;
+ static char exec_file_buffer[1024];
+ pid_t pid;
+ static struct pst_status buf;
- /* As of 10.x HP-UX, there's an explicit request to get the
- *pathname.
- */
+ /* On various versions of hpux11, this may fail due to a supposed
+ kernel bug. We have alternate methods to get this information
+ (ie pstat). */
tt_status = call_ttrace (TT_PROC_GET_PATHNAME,
tid,
- (TTRACE_ARG_TYPE) exec_file_buffer,
- (TTRACE_ARG_TYPE) sizeof (exec_file_buffer) - 1,
- TT_NIL);
+ (uint64_t) exec_file_buffer,
+ sizeof (exec_file_buffer) - 1,
+ 0);
if (tt_status >= 0)
return exec_file_buffer;
- /* ??rehrauer: The above request may or may not be broken. It
- doesn't seem to work when I use it. But, it may be designed
- to only work immediately after an exec event occurs. (I'm
- waiting for COSL to explain.)
-
- In any case, if it fails, try a really, truly amazingly gross
- hack that DDE uses, of pawing through the process' data
- segment to find the pathname.
- */
- top_of_stack = (TARGET_PTR_BIT == 64 ? 0x800003ffff7f0000 : 0x7b03a000);
- name_index = 0;
- done = 0;
-
- /* On the chance that pid != inferior_pid, set inferior_pid
- to pid, so that (grrrr!) implicit uses of inferior_pid get
- the right id.
- */
- saved_inferior_pid = inferior_pid;
- inferior_pid = tid;
-
- /* Try to grab a null-terminated string. */
- while (!done)
+ /* Try to get process information via pstat and extract the filename
+ from the pst_cmd field within the pst_status structure. */
+ if (pstat_getproc (&buf, sizeof (struct pst_status), 0, tid) != -1)
{
- if (target_read_memory (top_of_stack, four_chars, 4) != 0)
- {
- inferior_pid = saved_inferior_pid;
- return NULL;
- }
- for (i = 0; i < 4; i++)
- {
- exec_file_buffer[name_index++] = four_chars[i];
- done = (four_chars[i] == '\0');
- if (done)
- break;
- }
- top_of_stack += 4;
- }
+ char *p = buf.pst_cmd;
- if (exec_file_buffer[0] == '\0')
- {
- inferior_pid = saved_inferior_pid;
- return NULL;
+ while (*p && *p != ' ')
+ p++;
+ *p = 0;
+
+ return (buf.pst_cmd);
}
- inferior_pid = saved_inferior_pid;
- return exec_file_buffer;
+ return (NULL);
}
-
void
pre_fork_inferior (void)
{
}
}
-/* Called via #define REQUIRE_ATTACH from inftarg.c,
- * ultimately from "follow_inferior_fork" in infrun.c,
- * itself called from "resume".
+/* Called from child_follow_fork in hppah-nat.c.
*
* This seems to be intended to attach after a fork or
* vfork, while "attach" is used to attach to a pid
memory_page_t *previous_page = NULL;
/* We're going to be using the dictionary now, than-kew. */
- require_memory_page_dictionary (pid);
+ require_memory_page_dictionary ();
/* Try to find an existing dictionary entry for this page. Hash
on the page's starting address.
memory_page_dictionary.page_count--;
- free (page);
+ xfree (page);
}
watchpoints.
*/
int
-hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
- enum bptype type)
+hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
{
CORE_ADDR page_start;
int dictionary_is_empty;
hardware support.
*/
int
-hppa_can_use_hw_watchpoint (enum bptype type, int cnt, enum bptype ot)
+hppa_can_use_hw_watchpoint (int type, int cnt, int ot)
{
return (type == bp_hardware_watchpoint);
}
char *
-hppa_pid_or_tid_to_str (pid_t id)
+hppa_pid_or_tid_to_str (ptid_t ptid)
{
static char buf[100]; /* Static because address returned. */
+ pid_t id = PIDGET (ptid);
/* Does this appear to be a process? If so, print it that way. */
if (is_process_id (id))
- return child_pid_to_str (id);
+ return child_pid_to_str (ptid);
/* Else, print both the GDB thread number and the system thread id. */
- sprintf (buf, "thread %d (", pid_to_thread_id (id));
- strcat (buf, hppa_tid_to_str (id));
+ sprintf (buf, "thread %d (", pid_to_thread_id (ptid));
+ strcat (buf, hppa_tid_to_str (ptid));
strcat (buf, ")\0");
return buf;
}
\f
-/* If the current pid is not the pid this module reported
- * from "ptrace_wait" with the most recent event, then the
- * user has switched threads.
- *
- * If the last reported event was a breakpoint, then return
- * the old thread id, else return 0.
- */
-pid_t
-hppa_switched_threads (pid_t gdb_pid)
-{
- if (gdb_pid == old_gdb_pid)
- {
- /*
- * Core gdb is working with the same pid that it
- * was before we reported the last event. This
- * is ok: e.g. we reported hitting a thread-specific
- * breakpoint, but we were reporting the wrong
- * thread, so the core just ignored the event.
- *
- * No thread switch has happened.
- */
- return (pid_t) 0;
- }
- else if (gdb_pid == reported_pid)
- {
- /*
- * Core gdb is working with the pid we reported, so
- * any continue or step will be able to figure out
- * that it needs to step over any hit breakpoints
- * without our (i.e. PREPARE_TO_PROCEED's) help.
- */
- return (pid_t) 0;
- }
- else if (!reported_bpt)
- {
- /*
- * The core switched, but we didn't just report a
- * breakpoint, so there's no just-hit breakpoint
- * instruction at "reported_pid"'s PC, and thus there
- * is no need to step over it.
- */
- return (pid_t) 0;
- }
- else
- {
- /* There's been a real switch, and we reported
- * a hit breakpoint. Let "hppa_prepare_to_proceed"
- * know, so it can see whether the breakpoint is
- * still active.
- */
- return reported_pid;
- }
-
- /* Keep compiler happy with an obvious return at the end.
- */
- return (pid_t) 0;
-}
-
void
hppa_ensure_vforking_parent_remains_stopped (int pid)
{
/* We do a lot of casts from pointers to TTRACE_ARG_TYPE; make sure
this is okay. */
if (sizeof (TTRACE_ARG_TYPE) < sizeof (void *))
- abort ();
+ internal_error (__FILE__, __LINE__, "failed internal consistency check");
if (errno || (memory_page_dictionary.page_size <= 0))
perror_with_name ("sysconf");