From owner-p4-projects@FreeBSD.ORG Sun Apr 10 03:32:29 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 85A1116A4D0; Sun, 10 Apr 2005 03:32:29 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 452EB16A4CE for ; Sun, 10 Apr 2005 03:32:29 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1DD9343D45 for ; Sun, 10 Apr 2005 03:32:29 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j3A3WTZE004952 for ; Sun, 10 Apr 2005 03:32:29 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j3A3WSmD004949 for perforce@freebsd.org; Sun, 10 Apr 2005 03:32:28 GMT (envelope-from davidxu@freebsd.org) Date: Sun, 10 Apr 2005 03:32:28 GMT Message-Id: <200504100332.j3A3WSmD004949@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 74825 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 03:32:30 -0000 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);