Date: Sun, 10 Apr 2005 03:32:28 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 74825 for review Message-ID: <200504100332.j3A3WSmD004949@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=74825 Change 74825 by davidxu@davidxu_tiger on 2005/04/10 03:32:16 Enable initial thread to report events. Affected files ... .. //depot/projects/davidxu_thread/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#9 edit Differences ... ==== //depot/projects/davidxu_thread/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#9 (text+ko) ==== @@ -138,6 +138,9 @@ /* Prototypes for local functions. */ static void fbsd_thread_find_new_threads (void); static int fbsd_thread_alive (ptid_t ptid); +static void attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, + const td_thrinfo_t *ti_p, int verbose); +static void fbsd_thread_detach (char *args, int from_tty); /* Building process ids. */ @@ -233,23 +236,21 @@ /* Convert LWP to user-level thread id. */ static ptid_t -thread_from_lwp (ptid_t ptid) +thread_from_lwp (ptid_t ptid, td_thrhandle_t *th, td_thrinfo_t *ti) { - td_thrinfo_t ti; - td_thrhandle_t th; td_err_e err; gdb_assert (IS_LWP (ptid)); if (fbsd_thread_active) { - err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th); + err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), th); if (err == TD_OK) { - err = td_thr_get_info_p (&th, &ti); + err = td_thr_get_info_p (th, ti); if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); - return BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); + return BUILD_THREAD (ti->ti_tid, GET_PID (ptid)); } } @@ -290,14 +291,19 @@ 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); + ptid = thread_from_lwp (tmp, &th, &ti); if (!in_thread_list (ptid)) { +#if 0 + attach_thread (ptid, &th, &ti, 1); +#endif add_thread (ptid); } inferior_ptid = ptid; @@ -648,7 +654,7 @@ /* Add the thread to GDB's thread list. */ if (!in_thread_list (ptid)) add_thread (ptid); - + if (verbose) printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid)); @@ -724,17 +730,24 @@ 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))); + 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); -#if 0 - if (!in_thread_list (ret)) - add_thread (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 @@ -745,7 +758,6 @@ delete_thread (inferior_ptid); inferior_ptid = ret; } -#endif } return (ret);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504100332.j3A3WSmD004949>