From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67345 invoked by alias); 17 Sep 2015 14:10:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 67235 invoked by uid 89); 17 Sep 2015 14:10:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Sep 2015 14:09:56 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 17 Sep 2015 07:09:56 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 17 Sep 2015 07:09:55 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8HE9s4n001526; Thu, 17 Sep 2015 15:09:54 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t8HE9sHr001569; Thu, 17 Sep 2015 16:09:54 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t8HE9rhH001565; Thu, 17 Sep 2015 16:09:54 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v3 10/19] btrace: temporarily set inferior_ptid in record_btrace_start_replaying Date: Thu, 17 Sep 2015 14:10:00 -0000 Message-Id: <1442498990-1222-11-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1442498990-1222-1-git-send-email-markus.t.metzger@intel.com> References: <1442498990-1222-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00421.txt.bz2 Get_current_frame uses inferior_ptid. In record_btrace_start_replaying, we need to get the current frame of the argument thread. So far, this has always been inferior_ptid. With non-stop, this is not guaranteed. Temporarily set inferior_ptid to the ptid of the argument thread. We already temporarily set the argument thread's executing flag to false. Move both into a new function get_thread_current_frame that does the temporary adjustments, calls get_current_frame, and restores the previous values. 2015-09-17 Markus Metzger gdb/ * record-btrace.c (get_thread_current_frame): New. (record_btrace_start_replaying): Call get_thread_current_frame. --- gdb/record-btrace.c | 70 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index c25b8f4..0514471 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1707,6 +1707,55 @@ record_btrace_resume_thread (struct thread_info *tp, btinfo->flags |= flag; } +/* Get the current frame for TP. */ + +static struct frame_info * +get_thread_current_frame (struct thread_info *tp) +{ + struct frame_info *frame; + ptid_t old_inferior_ptid; + int executing; + + /* Set INFERIOR_PTID, which is implicitly used by get_current_frame. */ + old_inferior_ptid = inferior_ptid; + inferior_ptid = tp->ptid; + + /* Clear the executing flag to allow changes to the current frame. + We are not actually running, yet. We just started a reverse execution + command or a record goto command. + For the latter, EXECUTING is false and this has no effect. + For the former, EXECUTING is true and we're in to_wait, about to + move the thread. Since we need to recompute the stack, we temporarily + set EXECUTING to flase. */ + executing = is_executing (inferior_ptid); + set_executing (inferior_ptid, 0); + + frame = NULL; + TRY + { + frame = get_current_frame (); + } + CATCH (except, RETURN_MASK_ALL) + { + /* Restore the previous execution state. */ + set_executing (inferior_ptid, executing); + + /* Restore the previous inferior_ptid. */ + inferior_ptid = old_inferior_ptid; + + throw_exception (except); + } + END_CATCH + + /* Restore the previous execution state. */ + set_executing (inferior_ptid, executing); + + /* Restore the previous inferior_ptid. */ + inferior_ptid = old_inferior_ptid; + + return frame; +} + /* Start replaying a thread. */ static struct btrace_insn_iterator * @@ -1714,7 +1763,6 @@ record_btrace_start_replaying (struct thread_info *tp) { struct btrace_insn_iterator *replay; struct btrace_thread_info *btinfo; - int executing; btinfo = &tp->btrace; replay = NULL; @@ -1723,16 +1771,6 @@ record_btrace_start_replaying (struct thread_info *tp) if (btinfo->begin == NULL) return NULL; - /* Clear the executing flag to allow changes to the current frame. - We are not actually running, yet. We just started a reverse execution - command or a record goto command. - For the latter, EXECUTING is false and this has no effect. - For the former, EXECUTING is true and we're in to_wait, about to - move the thread. Since we need to recompute the stack, we temporarily - set EXECUTING to flase. */ - executing = is_executing (tp->ptid); - set_executing (tp->ptid, 0); - /* GDB stores the current frame_id when stepping in order to detects steps into subroutines. Since frames are computed differently when we're replaying, we need to @@ -1745,7 +1783,7 @@ record_btrace_start_replaying (struct thread_info *tp) int upd_step_frame_id, upd_step_stack_frame_id; /* The current frame without replaying - computed via normal unwind. */ - frame = get_current_frame (); + frame = get_thread_current_frame (tp); frame_id = get_frame_id (frame); /* Check if we need to update any stepping-related frame id's. */ @@ -1777,7 +1815,7 @@ record_btrace_start_replaying (struct thread_info *tp) registers_changed_ptid (tp->ptid); /* The current frame with replaying - computed via btrace unwind. */ - frame = get_current_frame (); + frame = get_thread_current_frame (tp); frame_id = get_frame_id (frame); /* Replace stepping related frames where necessary. */ @@ -1788,9 +1826,6 @@ record_btrace_start_replaying (struct thread_info *tp) } CATCH (except, RETURN_MASK_ALL) { - /* Restore the previous execution state. */ - set_executing (tp->ptid, executing); - xfree (btinfo->replay); btinfo->replay = NULL; @@ -1800,9 +1835,6 @@ record_btrace_start_replaying (struct thread_info *tp) } END_CATCH - /* Restore the previous execution state. */ - set_executing (tp->ptid, executing); - return replay; } -- 1.8.3.1