static void get_current_thread () { td_thrhandle_t th; td_thrinfo_t ti; long lwp; ptid_t tmp, ptid; lwp = get_current_lwp (proc_handle.pid); tmp = BUILD_LWP (lwp, proc_handle.pid); ptid = thread_from_lwp (tmp, &th, &ti); if (!in_thread_list (ptid)) { attach_thread (ptid, &th, &ti, 1); } inferior_ptid = ptid; }
static ptid_t fbsd_thread_wait (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int options) { struct target_ops *beneath = find_target_beneath (ops); ptid_t ret; long lwp; CORE_ADDR stop_pc; td_thrhandle_t th; td_thrinfo_t ti; ret = beneath->to_wait (beneath, ptid, ourstatus, options); if (GET_PID(ret) >= 0 && ourstatus->kind == TARGET_WAITKIND_STOPPED) { lwp = get_current_lwp (GET_PID(ret)); ret = thread_from_lwp (BUILD_LWP(lwp, GET_PID(ret)), &th, &ti); if (!in_thread_list(ret)) { /* * We have to enable event reporting for initial thread * which was not mapped before. */ attach_thread(ret, &th, &ti, 1); } if (ourstatus->value.sig == TARGET_SIGNAL_TRAP) check_event(ret); /* this is a hack, if an event won't cause gdb to stop, for example, SIGALRM, gdb resumes the process immediatly without setting inferior_ptid to the new thread returned here, this is a bug because inferior_ptid may already not exist there, and passing a non-existing thread to fbsd_thread_resume causes error. However, if the exiting thread is the currently selected thread, then that is handled later in handle_inferior_event(), and we must not delete the currently selected thread. */ if (!fbsd_thread_alive (ops, inferior_ptid) && !ptid_equal(inferior_ptid, ret)) { delete_thread (inferior_ptid); inferior_ptid = ret; } } return (ret); }
static ptid_t fbsd_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { ptid_t ret; long lwp; CORE_ADDR stop_pc; td_thrhandle_t th; td_thrinfo_t ti; ret = child_ops.to_wait (ptid, ourstatus); if (GET_PID(ret) >= 0 && ourstatus->kind == TARGET_WAITKIND_STOPPED) { lwp = get_current_lwp (GET_PID(ret)); ret = thread_from_lwp (BUILD_LWP(lwp, GET_PID(ret)), &th, &ti); if (!in_thread_list(ret)) { /* * We have to enable event reporting for initial thread * which was not mapped before. */ attach_thread(ret, &th, &ti, 1); } if (ourstatus->value.sig == TARGET_SIGNAL_TRAP) check_event(ret); /* this is a hack, if an event won't cause gdb to stop, for example, SIGARLM, gdb resumes the process immediatly without setting inferior_ptid to the new thread returned here, this is a bug because inferior_ptid may already not exist there, and passing a none existing thread to fbsd_thread_resume causes error. */ if (!fbsd_thread_alive (inferior_ptid)) { delete_thread (inferior_ptid); inferior_ptid = ret; } } return (ret); }