From owner-p4-projects@FreeBSD.ORG Tue Jul 20 07:57:01 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C6EDA16A4D0; Tue, 20 Jul 2004 07:57:00 +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 84EDB16A4CE for ; Tue, 20 Jul 2004 07:57:00 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67EAB43D5C for ; Tue, 20 Jul 2004 07:57:00 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i6K7v0pK085404 for ; Tue, 20 Jul 2004 07:57:00 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i6K7v034085399 for perforce@freebsd.org; Tue, 20 Jul 2004 07:57:00 GMT (envelope-from davidxu@freebsd.org) Date: Tue, 20 Jul 2004 07:57:00 GMT Message-Id: <200407200757.i6K7v034085399@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 57771 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: Tue, 20 Jul 2004 07:57:01 -0000 http://perforce.freebsd.org/chv.cgi?CH=57771 Change 57771 by davidxu@davidxu_celeron on 2004/07/20 07:56:28 Don't forget to unbind the temporarily bound thread. Affected files ... .. //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#16 edit Differences ... ==== //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#16 (text+ko) ==== @@ -72,6 +72,8 @@ /* The last thread we are single stepping */ static lwpid_t last_single_step_lwp; +static ptid_t last_single_step_ptid; + /* Pointers to the libthread_db functions. */ static td_err_e (*td_init_p) (void); @@ -115,6 +117,7 @@ /* Prototypes for local functions. */ static void fbsd_thread_find_new_threads (void); +static int fbsd_thread_alive (ptid_t ptid); /* Building process ids. */ @@ -409,6 +412,26 @@ work_ptid = inferior_ptid; } + /* + * For KSE thread, if last time we were single stepping + * a thread, first we unbind thread because we had bound it, + * may rebind it in following code. + */ + if (!ptid_equal(last_single_step_ptid, null_ptid)) + { + ret = td_ta_map_id2thr_p (thread_agent, + GET_THREAD(last_single_step_ptid), &th); + if (ret == TD_OK) + { + /* + * keep stepping flag (may be cleared in following code), + * but unbind the thread + */ + td_thr_sstep_p (&th, 1); + } + last_single_step_ptid = null_ptid; + } + lwp = GET_LWP (work_ptid); if (lwp == 0) { @@ -418,13 +441,13 @@ error (thread_db_err_str (ret)); /* - * For M:N thread, we need to tell UTS to set/unset single step + * For KSE thread, we need to tell UTS to set/unset single step * flag at context switch time, the flag will be written into * thread mailbox. This becauses some architecture may not have * machine single step flag in ucontext, so we put the flag in mailbox, * when the thread switches back, kse_switchin restores the single step * state. - */ + */ ret = td_thr_sstep_p (&th, resume_all ? step : 2); if (ret) error (thread_db_err_str (ret)); @@ -432,6 +455,8 @@ if (ret) error (thread_db_err_str (ret)); lwp = ti.ti_lid; + if (!resume_all) + last_single_step_ptid = work_ptid; } if (!resume_all && lwp == 0) @@ -457,6 +482,14 @@ free (lwps); } + /* + * FIX ME! if we can let PT_CONTINUE continue a single lwp, + * we needn't to iterate through lwp list to suspend/resume them, + * we just let the lwp run, this frees PT_SUSPEND PT_RESUME to user, + * so td_thr_dbsuspend/resume can be used to suspend or resume + * thread by user on command line... + */ + int i; if (last_single_step_lwp != 0) { @@ -483,10 +516,9 @@ last_single_step_lwp = 0; free (lwps); -/* ret = ptrace(PT_RESUME, lwp, 0, 0); */ /* now continue the process, suspended thread wont run */ - if (ptrace (PT_CONTINUE, proc_handle.pid , (caddr_t)1, + if (ptrace (PT_CONTINUE, proc_handle.pid, (caddr_t)1, target_signal_to_host(signo))) perror_with_name ("PT_CONTINUE"); }