X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Flinux-thread.c;h=f93387bfc7abc1a4926497eacd049828fdb41557;hb=b9891b29d8c2f8c2ad8ed59ca38612e3cd92a748;hp=2b9597db45f004c17c3fcfe83f967bde81496f62;hpb=67aaefa2dfc022e3abe43e0de7e5773b28400a38;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/linux-thread.c b/gdb/linux-thread.c index 2b9597db45..f93387bfc7 100644 --- a/gdb/linux-thread.c +++ b/gdb/linux-thread.c @@ -1,6 +1,6 @@ /* Low level interface for debugging GNU/Linux threads for GDB, the GNU debugger. - Copyright 1998, 1999 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of GDB. @@ -205,11 +205,11 @@ static CORE_ADDR linuxthreads_breakpoint_addr; #endif /* Check to see if the given thread is alive. */ static int -linuxthreads_thread_alive (pid) - int pid; +linuxthreads_thread_alive (ptid_t ptid) { errno = 0; - return ptrace (PT_READ_U, pid, (PTRACE_ARG3_TYPE)0, 0) >= 0 || errno == 0; + return ptrace (PT_READ_U, PIDGET (ptid), (PTRACE_ARG3_TYPE)0, 0) >= 0 + || errno == 0; } /* On detach(), find a SIGTRAP status. If stop is non-zero, find a @@ -230,9 +230,7 @@ linuxthreads_thread_alive (pid) our efforts to debug it, accept them with wait, but don't pass them through to PID. Do pass all other signals through. */ static int -linuxthreads_find_trap (pid, stop) - int pid; - int stop; +linuxthreads_find_trap (int pid, int stop) { int i; int rpid; @@ -311,7 +309,7 @@ linuxthreads_find_trap (pid, stop) for (;;) { /* resume the child every time... */ - child_resume (pid, 1, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (pid), 1, TARGET_SIGNAL_0); /* loop as long as errno == EINTR: waitpid syscall may be aborted due to GDB receiving a signal. @@ -376,32 +374,8 @@ linuxthreads_find_trap (pid, stop) return 1; } -/* Cleanup stub for save_inferior_pid. */ static void -restore_inferior_pid (arg) - void *arg; -{ -#if TARGET_PTR_BIT > TARGET_INT_BIT - inferior_pid = (int) ((long) arg); -#else - inferior_pid = (int) arg; -#endif -} - -/* Register a cleanup to restore the value of inferior_pid. */ -static struct cleanup * -save_inferior_pid () -{ -#if TARGET_PTR_BIT > TARGET_INT_BIT - return make_cleanup (restore_inferior_pid, (void *) ((long) inferior_pid)); -#else - return make_cleanup (restore_inferior_pid, (void *) inferior_pid); -#endif -} - -static void -sigchld_handler (signo) - int signo; +sigchld_handler (int signo) { /* This handler is used to get an EINTR while doing waitpid() when an event is received */ @@ -410,8 +384,7 @@ sigchld_handler (signo) /* Have we already collected a wait status for PID in the linuxthreads_wait bag? */ static int -linuxthreads_pending_status (pid) - int pid; +linuxthreads_pending_status (int pid) { int i; for (i = linuxthreads_wait_last; i >= 0; i--) @@ -428,9 +401,7 @@ linuxthreads_pending_status (pid) in OBJFILE, so we complain if it's required, but not there. Return true iff things are okay. */ static int -find_signal_var (sig, objfile) - struct linuxthreads_signal *sig; - struct objfile *objfile; +find_signal_var (struct linuxthreads_signal *sig, struct objfile *objfile) { struct minimal_symbol *ms = lookup_minimal_symbol (sig->var, NULL, objfile); @@ -456,8 +427,7 @@ find_signal_var (sig, objfile) } static int -find_all_signal_vars (objfile) - struct objfile *objfile; +find_all_signal_vars (struct objfile *objfile) { return ( find_signal_var (&linuxthreads_sig_restart, objfile) && find_signal_var (&linuxthreads_sig_cancel, objfile) @@ -471,8 +441,7 @@ static int complained_cannot_determine_thread_signal_number = 0; been initialized yet. If it has, tell GDB to pass that signal through to the inferior silently. */ static void -check_signal_number (sig) - struct linuxthreads_signal *sig; +check_signal_number (struct linuxthreads_signal *sig) { int num; @@ -508,7 +477,7 @@ check_signal_number (sig) } void -check_all_signal_numbers () +check_all_signal_numbers (void) { /* If this isn't a LinuxThreads program, quit early. */ if (! linuxthreads_max) @@ -541,8 +510,7 @@ check_all_signal_numbers () talking to an executable that uses LinuxThreads, so we clear the signal number and variable address too. */ static void -restore_signal (sig) - struct linuxthreads_signal *sig; +restore_signal (struct linuxthreads_signal *sig) { if (! sig->signal) return; @@ -562,7 +530,7 @@ restore_signal (sig) talking to an executable that uses LinuxThreads, so we clear the signal number and variable address too. */ static void -restore_all_signals () +restore_all_signals (void) { restore_signal (&linuxthreads_sig_restart); restore_signal (&linuxthreads_sig_cancel); @@ -581,9 +549,7 @@ restore_all_signals () If ALL is non-zero, process all threads. If ALL is zero, skip threads with pending status. */ static void -iterate_active_threads (func, all) - void (*func)(int); - int all; +iterate_active_threads (void (*func) (int), int all) { CORE_ADDR descr; int pid; @@ -613,8 +579,7 @@ iterate_active_threads (func, all) This is the worker function for linuxthreads_insert_breakpoint, which passes it to iterate_active_threads. */ static void -insert_breakpoint (pid) - int pid; +insert_breakpoint (int pid) { int j; @@ -640,8 +605,7 @@ insert_breakpoint (pid) breakpoint if the thread's PC is pointing at the breakpoint being removed. */ static void -remove_breakpoint (pid) - int pid; +remove_breakpoint (int pid) { int j; @@ -650,9 +614,10 @@ remove_breakpoint (pid) if (linuxthreads_breakpoint_zombie[j].pid == pid) break; - if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + if (in_thread_list (pid_to_ptid (pid)) + && linuxthreads_thread_alive (pid_to_ptid (pid))) { - CORE_ADDR pc = read_pc_pid (pid); + CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid)); if (linuxthreads_breakpoint_addr == pc - DECR_PC_AFTER_BREAK && j > linuxthreads_breakpoint_last) { @@ -666,10 +631,9 @@ remove_breakpoint (pid) /* Kill a thread */ static void -kill_thread (pid) - int pid; +kill_thread (int pid) { - if (in_thread_list (pid)) + if (in_thread_list (pid_to_ptid (pid))) { ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0); } @@ -681,44 +645,43 @@ kill_thread (pid) /* Resume a thread */ static void -resume_thread (pid) - int pid; +resume_thread (int pid) { - if (pid != inferior_pid - && in_thread_list (pid) - && linuxthreads_thread_alive (pid)) + if (pid != PIDGET (inferior_ptid) + && in_thread_list (pid_to_ptid (pid)) + && linuxthreads_thread_alive (pid_to_ptid (pid))) { if (pid == linuxthreads_step_pid) { - child_resume (pid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (pid), 1, linuxthreads_step_signo); } else { - child_resume (pid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (pid), 0, TARGET_SIGNAL_0); } } } /* Detach a thread */ static void -detach_thread (pid) - int pid; +detach_thread (int pid) { - if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + ptid_t ptid = pid_to_ptid (pid); + + if (in_thread_list (ptid) && linuxthreads_thread_alive (ptid)) { /* Remove pending SIGTRAP and SIGSTOP */ linuxthreads_find_trap (pid, 1); - inferior_pid = pid; + inferior_ptid = ptid; detach (TARGET_SIGNAL_0); - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); } } /* Attach a thread */ void -attach_thread (pid) - int pid; +attach_thread (int pid) { if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) != 0) perror_with_name ("attach_thread"); @@ -726,20 +689,20 @@ attach_thread (pid) /* Stop a thread */ static void -stop_thread (pid) - int pid; +stop_thread (int pid) { - if (pid != inferior_pid) + if (pid != PIDGET (inferior_ptid)) { - if (in_thread_list (pid)) + if (in_thread_list (pid_to_ptid (pid))) { kill (pid, SIGSTOP); } else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0) { if (!linuxthreads_attach_pending) - printf_filtered ("[New %s]\n", target_pid_to_str (pid)); - add_thread (pid); + printf_filtered ("[New %s]\n", + target_pid_to_str (pid_to_ptid (pid))); + add_thread (pid_to_ptid (pid)); if (linuxthreads_sig_debug.signal) { /* After a new thread in glibc 2.1 signals gdb its existence, @@ -755,13 +718,12 @@ stop_thread (pid) /* Wait for a thread */ static void -wait_thread (pid) - int pid; +wait_thread (int pid) { int status; int rpid; - if (pid != inferior_pid && in_thread_list (pid)) + if (pid != PIDGET (inferior_ptid) && in_thread_list (pid_to_ptid (pid))) { /* loop as long as errno == EINTR: waitpid syscall may be aborted if GDB receives a signal. @@ -801,7 +763,7 @@ wait_thread (pid) { break; } - if (errno != EINTR && linuxthreads_thread_alive (pid)) + if (errno != EINTR && linuxthreads_thread_alive (pid_to_ptid (pid))) perror_with_name ("wait_thread/waitpid"); /* the thread is dead. */ @@ -818,8 +780,7 @@ wait_thread (pid) /* Walk through the linuxthreads handles in order to detect all threads and stop them */ static void -update_stop_threads (test_pid) - int test_pid; +update_stop_threads (int test_pid) { struct cleanup *old_chain = NULL; @@ -829,20 +790,20 @@ update_stop_threads (test_pid) { if (linuxthreads_manager) { - if (test_pid > 0 && test_pid != inferior_pid) + if (test_pid > 0 && test_pid != PIDGET (inferior_ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } read_memory (linuxthreads_manager, (char *)&linuxthreads_manager_pid, sizeof (pid_t)); } if (linuxthreads_initial) { - if (test_pid > 0 && test_pid != inferior_pid) + if (test_pid > 0 && test_pid != PIDGET (inferior_ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } read_memory(linuxthreads_initial, (char *)&linuxthreads_initial_pid, sizeof (pid_t)); @@ -852,13 +813,14 @@ update_stop_threads (test_pid) if (linuxthreads_manager_pid != 0) { if (old_chain == NULL && test_pid > 0 && - test_pid != inferior_pid && linuxthreads_thread_alive (test_pid)) + test_pid != PIDGET (inferior_ptid) + && linuxthreads_thread_alive (pid_to_ptid (test_pid))) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } - if (linuxthreads_thread_alive (inferior_pid)) + if (linuxthreads_thread_alive (inferior_ptid)) { if (test_pid > 0) { @@ -868,14 +830,14 @@ update_stop_threads (test_pid) stop_thread (linuxthreads_manager_pid); wait_thread (linuxthreads_manager_pid); } - if (!in_thread_list (test_pid)) + if (!in_thread_list (pid_to_ptid (test_pid))) { if (!linuxthreads_attach_pending) printf_filtered ("[New %s]\n", - target_pid_to_str (test_pid)); - add_thread (test_pid); + target_pid_to_str (pid_to_ptid (test_pid))); + add_thread (pid_to_ptid (test_pid)); if (linuxthreads_sig_debug.signal - && inferior_pid == test_pid) + && PIDGET (inferior_ptid) == test_pid) { /* After a new thread in glibc 2.1 signals gdb its existence, it suspends itself and wait for @@ -905,11 +867,10 @@ update_stop_threads (test_pid) */ /* Saved pointer to previous owner of the new_objfile event. */ -static void (*target_new_objfile_chain) PARAMS ((struct objfile *)); +static void (*target_new_objfile_chain) (struct objfile *); void -linuxthreads_new_objfile (objfile) - struct objfile *objfile; +linuxthreads_new_objfile (struct objfile *objfile) { struct minimal_symbol *ms; @@ -1058,7 +1019,7 @@ any thread other than the main thread."); linuxthreads_breakpoint_zombie = (struct linuxthreads_breakpoint *) xmalloc (sizeof (struct linuxthreads_breakpoint) * (linuxthreads_max + 1)); - if (inferior_pid && + if (PIDGET (inferior_ptid) != 0 && !linuxthreads_attach_pending && !using_thread_db) /* suppressed by thread_db module */ { @@ -1066,7 +1027,7 @@ any thread other than the main thread."); target_write_memory (linuxthreads_debug, (char *)&on, sizeof (on)); linuxthreads_attach_pending = 1; - update_stop_threads (inferior_pid); + update_stop_threads (PIDGET (inferior_ptid)); linuxthreads_attach_pending = 0; } @@ -1076,22 +1037,28 @@ quit: } /* If we have switched threads from a one that stopped at breakpoint, - return 1 otherwise 0. */ + return 1 otherwise 0. + + Note that this implementation is potentially redundant now that + default_prepare_to_proceed() has been added. + + FIXME This may not support switching threads after Ctrl-C + correctly. The default implementation does support this. */ int -linuxthreads_prepare_to_proceed (step) - int step; +linuxthreads_prepare_to_proceed (int step) { if (!linuxthreads_max || !linuxthreads_manager_pid || !linuxthreads_breakpoint_pid - || !breakpoint_here_p (read_pc_pid (linuxthreads_breakpoint_pid))) + || !breakpoint_here_p ( + read_pc_pid (pid_to_ptid (linuxthreads_breakpoint_pid)))) return 0; if (step) { /* Mark the current inferior as single stepping process. */ - linuxthreads_step_pid = inferior_pid; + linuxthreads_step_pid = PIDGET (inferior_ptid); } linuxthreads_inferior_pid = linuxthreads_breakpoint_pid; @@ -1101,10 +1068,10 @@ linuxthreads_prepare_to_proceed (step) /* Convert a pid to printable form. */ char * -linuxthreads_pid_to_str (pid) - int pid; +linuxthreads_pid_to_str (ptid_t ptid) { static char buf[100]; + int pid = PIDGET (ptid); sprintf (buf, "%s %d%s", linuxthreads_max ? "Thread" : "Pid", pid, (pid == linuxthreads_manager_pid) ? " (manager thread)" @@ -1118,9 +1085,7 @@ linuxthreads_pid_to_str (pid) and wait for the trace-trap that results from attaching. */ static void -linuxthreads_attach (args, from_tty) - char *args; - int from_tty; +linuxthreads_attach (char *args, int from_tty) { if (!args) error_no_arg ("process-id to attach"); @@ -1146,9 +1111,7 @@ linuxthreads_attach (args, from_tty) started via the normal ptrace (PTRACE_TRACEME). */ static void -linuxthreads_detach (args, from_tty) - char *args; - int from_tty; +linuxthreads_detach (char *args, int from_tty) { if (linuxthreads_max) { @@ -1167,26 +1130,28 @@ linuxthreads_detach (args, from_tty) continue; pid = linuxthreads_breakpoint_zombie[i].pid; - if (!linuxthreads_thread_alive (pid)) + if (!linuxthreads_thread_alive (pid_to_ptid (pid))) continue; - if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (pid)) + if (linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (pid))) continue; /* Continue in STEP mode until the thread pc has moved or until SIGTRAP is found on the same PC. */ if (linuxthreads_find_trap (pid, 0) - && linuxthreads_breakpoint_zombie[i].pc == read_pc_pid (pid)) + && linuxthreads_breakpoint_zombie[i].pc + == read_pc_pid (pid_to_ptid (pid))) write_pc_pid (linuxthreads_breakpoint_zombie[i].pc - - DECR_PC_AFTER_BREAK, pid); + - DECR_PC_AFTER_BREAK, pid_to_ptid (pid)); } /* Detach thread after thread. */ - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); iterate_active_threads (detach_thread, 1); /* Remove pending SIGTRAP and SIGSTOP */ - linuxthreads_find_trap (inferior_pid, 1); + linuxthreads_find_trap (PIDGET (inferior_ptid), 1); linuxthreads_wait_last = -1; WSETSTOP (linuxthreads_exit_status, 0); @@ -1212,14 +1177,11 @@ linuxthreads_detach (args, from_tty) signal activated. */ static void -linuxthreads_resume (pid, step, signo) - int pid; - int step; - enum target_signal signo; +linuxthreads_resume (ptid_t ptid, int step, enum target_signal signo) { if (!linuxthreads_max || stop_soon_quietly || linuxthreads_manager_pid == 0) { - child_ops.to_resume (pid, step, signo); + child_ops.to_resume (ptid, step, signo); } else { @@ -1236,28 +1198,28 @@ linuxthreads_resume (pid, step, signo) struct cleanup *old_chain = NULL; int i; - if (pid < 0) + if (PIDGET (ptid) < 0) { - linuxthreads_step_pid = step ? inferior_pid : 0; + linuxthreads_step_pid = step ? PIDGET (inferior_ptid) : 0; linuxthreads_step_signo = signo; - rpid = inferior_pid; + rpid = PIDGET (inferior_ptid); } else - rpid = pid; + rpid = PIDGET (ptid); - if (pid < 0 || !step) + if (PIDGET (ptid) < 0 || !step) { linuxthreads_breakpoints_inserted = 1; /* Walk through linuxthreads array in order to resume threads */ - if (pid >= 0 && inferior_pid != pid) + if (PIDGET (ptid) >= 0 && !ptid_equal (inferior_ptid, ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = pid; + old_chain = save_inferior_ptid (); + inferior_ptid = ptid; } iterate_active_threads (resume_thread, 0); - if (linuxthreads_manager_pid != inferior_pid + if (linuxthreads_manager_pid != PIDGET (inferior_ptid) && !linuxthreads_pending_status (linuxthreads_manager_pid)) resume_thread (linuxthreads_manager_pid); } @@ -1268,7 +1230,8 @@ linuxthreads_resume (pid, step, signo) for (i = 0; i <= linuxthreads_breakpoint_last; i++) if (linuxthreads_breakpoint_zombie[i].pid == rpid) { - if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + if (linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (rpid))) { /* The current pc is out of zombie breakpoint. */ REMOVE_BREAKPOINT_ZOMBIE(i); @@ -1284,17 +1247,14 @@ linuxthreads_resume (pid, step, signo) /* [unles it has a wait event pending] */ if (!linuxthreads_pending_status (rpid)) { - child_ops.to_resume (rpid, step, signo); + child_ops.to_resume (pid_to_ptid (rpid), step, signo); } } } /* Abstract out the child_wait functionality. */ int -linux_child_wait (pid, rpid, status) - int pid; - int *rpid; - int *status; +linux_child_wait (int pid, int *rpid, int *status) { int save_errno; @@ -1347,16 +1307,15 @@ linux_child_wait (pid, rpid, status) /* Wait for any threads to stop. We may have to convert PID from a thread id to a LWP id, and vice versa on the way out. */ -static int -linuxthreads_wait (pid, ourstatus) - int pid; - struct target_waitstatus *ourstatus; +static ptid_t +linuxthreads_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { int status; int rpid; int i; int last; int *wstatus; + int pid = PIDGET (ptid); if (linuxthreads_max && !linuxthreads_breakpoints_inserted) wstatus = alloca (LINUXTHREAD_NSIG * sizeof (int)); @@ -1376,7 +1335,7 @@ linuxthreads_wait (pid, ourstatus) if (linuxthreads_inferior_pid) pid = linuxthreads_inferior_pid; else if (pid < 0) - pid = inferior_pid; + pid = PIDGET (inferior_ptid); last = rpid = 0; } else if (pid < 0 && linuxthreads_wait_last >= 0) @@ -1419,7 +1378,7 @@ linuxthreads_wait (pid, ourstatus) if (WIFEXITED(linuxthreads_exit_status)) { store_waitstatus (ourstatus, linuxthreads_exit_status); - return inferior_pid; + return inferior_ptid; } else { @@ -1429,7 +1388,7 @@ linuxthreads_wait (pid, ourstatus) /* Claim it exited with unknown signal. */ ourstatus->kind = TARGET_WAITKIND_SIGNALLED; ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; - return -1; + return pid_to_ptid (-1); } } @@ -1456,7 +1415,8 @@ linuxthreads_wait (pid, ourstatus) linuxthreads_breakpoint_zombie[i].pid = rpid; linuxthreads_breakpoint_last++; } - linuxthreads_breakpoint_zombie[i].pc = read_pc_pid (rpid); + linuxthreads_breakpoint_zombie[i].pc + = read_pc_pid (pid_to_ptid (rpid)); linuxthreads_breakpoint_zombie[i].step = 1; } else @@ -1471,7 +1431,7 @@ linuxthreads_wait (pid, ourstatus) wstatus[last++] = status; } } - child_resume (rpid, 1, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 1, TARGET_SIGNAL_0); continue; } if (linuxthreads_inferior_pid) @@ -1489,11 +1449,12 @@ linuxthreads_wait (pid, ourstatus) { if (linuxthreads_step_pid == rpid) { - child_resume (rpid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (rpid), 1, + linuxthreads_step_signo); } else { - child_resume (rpid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0); } } continue; @@ -1526,7 +1487,8 @@ linuxthreads_wait (pid, ourstatus) { /* There is a potential zombie breakpoint */ if (WIFEXITED(status) - || linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + || linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (rpid))) { /* The current pc is out of zombie breakpoint. */ REMOVE_BREAKPOINT_ZOMBIE(i); @@ -1536,14 +1498,14 @@ linuxthreads_wait (pid, ourstatus) { /* This is a real one ==> decrement PC and restart. */ write_pc_pid (linuxthreads_breakpoint_zombie[i].pc - - DECR_PC_AFTER_BREAK, rpid); + - DECR_PC_AFTER_BREAK, pid_to_ptid (rpid)); if (linuxthreads_step_pid == rpid) { - child_resume (rpid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (rpid), 1, linuxthreads_step_signo); } else { - child_resume (rpid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0); } continue; } @@ -1554,7 +1516,7 @@ linuxthreads_wait (pid, ourstatus) update_stop_threads (rpid); } - else if (rpid != inferior_pid) + else if (rpid != PIDGET (inferior_ptid)) continue; store_waitstatus (ourstatus, status); @@ -1578,17 +1540,14 @@ linuxthreads_wait (pid, ourstatus) else if (linuxthreads_breakpoint_pid) linuxthreads_breakpoint_pid = 0; - return rpid; + return pid_to_ptid (rpid); } } /* Fork an inferior process, and start debugging it with ptrace. */ static void -linuxthreads_create_inferior (exec_file, allargs, env) - char *exec_file; - char *allargs; - char **env; +linuxthreads_create_inferior (char *exec_file, char *allargs, char **env) { if (!exec_file && !exec_bfd) { @@ -1610,7 +1569,7 @@ Use the \"file\" or \"exec-file\" command."); } void -linuxthreads_discard_global_state () +linuxthreads_discard_global_state (void) { linuxthreads_inferior_pid = 0; linuxthreads_breakpoint_pid = 0; @@ -1625,7 +1584,7 @@ linuxthreads_discard_global_state () /* Clean up after the inferior dies. */ static void -linuxthreads_mourn_inferior () +linuxthreads_mourn_inferior (void) { if (linuxthreads_max) { @@ -1644,22 +1603,22 @@ linuxthreads_mourn_inferior () /* Kill the inferior process */ static void -linuxthreads_kill () +linuxthreads_kill (void) { int rpid; int status; - if (inferior_pid == 0) + if (PIDGET (inferior_ptid) == 0) return; if (linuxthreads_max && linuxthreads_manager_pid != 0) { /* Remove all threads status. */ - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); iterate_active_threads (kill_thread, 1); } - kill_thread (inferior_pid); + kill_thread (PIDGET (inferior_ptid)); #if 0 /* doing_quit_force solves a real problem, but I think a properly @@ -1678,9 +1637,9 @@ linuxthreads_kill () kill_thread (rpid); } else - while ((rpid = waitpid (inferior_pid, &status, 0)) > 0) + while ((rpid = waitpid (PIDGET (inferior_ptid), &status, 0)) > 0) if (!WIFEXITED(status)) - ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0); + ptrace (PT_KILL, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 0, 0); } #endif @@ -1705,9 +1664,7 @@ linuxthreads_kill () /* Insert a breakpoint */ static int -linuxthreads_insert_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; +linuxthreads_insert_breakpoint (CORE_ADDR addr, char *contents_cache) { if (linuxthreads_max && linuxthreads_manager_pid != 0) { @@ -1722,9 +1679,7 @@ linuxthreads_insert_breakpoint (addr, contents_cache) /* Remove a breakpoint */ static int -linuxthreads_remove_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; +linuxthreads_remove_breakpoint (CORE_ADDR addr, char *contents_cache) { if (linuxthreads_max && linuxthreads_manager_pid != 0) { @@ -1739,14 +1694,14 @@ linuxthreads_remove_breakpoint (addr, contents_cache) /* Mark our target-struct as eligible for stray "run" and "attach" commands. */ static int -linuxthreads_can_run () +linuxthreads_can_run (void) { return child_suppress_run; } static void -init_linuxthreads_ops () +init_linuxthreads_ops (void) { linuxthreads_ops.to_shortname = "linuxthreads"; linuxthreads_ops.to_longname = "LINUX threads and pthread."; @@ -1768,7 +1723,7 @@ init_linuxthreads_ops () } void -_initialize_linuxthreads () +_initialize_linuxthreads (void) { struct sigaction sact; sigset_t linuxthreads_wait_mask; /* sigset with SIGCHLD */