diff options
Diffstat (limited to 'gdb/infttrace.c')
-rw-r--r-- | gdb/infttrace.c | 104 |
1 files changed, 54 insertions, 50 deletions
diff --git a/gdb/infttrace.c b/gdb/infttrace.c index 3229f35..ffcbd20 100644 --- a/gdb/infttrace.c +++ b/gdb/infttrace.c @@ -383,7 +383,7 @@ static thread_info_header thread_head = static thread_info_header deleted_threads = {0, NULL, NULL}; -static saved_real_pid = 0; +static ptid_t saved_real_ptid; /************************************************* @@ -623,7 +623,7 @@ create_thread_info (int pid, lwpid_t tid) 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 { @@ -1238,7 +1238,7 @@ update_thread_list (void) 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 @@ -1625,14 +1625,15 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr, * 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; } @@ -1653,14 +1654,14 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr, 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 @@ -1747,11 +1748,11 @@ stop_all_threads_of_process (pid_t real_pid) 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) @@ -2595,8 +2596,8 @@ count_unhandled_events (int real_pid, lwpid_t real_tid) * * Note: used by core gdb and so uses the pseudo-pid (really tid). */ -int -ptrace_wait (int pid, int *status) +ptid_t +ptrace_wait (ptid_t ptid, int *status) { ttstate_t tsp; int ttwait_return; @@ -2620,13 +2621,13 @@ ptrace_wait (int pid, int *status) if (errno == ESRCH) { *status = 0; /* WIFEXITED */ - return inferior_pid; + return inferior_ptid; } warning ("Call of ttrace_wait returned with errno %d.", errno); *status = ttwait_return; - return inferior_pid; + return inferior_ptid; } real_pid = tsp.tts_pid; @@ -2688,7 +2689,7 @@ ptrace_wait (int pid, int *status) #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); @@ -2851,7 +2852,7 @@ ptrace_wait (int pid, int *status) * 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); } @@ -2904,7 +2905,7 @@ ptrace_wait (int pid, int *status) /* Remember this for later use in "hppa_prepare_to_proceed". */ - old_gdb_pid = inferior_pid; + old_gdb_pid = PIDGET (inferior_ptid); reported_pid = return_pid; reported_bpt = ((tsp.tts_event & TTEVT_SIGNAL) && (5 == tsp.tts_u.tts_signal.tts_signo)); @@ -2913,7 +2914,7 @@ ptrace_wait (int pid, int *status) warning ("Internal error: process-wait failed."); } - return return_pid; + return pid_to_ptid (return_pid); } @@ -3150,9 +3151,9 @@ child_acknowledge_created_inferior (int pid) * 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. @@ -3582,8 +3583,9 @@ child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id) * May need a FIXME for that reason. */ int -child_thread_alive (lwpid_t gdb_tid) +child_thread_alive (ptid_t ptid) { + lwpid_t gdp_tid = PIDGET (ptid); lwpid_t tid; /* This spins down the lists twice. @@ -3815,11 +3817,11 @@ kill_inferior (void) 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 @@ -3849,7 +3851,7 @@ kill_inferior (void) } 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. @@ -3872,7 +3874,7 @@ kill_inferior (void) xfree (paranoia); call_ttrace (TT_PROC_STOP, - inferior_pid, + PIDGET (inferior_ptid), TT_NIL, TT_NIL, TT_NIL); @@ -4313,7 +4315,7 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal) * -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 @@ -4323,11 +4325,12 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal) * | 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) || @@ -4342,7 +4345,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal) 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); @@ -4648,7 +4651,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal) /* * 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? * */ @@ -4702,7 +4705,7 @@ update_thread_state_after_attach (int pid, attach_continue_t kind_of_go) * * 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!). @@ -4876,7 +4879,7 @@ detach (int signal) { errno = 0; call_ttrace (TT_PROC_DETACH, - inferior_pid, + PIDGET (inferior_ptid), TT_NIL, (TTRACE_ARG_TYPE) signal, TT_NIL); @@ -4939,7 +4942,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int 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); @@ -4948,7 +4951,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, 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, @@ -4967,7 +4970,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, { errno = 0; call_ttrace (TT_LWP_WRDATA, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, (TTRACE_ARG_TYPE) buffer[i], TT_NIL); @@ -4977,7 +4980,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, 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); @@ -4993,7 +4996,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, { errno = 0; buffer[i] = call_ttrace (TT_LWP_RDTEXT, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, TT_NIL, TT_NIL); @@ -5044,7 +5047,7 @@ udot_info (void) 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); @@ -5074,7 +5077,7 @@ child_pid_to_exec_file (int tid) int name_index; int i; int done; - int saved_inferior_pid; + ptid_t saved_inferior_ptid; /* As of 10.x HP-UX, there's an explicit request to get the *pathname. @@ -5100,19 +5103,19 @@ child_pid_to_exec_file (int tid) 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 + /* On the chance that pid != inferior_ptid, set inferior_ptid + to pid, so that (grrrr!) implicit uses of inferior_ptid get the right id. */ - saved_inferior_pid = inferior_pid; - inferior_pid = tid; + saved_inferior_ptid = inferior_ptid; + inferior_ptid = pid_to_ptid (tid); /* Try to grab a null-terminated string. */ while (!done) { if (target_read_memory (top_of_stack, four_chars, 4) != 0) { - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; return NULL; } for (i = 0; i < 4; i++) @@ -5127,11 +5130,11 @@ child_pid_to_exec_file (int tid) if (exec_file_buffer[0] == '\0') { - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; return NULL; } - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; return exec_file_buffer; } @@ -5626,17 +5629,18 @@ hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len) 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; |