From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26157 invoked by alias); 17 Mar 2009 19:31:52 -0000 Received: (qmail 26138 invoked by uid 22791); 17 Mar 2009 19:31:46 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_35,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Mar 2009 19:31:36 +0000 Received: (qmail 25275 invoked from network); 17 Mar 2009 19:31:29 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 17 Mar 2009 19:31:29 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [gdbserver/RFA] pave way for multi-process, s/process/lwp/g Date: Tue, 17 Mar 2009 19:41:00 -0000 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903171931.31390.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00325.txt.bz2 Hi, One of the things I stumbled upon when adding multi-process support to gdbserver, was, what to name the type representing "process" objects. "inferior" is taken as generic object from the inferior (threads, dlls, etc.). `struct process_info' sounds like an obvious choice, after `struct thread_info', but, it is already taken by linux-low.c, to represent each "LWP" from a single process or thread group. I think it would make gdbserver's code more readable, if we renamed `struct process_info' to `struct lwp_info', and then, we added a new, but different, `struct process_info' later when we add multi-process support. That's the path I have taken on the multi-process branch. There we have: struct process_info A process / thread group. struct lwp_info An "LWP" that belongs to a thread group. This is the equivalent of gdb/linux-nat.c's `struct lwp_info'. struct thread_info gdbserver common code's thread object. The patch below implements that renaming. I'd like to get this upfront, so as to minimize merge pain, and, well, follow up patches would apply on top of this. As a bonus, "lwp" is shorter than "process". As an argument, linux_attach_lwp was already there. :-) What do you think? OK? -- Pedro Alves 2009-03-17 Pedro Alves Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust. --- gdb/gdbserver/linux-low.c | 354 +++++++++++++++++++++---------------------- gdb/gdbserver/linux-low.h | 16 - gdb/gdbserver/proc-service.c | 10 - gdb/gdbserver/thread-db.c | 44 ++--- 4 files changed, 212 insertions(+), 212 deletions(-) Index: src/gdb/gdbserver/linux-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-low.c 2009-03-12 14:54:19.000000000 +0000 +++ src/gdb/gdbserver/linux-low.c 2009-03-17 18:42:12.000000000 +0000 @@ -89,10 +89,10 @@ /* ``all_threads'' is keyed by the LWP ID, which we use as the GDB protocol representation of the thread ID. - ``all_processes'' is keyed by the process ID - which on Linux is (presently) + ``all_lwps'' is keyed by the process ID - which on Linux is (presently) the same as the LWP ID. */ -struct inferior_list all_processes; +struct inferior_list all_lwps; /* A list of all unknown processes which receive stop signals. Some other process will presumably claim each of these as forked children @@ -114,13 +114,13 @@ static int must_set_ptrace_flags; low target's arch_setup callback. */ static int new_inferior; -static void linux_resume_one_process (struct inferior_list_entry *entry, - int step, int signal, siginfo_t *info); +static void linux_resume_one_lwp (struct inferior_list_entry *entry, + int step, int signal, siginfo_t *info); static void linux_resume (struct thread_resume *resume_info, size_t n); -static void stop_all_processes (void); +static void stop_all_lwps (void); static int linux_wait_for_event (struct thread_info *child); -static int check_removed_breakpoint (struct process_info *event_child); -static void *add_process (unsigned long pid); +static int check_removed_breakpoint (struct lwp_info *event_child); +static void *add_lwp (unsigned long pid); static int my_waitpid (int pid, int *status, int flags); static int linux_stopped_by_watchpoint (void); @@ -142,13 +142,13 @@ static int num_regsets; #define pid_of(proc) ((proc)->head.id) /* FIXME: Delete eventually. */ -#define inferior_pid (pid_of (get_thread_process (current_inferior))) +#define inferior_pid (pid_of (get_thread_lwp (current_inferior))) static void -handle_extended_wait (struct process_info *event_child, int wstat) +handle_extended_wait (struct lwp_info *event_child, int wstat) { int event = wstat >> 16; - struct process_info *new_process; + struct lwp_info *new_lwp; if (event == PTRACE_EVENT_CLONE) { @@ -175,9 +175,9 @@ handle_extended_wait (struct process_inf ptrace (PTRACE_SETOPTIONS, new_pid, 0, PTRACE_O_TRACECLONE); - new_process = (struct process_info *) add_process (new_pid); - add_thread (new_pid, new_process, new_pid); - new_thread_notify (thread_id_to_gdb_id (new_process->lwpid)); + new_lwp = (struct lwp_info *) add_lwp (new_pid); + add_thread (new_pid, new_lwp, new_pid); + new_thread_notify (thread_id_to_gdb_id (new_lwp->lwpid)); /* Normally we will get the pending SIGSTOP. But in some cases we might get another signal delivered to the group first. @@ -185,18 +185,18 @@ handle_extended_wait (struct process_inf if (WSTOPSIG (status) == SIGSTOP) { if (stopping_threads) - new_process->stopped = 1; + new_lwp->stopped = 1; else ptrace (PTRACE_CONT, new_pid, 0, 0); } else { - new_process->stop_expected = 1; + new_lwp->stop_expected = 1; if (stopping_threads) { - new_process->stopped = 1; - new_process->status_pending_p = 1; - new_process->status_pending = status; + new_lwp->stopped = 1; + new_lwp->status_pending_p = 1; + new_lwp->status_pending = status; } else /* Pass the signal on. This is what GDB does - except @@ -207,8 +207,8 @@ handle_extended_wait (struct process_inf /* Always resume the current thread. If we are stopping threads, it will have a pending SIGSTOP; we may as well collect it now. */ - linux_resume_one_process (&event_child->head, - event_child->stepping, 0, NULL); + linux_resume_one_lwp (&event_child->head, + event_child->stepping, 0, NULL); } } @@ -239,26 +239,26 @@ get_stop_pc (void) { CORE_ADDR stop_pc = (*the_low_target.get_pc) (); - if (get_thread_process (current_inferior)->stepping) + if (get_thread_lwp (current_inferior)->stepping) return stop_pc; else return stop_pc - the_low_target.decr_pc_after_break; } static void * -add_process (unsigned long pid) +add_lwp (unsigned long pid) { - struct process_info *process; + struct lwp_info *lwp; - process = (struct process_info *) xmalloc (sizeof (*process)); - memset (process, 0, sizeof (*process)); + lwp = (struct lwp_info *) xmalloc (sizeof (*lwp)); + memset (lwp, 0, sizeof (*lwp)); - process->head.id = pid; - process->lwpid = pid; + lwp->head.id = pid; + lwp->lwpid = pid; - add_inferior_to_list (&all_processes, &process->head); + add_inferior_to_list (&all_lwps, &lwp->head); - return process; + return lwp; } /* Start an inferior process and returns its pid. @@ -267,7 +267,7 @@ add_process (unsigned long pid) static int linux_create_inferior (char *program, char **allargs) { - void *new_process; + void *new_lwp; int pid; #if defined(__UCLIBC__) && defined(HAS_NOMMU) @@ -296,8 +296,8 @@ linux_create_inferior (char *program, ch _exit (0177); } - new_process = add_process (pid); - add_thread (pid, new_process, pid); + new_lwp = add_lwp (pid); + add_thread (pid, new_lwp, pid); must_set_ptrace_flags = 1; new_inferior = 1; @@ -309,14 +309,14 @@ linux_create_inferior (char *program, ch void linux_attach_lwp (unsigned long pid) { - struct process_info *new_process; + struct lwp_info *new_lwp; if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0) { if (all_threads.head != NULL) { /* If we fail to attach to an LWP, just warn. */ - fprintf (stderr, "Cannot attach to process %ld: %s (%d)\n", pid, + fprintf (stderr, "Cannot attach to lwp %ld: %s (%d)\n", pid, strerror (errno), errno); fflush (stderr); return; @@ -331,9 +331,9 @@ linux_attach_lwp (unsigned long pid) We need to wait for SIGSTOP first. */ ptrace (PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACECLONE); - new_process = (struct process_info *) add_process (pid); - add_thread (pid, new_process, pid); - new_thread_notify (thread_id_to_gdb_id (new_process->lwpid)); + new_lwp = (struct lwp_info *) add_lwp (pid); + add_thread (pid, new_lwp, pid); + new_thread_notify (thread_id_to_gdb_id (new_lwp->lwpid)); /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH brings it to a halt. @@ -363,24 +363,24 @@ linux_attach_lwp (unsigned long pid) On the other hand, if we are currently trying to stop all threads, we should treat the new thread as if we had sent it a SIGSTOP. This works - because we are guaranteed that the add_process call above added us to the + because we are guaranteed that the add_lwp call above added us to the end of the list, and so the new thread has not yet reached wait_for_sigstop (but will). */ if (! stopping_threads) - new_process->stop_expected = 1; + new_lwp->stop_expected = 1; } int linux_attach (unsigned long pid) { - struct process_info *process; + struct lwp_info *lwp; linux_attach_lwp (pid); /* Don't ignore the initial SIGSTOP if we just attached to this process. It will be collected by wait shortly. */ - process = (struct process_info *) find_inferior_id (&all_processes, pid); - process->stop_expected = 0; + lwp = (struct lwp_info *) find_inferior_id (&all_lwps, pid); + lwp->stop_expected = 0; new_inferior = 1; @@ -390,10 +390,10 @@ linux_attach (unsigned long pid) /* Kill the inferior process. Make us have no inferior. */ static void -linux_kill_one_process (struct inferior_list_entry *entry) +linux_kill_one_lwp (struct inferior_list_entry *entry) { struct thread_info *thread = (struct thread_info *) entry; - struct process_info *process = get_thread_process (thread); + struct lwp_info *lwp = get_thread_lwp (thread); int wstat; /* We avoid killing the first thread here, because of a Linux kernel (at @@ -405,7 +405,7 @@ linux_kill_one_process (struct inferior_ do { - ptrace (PTRACE_KILL, pid_of (process), 0, 0); + ptrace (PTRACE_KILL, pid_of (lwp), 0, 0); /* Make sure it died. The loop is most likely unnecessary. */ wstat = linux_wait_for_event (thread); @@ -416,68 +416,68 @@ static void linux_kill (void) { struct thread_info *thread = (struct thread_info *) all_threads.head; - struct process_info *process; + struct lwp_info *lwp; int wstat; if (thread == NULL) return; - for_each_inferior (&all_threads, linux_kill_one_process); + for_each_inferior (&all_threads, linux_kill_one_lwp); - /* See the comment in linux_kill_one_process. We did not kill the first + /* See the comment in linux_kill_one_lwp. We did not kill the first thread in the list, so do so now. */ - process = get_thread_process (thread); + lwp = get_thread_lwp (thread); do { - ptrace (PTRACE_KILL, pid_of (process), 0, 0); + ptrace (PTRACE_KILL, pid_of (lwp), 0, 0); /* Make sure it died. The loop is most likely unnecessary. */ wstat = linux_wait_for_event (thread); } while (WIFSTOPPED (wstat)); clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; + free (all_lwps.head); + all_lwps.head = all_lwps.tail = NULL; } static void -linux_detach_one_process (struct inferior_list_entry *entry) +linux_detach_one_lwp (struct inferior_list_entry *entry) { struct thread_info *thread = (struct thread_info *) entry; - struct process_info *process = get_thread_process (thread); + struct lwp_info *lwp = get_thread_lwp (thread); /* Make sure the process isn't stopped at a breakpoint that's no longer there. */ - check_removed_breakpoint (process); + check_removed_breakpoint (lwp); /* If this process is stopped but is expecting a SIGSTOP, then make sure we take care of that now. This isn't absolutely guaranteed to collect the SIGSTOP, but is fairly likely to. */ - if (process->stop_expected) + if (lwp->stop_expected) { /* Clear stop_expected, so that the SIGSTOP will be reported. */ - process->stop_expected = 0; - if (process->stopped) - linux_resume_one_process (&process->head, 0, 0, NULL); + lwp->stop_expected = 0; + if (lwp->stopped) + linux_resume_one_lwp (&lwp->head, 0, 0, NULL); linux_wait_for_event (thread); } /* Flush any pending changes to the process's registers. */ regcache_invalidate_one ((struct inferior_list_entry *) - get_process_thread (process)); + get_lwp_thread (lwp)); /* Finally, let it resume. */ - ptrace (PTRACE_DETACH, pid_of (process), 0, 0); + ptrace (PTRACE_DETACH, pid_of (lwp), 0, 0); } static int linux_detach (void) { delete_all_breakpoints (); - for_each_inferior (&all_threads, linux_detach_one_process); + for_each_inferior (&all_threads, linux_detach_one_lwp); clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; + free (all_lwps.head); + all_lwps.head = all_lwps.tail = NULL; return 0; } @@ -508,7 +508,7 @@ linux_thread_alive (unsigned long lwpid) no longer appears to be inserted. Also adjust the PC appropriately to resume where the breakpoint used to be. */ static int -check_removed_breakpoint (struct process_info *event_child) +check_removed_breakpoint (struct lwp_info *event_child) { CORE_ADDR stop_pc; struct thread_info *saved_inferior; @@ -517,11 +517,11 @@ check_removed_breakpoint (struct process return 0; if (debug_threads) - fprintf (stderr, "Checking for breakpoint in process %ld.\n", + fprintf (stderr, "Checking for breakpoint in lwp %ld.\n", event_child->lwpid); saved_inferior = current_inferior; - current_inferior = get_process_thread (event_child); + current_inferior = get_lwp_thread (event_child); stop_pc = get_stop_pc (); @@ -566,15 +566,15 @@ check_removed_breakpoint (struct process return 1; } -/* Return 1 if this process has an interesting status pending. This function - may silently resume an inferior process. */ +/* Return 1 if this lwp has an interesting status pending. This + function may silently resume an inferior lwp. */ static int status_pending_p (struct inferior_list_entry *entry, void *dummy) { - struct process_info *process = (struct process_info *) entry; + struct lwp_info *lwp = (struct lwp_info *) entry; - if (process->status_pending_p) - if (check_removed_breakpoint (process)) + if (lwp->status_pending_p) + if (check_removed_breakpoint (lwp)) { /* This thread was stopped at a breakpoint, and the breakpoint is now gone. We were told to continue (or step...) all threads, @@ -582,15 +582,15 @@ status_pending_p (struct inferior_list_e So instead of reporting the old SIGTRAP, pretend we got to the breakpoint just after it was removed instead of just before; resume the process. */ - linux_resume_one_process (&process->head, 0, 0, NULL); + linux_resume_one_lwp (&lwp->head, 0, 0, NULL); return 0; } - return process->status_pending_p; + return lwp->status_pending_p; } static void -linux_wait_for_process (struct process_info **childp, int *wstatp) +linux_wait_for_lwp (struct lwp_info **childp, int *wstatp) { int ret; int to_wait_for = -1; @@ -631,7 +631,7 @@ retry: fprintf (stderr, "Got an event from %d (%x)\n", ret, *wstatp); if (to_wait_for == -1) - *childp = (struct process_info *) find_inferior_id (&all_processes, ret); + *childp = (struct lwp_info *) find_inferior_id (&all_lwps, ret); /* If we didn't find a process, one of two things presumably happened: - A process we started and then detached from has exited. Ignore it. @@ -680,7 +680,7 @@ static int linux_wait_for_event (struct thread_info *child) { CORE_ADDR stop_pc; - struct process_info *event_child; + struct lwp_info *event_child; int wstat; int bp_status; @@ -690,14 +690,14 @@ linux_wait_for_event (struct thread_info (in check_removed_breakpoint); signals should be reported anyway. */ if (child == NULL) { - event_child = (struct process_info *) - find_inferior (&all_processes, status_pending_p, NULL); + event_child = (struct lwp_info *) + find_inferior (&all_lwps, status_pending_p, NULL); if (debug_threads && event_child) fprintf (stderr, "Got a pending child %ld\n", event_child->lwpid); } else { - event_child = get_thread_process (child); + event_child = get_thread_lwp (child); if (event_child->status_pending_p && check_removed_breakpoint (event_child)) event_child = NULL; @@ -713,7 +713,7 @@ linux_wait_for_event (struct thread_info wstat = event_child->status_pending; event_child->status_pending_p = 0; event_child->status_pending = 0; - current_inferior = get_process_thread (event_child); + current_inferior = get_lwp_thread (event_child); return wstat; } } @@ -727,9 +727,9 @@ linux_wait_for_event (struct thread_info if (child == NULL) event_child = NULL; else - event_child = get_thread_process (child); + event_child = get_thread_lwp (child); - linux_wait_for_process (&event_child, &wstat); + linux_wait_for_lwp (&event_child, &wstat); if (event_child == NULL) error ("event from unknown child"); @@ -749,7 +749,7 @@ linux_wait_for_event (struct thread_info dead_thread_notify (thread_id_to_gdb_id (event_child->lwpid)); - remove_inferior (&all_processes, &event_child->head); + remove_inferior (&all_lwps, &event_child->head); free (event_child); remove_thread (current_inferior); current_inferior = (struct thread_info *) all_threads.head; @@ -770,8 +770,8 @@ linux_wait_for_event (struct thread_info if (debug_threads) fprintf (stderr, "Expected stop.\n"); event_child->stop_expected = 0; - linux_resume_one_process (&event_child->head, - event_child->stepping, 0, NULL); + linux_resume_one_lwp (&event_child->head, + event_child->stepping, 0, NULL); continue; } @@ -812,9 +812,9 @@ linux_wait_for_event (struct thread_info info_p = &info; else info_p = NULL; - linux_resume_one_process (&event_child->head, - event_child->stepping, - WSTOPSIG (wstat), info_p); + linux_resume_one_lwp (&event_child->head, + event_child->stepping, + WSTOPSIG (wstat), info_p); continue; } @@ -842,7 +842,7 @@ linux_wait_for_event (struct thread_info event_child->bp_reinsert = 0; /* Clear the single-stepping flag and SIGTRAP as we resume. */ - linux_resume_one_process (&event_child->head, 0, 0, NULL); + linux_resume_one_lwp (&event_child->head, 0, 0, NULL); continue; } @@ -879,18 +879,18 @@ linux_wait_for_event (struct thread_info process. */ if (bp_status == 2) /* No need to reinsert. */ - linux_resume_one_process (&event_child->head, 0, 0, NULL); + linux_resume_one_lwp (&event_child->head, 0, 0, NULL); else if (the_low_target.breakpoint_reinsert_addr == NULL) { event_child->bp_reinsert = stop_pc; uninsert_breakpoint (stop_pc); - linux_resume_one_process (&event_child->head, 1, 0, NULL); + linux_resume_one_lwp (&event_child->head, 1, 0, NULL); } else { reinsert_breakpoint_by_bp (stop_pc, (*the_low_target.breakpoint_reinsert_addr) ()); - linux_resume_one_process (&event_child->head, 0, 0, NULL); + linux_resume_one_lwp (&event_child->head, 0, 0, NULL); } continue; @@ -958,7 +958,7 @@ retry: } w = linux_wait_for_event (child); - stop_all_processes (); + stop_all_lwps (); if (must_set_ptrace_flags) { @@ -985,8 +985,8 @@ retry: fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w)); *status = 'W'; clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; + free (all_lwps.head); + all_lwps.head = all_lwps.tail = NULL; return WEXITSTATUS (w); } else if (!WIFSTOPPED (w)) @@ -994,8 +994,8 @@ retry: fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w)); *status = 'X'; clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; + free (all_lwps.head); + all_lwps.head = all_lwps.tail = NULL; return target_signal_from_host (WTERMSIG (w)); } } @@ -1036,47 +1036,47 @@ kill_lwp (unsigned long lwpid, int signo static void send_sigstop (struct inferior_list_entry *entry) { - struct process_info *process = (struct process_info *) entry; + struct lwp_info *lwp = (struct lwp_info *) entry; - if (process->stopped) + if (lwp->stopped) return; /* If we already have a pending stop signal for this process, don't send another. */ - if (process->stop_expected) + if (lwp->stop_expected) { if (debug_threads) - fprintf (stderr, "Have pending sigstop for process %ld\n", - process->lwpid); + fprintf (stderr, "Have pending sigstop for lwp %ld\n", + lwp->lwpid); /* We clear the stop_expected flag so that wait_for_sigstop will receive the SIGSTOP event (instead of silently resuming and waiting again). It'll be reset below. */ - process->stop_expected = 0; + lwp->stop_expected = 0; return; } if (debug_threads) - fprintf (stderr, "Sending sigstop to process %ld\n", process->head.id); + fprintf (stderr, "Sending sigstop to lwp %ld\n", lwp->head.id); - kill_lwp (process->head.id, SIGSTOP); + kill_lwp (lwp->head.id, SIGSTOP); } static void wait_for_sigstop (struct inferior_list_entry *entry) { - struct process_info *process = (struct process_info *) entry; + struct lwp_info *lwp = (struct lwp_info *) entry; struct thread_info *saved_inferior, *thread; int wstat; unsigned long saved_tid; - if (process->stopped) + if (lwp->stopped) return; saved_inferior = current_inferior; saved_tid = ((struct inferior_list_entry *) saved_inferior)->id; thread = (struct thread_info *) find_inferior_id (&all_threads, - process->lwpid); + lwp->lwpid); wstat = linux_wait_for_event (thread); /* If we stopped with a non-SIGSTOP signal, save it for later @@ -1087,7 +1087,7 @@ wait_for_sigstop (struct inferior_list_e { if (debug_threads) fprintf (stderr, "LWP %ld stopped with non-sigstop status %06x\n", - process->lwpid, wstat); + lwp->lwpid, wstat); /* Do not leave a pending single-step finish to be reported to the client. The client will give us a new action for this @@ -1095,7 +1095,7 @@ wait_for_sigstop (struct inferior_list_e would consider this pending SIGTRAP reported later a spurious signal. */ if (WSTOPSIG (wstat) == SIGTRAP - && process->stepping + && lwp->stepping && !linux_stopped_by_watchpoint ()) { if (debug_threads) @@ -1103,10 +1103,10 @@ wait_for_sigstop (struct inferior_list_e } else { - process->status_pending_p = 1; - process->status_pending = wstat; + lwp->status_pending_p = 1; + lwp->status_pending = wstat; } - process->stop_expected = 1; + lwp->stop_expected = 1; } if (linux_thread_alive (saved_tid)) @@ -1122,11 +1122,11 @@ wait_for_sigstop (struct inferior_list_e } static void -stop_all_processes (void) +stop_all_lwps (void) { stopping_threads = 1; - for_each_inferior (&all_processes, send_sigstop); - for_each_inferior (&all_processes, wait_for_sigstop); + for_each_inferior (&all_lwps, send_sigstop); + for_each_inferior (&all_lwps, wait_for_sigstop); stopping_threads = 0; } @@ -1135,43 +1135,43 @@ stop_all_processes (void) If SIGNAL is nonzero, give it that signal. */ static void -linux_resume_one_process (struct inferior_list_entry *entry, - int step, int signal, siginfo_t *info) +linux_resume_one_lwp (struct inferior_list_entry *entry, + int step, int signal, siginfo_t *info) { - struct process_info *process = (struct process_info *) entry; + struct lwp_info *lwp = (struct lwp_info *) entry; struct thread_info *saved_inferior; - if (process->stopped == 0) + if (lwp->stopped == 0) return; /* If we have pending signals or status, and a new signal, enqueue the signal. Also enqueue the signal if we are waiting to reinsert a breakpoint; it will be picked up again below. */ if (signal != 0 - && (process->status_pending_p || process->pending_signals != NULL - || process->bp_reinsert != 0)) + && (lwp->status_pending_p || lwp->pending_signals != NULL + || lwp->bp_reinsert != 0)) { struct pending_signals *p_sig; p_sig = xmalloc (sizeof (*p_sig)); - p_sig->prev = process->pending_signals; + p_sig->prev = lwp->pending_signals; p_sig->signal = signal; if (info == NULL) memset (&p_sig->info, 0, sizeof (siginfo_t)); else memcpy (&p_sig->info, info, sizeof (siginfo_t)); - process->pending_signals = p_sig; + lwp->pending_signals = p_sig; } - if (process->status_pending_p && !check_removed_breakpoint (process)) + if (lwp->status_pending_p && !check_removed_breakpoint (lwp)) return; saved_inferior = current_inferior; - current_inferior = get_process_thread (process); + current_inferior = get_lwp_thread (lwp); if (debug_threads) - fprintf (stderr, "Resuming process %ld (%s, signal %d, stop %s)\n", inferior_pid, + fprintf (stderr, "Resuming lwp %ld (%s, signal %d, stop %s)\n", inferior_pid, step ? "step" : "continue", signal, - process->stop_expected ? "expected" : "not expected"); + lwp->stop_expected ? "expected" : "not expected"); /* This bit needs some thinking about. If we get a signal that we must report while a single-step reinsert is still pending, @@ -1180,13 +1180,13 @@ linux_resume_one_process (struct inferio the reinsert happened right away and not lose any signals. Making this stack would also shrink the window in which breakpoints are - uninserted (see comment in linux_wait_for_process) but not enough for + uninserted (see comment in linux_wait_for_lwp) but not enough for complete correctness, so it won't solve that problem. It may be worthwhile just to solve this one, however. */ - if (process->bp_reinsert != 0) + if (lwp->bp_reinsert != 0) { if (debug_threads) - fprintf (stderr, " pending reinsert at %08lx", (long)process->bp_reinsert); + fprintf (stderr, " pending reinsert at %08lx", (long)lwp->bp_reinsert); if (step == 0) fprintf (stderr, "BAD - reinserting but not stepping.\n"); step = 1; @@ -1195,7 +1195,7 @@ linux_resume_one_process (struct inferio signal = 0; } - check_removed_breakpoint (process); + check_removed_breakpoint (lwp); if (debug_threads && the_low_target.get_pc != NULL) { @@ -1205,28 +1205,28 @@ linux_resume_one_process (struct inferio /* If we have pending signals, consume one unless we are trying to reinsert a breakpoint. */ - if (process->pending_signals != NULL && process->bp_reinsert == 0) + if (lwp->pending_signals != NULL && lwp->bp_reinsert == 0) { struct pending_signals **p_sig; - p_sig = &process->pending_signals; + p_sig = &lwp->pending_signals; while ((*p_sig)->prev != NULL) p_sig = &(*p_sig)->prev; signal = (*p_sig)->signal; if ((*p_sig)->info.si_signo != 0) - ptrace (PTRACE_SETSIGINFO, process->lwpid, 0, &(*p_sig)->info); + ptrace (PTRACE_SETSIGINFO, lwp->lwpid, 0, &(*p_sig)->info); free (*p_sig); *p_sig = NULL; } regcache_invalidate_one ((struct inferior_list_entry *) - get_process_thread (process)); + get_lwp_thread (lwp)); errno = 0; - process->stopped = 0; - process->stepping = step; - ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, process->lwpid, 0, signal); + lwp->stopped = 0; + lwp->stepping = step; + ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwp->lwpid, 0, signal); current_inferior = saved_inferior; if (errno) @@ -1261,24 +1261,24 @@ struct thread_resume_array static int linux_set_resume_request (struct inferior_list_entry *entry, void *arg) { - struct process_info *process; + struct lwp_info *lwp; struct thread_info *thread; int ndx; struct thread_resume_array *r; thread = (struct thread_info *) entry; - process = get_thread_process (thread); + lwp = get_thread_lwp (thread); r = arg; for (ndx = 0; ndx < r->n; ndx++) if (r->resume[ndx].thread == -1 || r->resume[ndx].thread == entry->id) { - process->resume = &r->resume[ndx]; + lwp->resume = &r->resume[ndx]; return 0; } /* No resume action for this thread. */ - process->resume = NULL; + lwp->resume = NULL; return 0; } @@ -1292,26 +1292,26 @@ linux_set_resume_request (struct inferio static void linux_continue_one_thread (struct inferior_list_entry *entry) { - struct process_info *process; + struct lwp_info *lwp; struct thread_info *thread; int step; thread = (struct thread_info *) entry; - process = get_thread_process (thread); + lwp = get_thread_lwp (thread); - if (process->resume == NULL) + if (lwp->resume == NULL) return; - if (process->resume->thread == -1 - && process->stepping - && process->pending_is_breakpoint) + if (lwp->resume->thread == -1 + && lwp->stepping + && lwp->pending_is_breakpoint) step = 1; else - step = process->resume->step; + step = lwp->resume->step; - linux_resume_one_process (&process->head, step, process->resume->sig, NULL); + linux_resume_one_lwp (&lwp->head, step, lwp->resume->sig, NULL); - process->resume = NULL; + lwp->resume = NULL; } /* This function is called once per thread. We check the thread's resume @@ -1324,47 +1324,47 @@ linux_continue_one_thread (struct inferi static void linux_queue_one_thread (struct inferior_list_entry *entry) { - struct process_info *process; + struct lwp_info *lwp; struct thread_info *thread; thread = (struct thread_info *) entry; - process = get_thread_process (thread); + lwp = get_thread_lwp (thread); - if (process->resume == NULL) + if (lwp->resume == NULL) return; /* If we have a new signal, enqueue the signal. */ - if (process->resume->sig != 0) + if (lwp->resume->sig != 0) { struct pending_signals *p_sig; p_sig = xmalloc (sizeof (*p_sig)); - p_sig->prev = process->pending_signals; - p_sig->signal = process->resume->sig; + p_sig->prev = lwp->pending_signals; + p_sig->signal = lwp->resume->sig; memset (&p_sig->info, 0, sizeof (siginfo_t)); /* If this is the same signal we were previously stopped by, make sure to queue its siginfo. We can ignore the return value of ptrace; if it fails, we'll skip PTRACE_SETSIGINFO. */ - if (WIFSTOPPED (process->last_status) - && WSTOPSIG (process->last_status) == process->resume->sig) - ptrace (PTRACE_GETSIGINFO, process->lwpid, 0, &p_sig->info); + if (WIFSTOPPED (lwp->last_status) + && WSTOPSIG (lwp->last_status) == lwp->resume->sig) + ptrace (PTRACE_GETSIGINFO, lwp->lwpid, 0, &p_sig->info); - process->pending_signals = p_sig; + lwp->pending_signals = p_sig; } - process->resume = NULL; + lwp->resume = NULL; } /* Set DUMMY if this process has an interesting status pending. */ static int resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p) { - struct process_info *process = (struct process_info *) entry; + struct lwp_info *lwp = (struct lwp_info *) entry; /* Processes which will not be resumed are not interesting, because we might not wait for them next time through linux_wait. */ - if (process->resume == NULL) + if (lwp->resume == NULL) return 0; /* If this thread has a removed breakpoint, we won't have any @@ -1375,10 +1375,10 @@ resume_status_pending_p (struct inferior GDB removes the breakpoint to single-step a particular thread past it, then re-inserts it and resumes all threads. We want to report the second thread without resuming it in the interim. */ - if (process->status_pending_p) - check_removed_breakpoint (process); + if (lwp->status_pending_p) + check_removed_breakpoint (lwp); - if (process->status_pending_p) + if (lwp->status_pending_p) * (int *) flag_p = 1; return 0; @@ -1397,7 +1397,7 @@ linux_resume (struct thread_resume *resu report the pending status. Make sure to queue any signals that would otherwise be sent. */ pending_flag = 0; - find_inferior (&all_processes, resume_status_pending_p, &pending_flag); + find_inferior (&all_lwps, resume_status_pending_p, &pending_flag); if (debug_threads) { @@ -1525,7 +1525,7 @@ usr_store_inferior_registers (int regno) { /* At this point, ESRCH should mean the process is already gone, in which case we simply ignore attempts to change its registers. - See also the related comment in linux_resume_one_process. */ + See also the related comment in linux_resume_one_lwp. */ if (errno == ESRCH) return; @@ -1661,7 +1661,7 @@ regsets_store_inferior_registers () { /* At this point, ESRCH should mean the process is already gone, in which case we simply ignore attempts to change its registers. - See also the related comment in linux_resume_one_process. */ + See also the related comment in linux_resume_one_lwp. */ return 0; } else @@ -1977,10 +1977,10 @@ linux_request_interrupt (void) if (cont_thread != 0 && cont_thread != -1) { - struct process_info *process; + struct lwp_info *lwp; - process = get_thread_process (current_inferior); - kill_lwp (process->lwpid, SIGINT); + lwp = get_thread_lwp (current_inferior); + kill_lwp (lwp->lwpid, SIGINT); } else kill_lwp (signal_pid, SIGINT); @@ -2069,7 +2069,7 @@ linux_read_offsets (CORE_ADDR *text_p, C { #if defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) && defined(PT_TEXT_END_ADDR) unsigned long text, text_end, data; - int pid = get_thread_process (current_inferior)->head.id; + int pid = get_thread_lwp (current_inferior)->head.id; errno = 0; @@ -2211,7 +2211,7 @@ linux_xfer_siginfo (const char *annex, u if (current_inferior == NULL) return -1; - pid = pid_of (get_thread_process (current_inferior)); + pid = pid_of (get_thread_lwp (current_inferior)); if (debug_threads) fprintf (stderr, "%s siginfo for lwp %ld.\n", Index: src/gdb/gdbserver/linux-low.h =================================================================== --- src.orig/gdb/gdbserver/linux-low.h 2009-03-11 23:42:53.000000000 +0000 +++ src/gdb/gdbserver/linux-low.h 2009-03-17 19:00:05.000000000 +0000 @@ -78,13 +78,13 @@ struct linux_target_ops extern struct linux_target_ops the_low_target; -#define get_process(inf) ((struct process_info *)(inf)) -#define get_thread_process(thr) (get_process (inferior_target_data (thr))) -#define get_process_thread(proc) ((struct thread_info *) \ - find_inferior_id (&all_threads, \ - get_process (proc)->lwpid)) +#define get_lwp(inf) ((struct lwp_info *)(inf)) +#define get_thread_lwp(thr) (get_lwp (inferior_target_data (thr))) +#define get_lwp_thread(proc) ((struct thread_info *) \ + find_inferior_id (&all_threads, \ + get_lwp (proc)->lwpid)) -struct process_info +struct lwp_info { struct inferior_list_entry head; unsigned long lwpid; @@ -126,7 +126,7 @@ struct process_info struct pending_signals *pending_signals; /* A link used when resuming. It is initialized from the resume request, - and then processed and cleared in linux_resume_one_process. */ + and then processed and cleared in linux_resume_one_lwp. */ struct thread_resume *resume; @@ -138,7 +138,7 @@ struct process_info #endif }; -extern struct inferior_list all_processes; +extern struct inferior_list all_lwps; void linux_attach_lwp (unsigned long pid); Index: src/gdb/gdbserver/proc-service.c =================================================================== --- src.orig/gdb/gdbserver/proc-service.c 2009-03-11 23:42:53.000000000 +0000 +++ src/gdb/gdbserver/proc-service.c 2009-03-17 18:42:12.000000000 +0000 @@ -99,15 +99,15 @@ ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) { #ifdef HAVE_REGSETS - struct process_info *process; + struct lwp_info *lwp; struct thread_info *reg_inferior, *save_inferior; - process = (struct process_info *) find_inferior_id (&all_processes, - lwpid); - if (process == NULL) + lwp = (struct lwp_info *) find_inferior_id (&all_lwps, + lwpid); + if (lwp == NULL) return PS_ERR; - reg_inferior = get_process_thread (process); + reg_inferior = get_lwp_thread (lwp); save_inferior = current_inferior; current_inferior = reg_inferior; Index: src/gdb/gdbserver/thread-db.c =================================================================== --- src.orig/gdb/gdbserver/thread-db.c 2009-03-11 23:42:53.000000000 +0000 +++ src/gdb/gdbserver/thread-db.c 2009-03-17 18:42:12.000000000 +0000 @@ -136,7 +136,7 @@ thread_db_create_event (CORE_ADDR where) { td_event_msg_t msg; td_err_e err; - struct process_info *process; + struct lwp_info *lwp; if (debug_threads) fprintf (stderr, "Thread creation event.\n"); @@ -153,9 +153,9 @@ thread_db_create_event (CORE_ADDR where) /* If we do not know about the main thread yet, this would be a good time to find it. We need to do this to pick up the main thread before any newly created threads. */ - process = get_thread_process (current_inferior); - if (process->thread_known == 0) - find_one_thread (process->lwpid); + lwp = get_thread_lwp (current_inferior); + if (lwp->thread_known == 0) + find_one_thread (lwp->lwpid); /* msg.event == TD_EVENT_CREATE */ @@ -237,15 +237,15 @@ find_one_thread (int lwpid) td_thrinfo_t ti; td_err_e err; struct thread_info *inferior; - struct process_info *process; + struct lwp_info *lwp; inferior = (struct thread_info *) find_inferior_id (&all_threads, lwpid); - process = get_thread_process (inferior); - if (process->thread_known) + lwp = get_thread_lwp (inferior); + if (lwp->thread_known) return 1; /* Get information about this thread. */ - err = td_ta_map_lwp2thr (thread_agent, process->lwpid, &th); + err = td_ta_map_lwp2thr (thread_agent, lwp->lwpid, &th); if (err != TD_OK) error ("Cannot get thread handle for LWP %d: %s", lwpid, thread_db_err_str (err)); @@ -259,10 +259,10 @@ find_one_thread (int lwpid) fprintf (stderr, "Found thread %ld (LWP %d)\n", ti.ti_tid, ti.ti_lid); - if (process->lwpid != ti.ti_lid) + if (lwp->lwpid != ti.ti_lid) { warning ("PID mismatch! Expected %ld, got %ld", - (long) process->lwpid, (long) ti.ti_lid); + (long) lwp->lwpid, (long) ti.ti_lid); return 0; } @@ -279,8 +279,8 @@ find_one_thread (int lwpid) if (ti.ti_tid == 0) return 0; - process->thread_known = 1; - process->th = th; + lwp->thread_known = 1; + lwp->th = th; return 1; } @@ -290,7 +290,7 @@ maybe_attach_thread (const td_thrhandle_ { td_err_e err; struct thread_info *inferior; - struct process_info *process; + struct lwp_info *lwp; inferior = (struct thread_info *) find_inferior_id (&all_threads, ti_p->ti_lid); @@ -310,10 +310,10 @@ maybe_attach_thread (const td_thrhandle_ return; } - process = inferior_target_data (inferior); + lwp = inferior_target_data (inferior); - process->thread_known = 1; - process->th = *th_p; + lwp->thread_known = 1; + lwp->th = *th_p; if (thread_db_use_events) { @@ -384,18 +384,18 @@ thread_db_get_tls_address (struct thread #if HAVE_TD_THR_TLS_GET_ADDR psaddr_t addr; td_err_e err; - struct process_info *process; + struct lwp_info *lwp; - process = get_thread_process (thread); - if (!process->thread_known) - find_one_thread (process->lwpid); - if (!process->thread_known) + lwp = get_thread_lwp (thread); + if (!lwp->thread_known) + find_one_thread (lwp->lwpid); + if (!lwp->thread_known) return TD_NOTHR; /* Note the cast through uintptr_t: this interface only works if a target address fits in a psaddr_t, which is a host pointer. So a 32-bit debugger can not access 64-bit TLS through this. */ - err = td_thr_tls_get_addr (&process->th, (psaddr_t) (uintptr_t) load_module, + err = td_thr_tls_get_addr (&lwp->th, (psaddr_t) (uintptr_t) load_module, offset, &addr); if (err == TD_OK) {