/* GNU/Linux native-dependent code common to multiple platforms.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GDB.
#define __WALL 0x40000000 /* Wait for any child. */
#endif
+#ifndef PTRACE_GETSIGINFO
+#define PTRACE_GETSIGINFO 0x4202
+#endif
+
/* The single-threaded native GNU/Linux target_ops. We save a pointer for
the use of the multi-threaded target. */
static struct target_ops *linux_ops;
static struct target_ops linux_ops_saved;
+/* The method to call, if any, when a new thread is attached. */
+static void (*linux_nat_new_thread) (ptid_t);
+
/* The saved to_xfer_partial method, inherited from inf-ptrace.c.
Called by our to_xfer_partial. */
static LONGEST (*super_xfer_partial) (struct target_ops *,
/* Detach new forked process? */
if (detach_fork)
{
- if (debug_linux_nat)
+ if (info_verbose || debug_linux_nat)
{
target_terminal_ours ();
fprintf_filtered (gdb_stdlog,
/* Before detaching from the parent, remove all breakpoints from it. */
remove_breakpoints ();
- if (debug_linux_nat)
+ if (info_verbose || debug_linux_nat)
{
target_terminal_ours ();
fprintf_filtered (gdb_stdlog,
target_detach (NULL, 0);
}
- inferior_ptid = pid_to_ptid (child_pid);
+ inferior_ptid = ptid_build (child_pid, child_pid, 0);
/* Reinstall ourselves, since we might have been removed in
target_detach (which does other necessary cleanup). */
push_target (ops);
+ linux_nat_switch_fork (inferior_ptid);
+ check_for_thread_db ();
/* Reset breakpoints in the child as appropriate. */
follow_inferior_reset_breakpoints ();
because the "zombies" stay around. */
/* List of known LWPs. */
-static struct lwp_info *lwp_list;
+struct lwp_info *lwp_list;
/* Number of LWPs in the list. */
static int num_lwps;
}
/* Add the LWP specified by PID to the list. Return a pointer to the
- structure describing the new LWP. */
+ structure describing the new LWP. The LWP should already be stopped
+ (with an exception for the very first LWP). */
static struct lwp_info *
add_lwp (ptid_t ptid)
lwp_list = lp;
++num_lwps;
+ if (num_lwps > 1 && linux_nat_new_thread != NULL)
+ linux_nat_new_thread (ptid);
+
return lp;
}
be attached. */
int
-lin_lwp_attach_lwp (ptid_t ptid, int verbose)
+lin_lwp_attach_lwp (ptid_t ptid)
{
struct lwp_info *lp;
{
pid_t pid;
int status;
+ int cloned = 0;
if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0)
{
/* If we fail to attach to the thread, issue a warning,
but continue. One way this can happen is if thread
- creation is interrupted; as of Linux 2.6.19, a kernel
+ creation is interrupted; as of Linux kernel 2.6.19, a
bug may place threads in the thread list and then fail
to create them. */
warning (_("Can't attach %s: %s"), target_pid_to_str (ptid),
return -1;
}
- if (lp == NULL)
- lp = add_lwp (ptid);
-
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LLAL: PTRACE_ATTACH %s, 0, 0 (OK)\n",
{
/* Try again with __WCLONE to check cloned processes. */
pid = my_waitpid (GET_LWP (ptid), &status, __WCLONE);
- lp->cloned = 1;
+ cloned = 1;
}
gdb_assert (pid == GET_LWP (ptid)
&& WIFSTOPPED (status) && WSTOPSIG (status));
+ if (lp == NULL)
+ lp = add_lwp (ptid);
+ lp->cloned = cloned;
+
target_post_attach (pid);
lp->stopped = 1;
lp->stopped = 1;
}
- if (verbose)
- printf_filtered (_("[New %s]\n"), target_pid_to_str (ptid));
-
return 0;
}
struct lwp_info *lp;
pid_t pid;
int status;
+ int cloned = 0;
/* FIXME: We should probably accept a list of process id's, and
attach all of them. */
linux_ops->to_attach (args, from_tty);
- /* Add the initial process as the first LWP to the list. */
- inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid));
- lp = add_lwp (inferior_ptid);
-
/* Make sure the initial process is stopped. The user-level threads
layer might want to poke around in the inferior, and that won't
work if things haven't stabilized yet. */
/* Try again with __WCLONE to check cloned processes. */
pid = my_waitpid (GET_PID (inferior_ptid), &status, __WCLONE);
- lp->cloned = 1;
+ cloned = 1;
}
gdb_assert (pid == GET_PID (inferior_ptid)
&& WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP);
+ /* Add the initial process as the first LWP to the list. */
+ inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid));
+ lp = add_lwp (inferior_ptid);
+ lp->cloned = cloned;
+
lp->stopped = 1;
/* Fake the SIGSTOP that core GDB expects. */
{
if (lp->stopped && lp->status == 0)
{
- struct thread_info *tp;
-
linux_ops->to_resume (pid_to_ptid (GET_LWP (lp->ptid)),
0, TARGET_SIGNAL_0);
if (debug_linux_nat)
target_pid_to_str (lp->ptid));
lp->stopped = 0;
lp->step = 0;
+ memset (&lp->siginfo, 0, sizeof (lp->siginfo));
}
return 0;
ptid = inferior_ptid;
lp = find_lwp_pid (ptid);
- if (lp)
- {
- ptid = pid_to_ptid (GET_LWP (lp->ptid));
+ gdb_assert (lp != NULL);
- /* Remember if we're stepping. */
- lp->step = step;
+ ptid = pid_to_ptid (GET_LWP (lp->ptid));
- /* Mark this LWP as resumed. */
- lp->resumed = 1;
+ /* Remember if we're stepping. */
+ lp->step = step;
- /* If we have a pending wait status for this thread, there is no
- point in resuming the process. But first make sure that
- linux_nat_wait won't preemptively handle the event - we
- should never take this short-circuit if we are going to
- leave LP running, since we have skipped resuming all the
- other threads. This bit of code needs to be synchronized
- with linux_nat_wait. */
+ /* Mark this LWP as resumed. */
+ lp->resumed = 1;
- if (lp->status && WIFSTOPPED (lp->status))
- {
- int saved_signo = target_signal_from_host (WSTOPSIG (lp->status));
+ /* If we have a pending wait status for this thread, there is no
+ point in resuming the process. But first make sure that
+ linux_nat_wait won't preemptively handle the event - we
+ should never take this short-circuit if we are going to
+ leave LP running, since we have skipped resuming all the
+ other threads. This bit of code needs to be synchronized
+ with linux_nat_wait. */
- if (signal_stop_state (saved_signo) == 0
- && signal_print_state (saved_signo) == 0
- && signal_pass_state (saved_signo) == 1)
- {
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLR: Not short circuiting for ignored "
- "status 0x%x\n", lp->status);
-
- /* FIXME: What should we do if we are supposed to continue
- this thread with a signal? */
- gdb_assert (signo == TARGET_SIGNAL_0);
- signo = saved_signo;
- lp->status = 0;
- }
- }
+ if (lp->status && WIFSTOPPED (lp->status))
+ {
+ int saved_signo = target_signal_from_host (WSTOPSIG (lp->status));
- if (lp->status)
+ if (signal_stop_state (saved_signo) == 0
+ && signal_print_state (saved_signo) == 0
+ && signal_pass_state (saved_signo) == 1)
{
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLR: Not short circuiting for ignored "
+ "status 0x%x\n", lp->status);
+
/* FIXME: What should we do if we are supposed to continue
this thread with a signal? */
gdb_assert (signo == TARGET_SIGNAL_0);
+ signo = saved_signo;
+ lp->status = 0;
+ }
+ }
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLR: Short circuiting for status 0x%x\n",
- lp->status);
+ if (lp->status)
+ {
+ /* FIXME: What should we do if we are supposed to continue
+ this thread with a signal? */
+ gdb_assert (signo == TARGET_SIGNAL_0);
- return;
- }
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLR: Short circuiting for status 0x%x\n",
+ lp->status);
- /* Mark LWP as not stopped to prevent it from being continued by
- resume_callback. */
- lp->stopped = 0;
+ return;
}
+ /* Mark LWP as not stopped to prevent it from being continued by
+ resume_callback. */
+ lp->stopped = 0;
+
if (resume_all)
iterate_over_lwps (resume_callback, NULL);
linux_ops->to_resume (ptid, step, signo);
+ memset (&lp->siginfo, 0, sizeof (lp->siginfo));
+
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LLR: %s %s, %s (resume event thread)\n",
return status;
}
+/* Save the most recent siginfo for LP. This is currently only called
+ for SIGTRAP; some ports use the si_addr field for
+ target_stopped_data_address. In the future, it may also be used to
+ restore the siginfo of requeued signals. */
+
+static void
+save_siginfo (struct lwp_info *lp)
+{
+ errno = 0;
+ ptrace (PTRACE_GETSIGINFO, GET_LWP (lp->ptid),
+ (PTRACE_TYPE_ARG3) 0, &lp->siginfo);
+
+ if (errno != 0)
+ memset (&lp->siginfo, 0, sizeof (lp->siginfo));
+}
+
/* Send a SIGSTOP to LP. */
static int
user will delete or disable the breakpoint, but the
thread will have already tripped on it. */
+ /* Save the trap's siginfo in case we need it later. */
+ save_siginfo (lp);
+
/* Now resume this LWP and get the SIGSTOP event. */
errno = 0;
ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
return 0;
}
+/* Check if we should go on and pass this event to common code.
+ Return the affected lwp if we are, or NULL otherwise. */
+static struct lwp_info *
+linux_nat_filter_event (int lwpid, int status, int options)
+{
+ struct lwp_info *lp;
+
+ lp = find_lwp_pid (pid_to_ptid (lwpid));
+
+ /* Check for stop events reported by a process we didn't already
+ know about - anything not already in our LWP list.
+
+ If we're expecting to receive stopped processes after
+ fork, vfork, and clone events, then we'll just add the
+ new one to our list and go back to waiting for the event
+ to be reported - the stopped process might be returned
+ from waitpid before or after the event is. */
+ if (WIFSTOPPED (status) && !lp)
+ {
+ linux_record_stopped_pid (lwpid, status);
+ return NULL;
+ }
+
+ /* Make sure we don't report an event for the exit of an LWP not in
+ our list, i.e. not part of the current process. This can happen
+ if we detach from a program we original forked and then it
+ exits. */
+ if (!WIFSTOPPED (status) && !lp)
+ return NULL;
+
+ /* NOTE drow/2003-06-17: This code seems to be meant for debugging
+ CLONE_PTRACE processes which do not use the thread library -
+ otherwise we wouldn't find the new LWP this way. That doesn't
+ currently work, and the following code is currently unreachable
+ due to the two blocks above. If it's fixed some day, this code
+ should be broken out into a function so that we can also pick up
+ LWPs from the new interface. */
+ if (!lp)
+ {
+ lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
+ if (options & __WCLONE)
+ lp->cloned = 1;
+
+ gdb_assert (WIFSTOPPED (status)
+ && WSTOPSIG (status) == SIGSTOP);
+ lp->signalled = 1;
+
+ if (!in_thread_list (inferior_ptid))
+ {
+ inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid),
+ GET_PID (inferior_ptid));
+ add_thread (inferior_ptid);
+ }
+
+ add_thread (lp->ptid);
+ }
+
+ /* Save the trap's siginfo in case we need it later. */
+ if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP)
+ save_siginfo (lp);
+
+ /* Handle GNU/Linux's extended waitstatus for trace events. */
+ if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
+ {
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLW: Handling extended status 0x%06x\n",
+ status);
+ if (linux_handle_extended_wait (lp, status, 0))
+ return NULL;
+ }
+
+ /* Check if the thread has exited. */
+ if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
+ {
+ /* If this is the main thread, we must stop all threads and
+ verify if they are still alive. This is because in the nptl
+ thread model, there is no signal issued for exiting LWPs
+ other than the main thread. We only get the main thread exit
+ signal once all child threads have already exited. If we
+ stop all the threads and use the stop_wait_callback to check
+ if they have exited we can determine whether this signal
+ should be ignored or whether it means the end of the debugged
+ application, regardless of which threading model is being
+ used. */
+ if (GET_PID (lp->ptid) == GET_LWP (lp->ptid))
+ {
+ lp->stopped = 1;
+ iterate_over_lwps (stop_and_resume_callback, NULL);
+ }
+
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLW: %s exited.\n",
+ target_pid_to_str (lp->ptid));
+
+ exit_lwp (lp);
+
+ /* If there is at least one more LWP, then the exit signal was
+ not the end of the debugged application and should be
+ ignored. */
+ if (num_lwps > 0)
+ {
+ /* Make sure there is at least one thread running. */
+ gdb_assert (iterate_over_lwps (running_callback, NULL));
+
+ /* Discard the event. */
+ return NULL;
+ }
+ }
+
+ /* Check if the current LWP has previously exited. In the nptl
+ thread model, LWPs other than the main thread do not issue
+ signals when they exit so we must check whenever the thread has
+ stopped. A similar check is made in stop_wait_callback(). */
+ if (num_lwps > 1 && !linux_nat_thread_alive (lp->ptid))
+ {
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLW: %s exited.\n",
+ target_pid_to_str (lp->ptid));
+
+ exit_lwp (lp);
+
+ /* Make sure there is at least one thread running. */
+ gdb_assert (iterate_over_lwps (running_callback, NULL));
+
+ /* Discard the event. */
+ return NULL;
+ }
+
+ /* Make sure we don't report a SIGSTOP that we sent ourselves in
+ an attempt to stop an LWP. */
+ if (lp->signalled
+ && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP)
+ {
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLW: Delayed SIGSTOP caught for %s.\n",
+ target_pid_to_str (lp->ptid));
+
+ /* This is a delayed SIGSTOP. */
+ lp->signalled = 0;
+
+ registers_changed ();
+
+ linux_ops->to_resume (pid_to_ptid (GET_LWP (lp->ptid)),
+ lp->step, TARGET_SIGNAL_0);
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
+ lp->step ?
+ "PTRACE_SINGLESTEP" : "PTRACE_CONT",
+ target_pid_to_str (lp->ptid));
+
+ lp->stopped = 0;
+ gdb_assert (lp->resumed);
+
+ /* Discard the event. */
+ return NULL;
+ }
+
+ /* An interesting event. */
+ gdb_assert (lp);
+ return lp;
+}
+
static ptid_t
linux_nat_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
(long) lwpid, status_to_str (status));
}
- lp = find_lwp_pid (pid_to_ptid (lwpid));
-
- /* Check for stop events reported by a process we didn't
- already know about - anything not already in our LWP
- list.
-
- If we're expecting to receive stopped processes after
- fork, vfork, and clone events, then we'll just add the
- new one to our list and go back to waiting for the event
- to be reported - the stopped process might be returned
- from waitpid before or after the event is. */
- if (WIFSTOPPED (status) && !lp)
- {
- linux_record_stopped_pid (lwpid, status);
- status = 0;
- continue;
- }
-
- /* Make sure we don't report an event for the exit of an LWP not in
- our list, i.e. not part of the current process. This can happen
- if we detach from a program we original forked and then it
- exits. */
- if (!WIFSTOPPED (status) && !lp)
- {
- status = 0;
- continue;
- }
-
- /* NOTE drow/2003-06-17: This code seems to be meant for debugging
- CLONE_PTRACE processes which do not use the thread library -
- otherwise we wouldn't find the new LWP this way. That doesn't
- currently work, and the following code is currently unreachable
- due to the two blocks above. If it's fixed some day, this code
- should be broken out into a function so that we can also pick up
- LWPs from the new interface. */
+ lp = linux_nat_filter_event (lwpid, status, options);
if (!lp)
{
- lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
- if (options & __WCLONE)
- lp->cloned = 1;
-
- gdb_assert (WIFSTOPPED (status)
- && WSTOPSIG (status) == SIGSTOP);
- lp->signalled = 1;
-
- if (!in_thread_list (inferior_ptid))
- {
- inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid),
- GET_PID (inferior_ptid));
- add_thread (inferior_ptid);
- }
-
- add_thread (lp->ptid);
- printf_unfiltered (_("[New %s]\n"),
- target_pid_to_str (lp->ptid));
- }
-
- /* Handle GNU/Linux's extended waitstatus for trace events. */
- if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
- {
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: Handling extended status 0x%06x\n",
- status);
- if (linux_handle_extended_wait (lp, status, 0))
- {
- status = 0;
- continue;
- }
- }
-
- /* Check if the thread has exited. */
- if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
- {
- /* If this is the main thread, we must stop all threads and
- verify if they are still alive. This is because in the nptl
- thread model, there is no signal issued for exiting LWPs
- other than the main thread. We only get the main thread
- exit signal once all child threads have already exited.
- If we stop all the threads and use the stop_wait_callback
- to check if they have exited we can determine whether this
- signal should be ignored or whether it means the end of the
- debugged application, regardless of which threading model
- is being used. */
- if (GET_PID (lp->ptid) == GET_LWP (lp->ptid))
- {
- lp->stopped = 1;
- iterate_over_lwps (stop_and_resume_callback, NULL);
- }
-
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: %s exited.\n",
- target_pid_to_str (lp->ptid));
-
- exit_lwp (lp);
-
- /* If there is at least one more LWP, then the exit signal
- was not the end of the debugged application and should be
- ignored. */
- if (num_lwps > 0)
- {
- /* Make sure there is at least one thread running. */
- gdb_assert (iterate_over_lwps (running_callback, NULL));
-
- /* Discard the event. */
- status = 0;
- continue;
- }
- }
-
- /* Check if the current LWP has previously exited. In the nptl
- thread model, LWPs other than the main thread do not issue
- signals when they exit so we must check whenever the thread
- has stopped. A similar check is made in stop_wait_callback(). */
- if (num_lwps > 1 && !linux_nat_thread_alive (lp->ptid))
- {
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: %s exited.\n",
- target_pid_to_str (lp->ptid));
-
- exit_lwp (lp);
-
- /* Make sure there is at least one thread running. */
- gdb_assert (iterate_over_lwps (running_callback, NULL));
-
- /* Discard the event. */
- status = 0;
- continue;
- }
-
- /* Make sure we don't report a SIGSTOP that we sent
- ourselves in an attempt to stop an LWP. */
- if (lp->signalled
- && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP)
- {
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: Delayed SIGSTOP caught for %s.\n",
- target_pid_to_str (lp->ptid));
-
- /* This is a delayed SIGSTOP. */
- lp->signalled = 0;
-
- registers_changed ();
- linux_ops->to_resume (pid_to_ptid (GET_LWP (lp->ptid)),
- lp->step, TARGET_SIGNAL_0);
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
- lp->step ?
- "PTRACE_SINGLESTEP" : "PTRACE_CONT",
- target_pid_to_str (lp->ptid));
-
- lp->stopped = 0;
- gdb_assert (lp->resumed);
-
- /* Discard the event. */
+ /* A discarded event. */
status = 0;
continue;
}
do
{
pid = my_waitpid (GET_LWP (lp->ptid), NULL, __WCLONE);
- if (pid != (pid_t) -1 && debug_linux_nat)
+ if (pid != (pid_t) -1)
{
- fprintf_unfiltered (gdb_stdlog,
- "KWC: wait %s received unknown.\n",
- target_pid_to_str (lp->ptid));
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "KWC: wait %s received unknown.\n",
+ target_pid_to_str (lp->ptid));
+ /* The Linux kernel sometimes fails to kill a thread
+ completely after PTRACE_KILL; that goes from the stop
+ point in do_fork out to the one in
+ get_signal_to_deliever and waits again. So kill it
+ again. */
+ kill_callback (lp, NULL);
}
}
while (pid == GET_LWP (lp->ptid));
do
{
pid = my_waitpid (GET_LWP (lp->ptid), NULL, 0);
- if (pid != (pid_t) -1 && debug_linux_nat)
+ if (pid != (pid_t) -1)
{
- fprintf_unfiltered (gdb_stdlog,
- "KWC: wait %s received unk.\n",
- target_pid_to_str (lp->ptid));
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "KWC: wait %s received unk.\n",
+ target_pid_to_str (lp->ptid));
+ /* See the call to kill_callback above. */
+ kill_callback (lp, NULL);
}
}
while (pid == GET_LWP (lp->ptid));
{
struct linux_nat_corefile_thread_data thread_args;
struct cleanup *old_chain;
+ /* The variable size must be >= sizeof (prpsinfo_t.pr_fname). */
char fname[16] = { '\0' };
+ /* The variable size must be >= sizeof (prpsinfo_t.pr_psargs). */
char psargs[80] = { '\0' };
char *note_data = NULL;
ptid_t current_ptid = inferior_ptid;
strncpy (psargs, get_exec_file (0), sizeof (psargs));
if (get_inferior_args ())
{
- strncat (psargs, " ", sizeof (psargs) - strlen (psargs));
- strncat (psargs, get_inferior_args (),
- sizeof (psargs) - strlen (psargs));
+ char *string_end;
+ char *psargs_end = psargs + sizeof (psargs);
+
+ /* linux_elfcore_write_prpsinfo () handles zero unterminated
+ strings fine. */
+ string_end = memchr (psargs, 0, sizeof (psargs));
+ if (string_end != NULL)
+ {
+ *string_end++ = ' ';
+ strncpy (string_end, get_inferior_args (),
+ psargs_end - string_end);
+ }
}
note_data = (char *) elfcore_write_prpsinfo (obfd,
note_data,
offset, len);
}
-/* Create a prototype generic Linux target. The client can override
+/* Create a prototype generic GNU/Linux target. The client can override
it with local methods. */
static void
thread_db_init (t);
}
+/* Register a method to call whenever a new thread is attached. */
+void
+linux_nat_set_new_thread (struct target_ops *t, void (*new_thread) (ptid_t))
+{
+ /* Save the pointer. We only support a single registered instance
+ of the GNU/Linux native target, so we do not need to map this to
+ T. */
+ linux_nat_new_thread = new_thread;
+}
+
+/* Return the saved siginfo associated with PTID. */
+struct siginfo *
+linux_nat_get_siginfo (ptid_t ptid)
+{
+ struct lwp_info *lp = find_lwp_pid (ptid);
+
+ gdb_assert (lp != NULL);
+
+ return &lp->siginfo;
+}
+
void
_initialize_linux_nat (void)
{