From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17631 invoked by alias); 9 Sep 2015 10:35:52 -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 17565 invoked by uid 89); 9 Sep 2015 10:35:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_05,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Sep 2015 10:35:46 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 09 Sep 2015 03:35:13 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 09 Sep 2015 03:35:11 -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 t89AZA8D004723; Wed, 9 Sep 2015 11:35:11 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t89AZAro000548; Wed, 9 Sep 2015 12:35:10 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t89AZAQa000541; Wed, 9 Sep 2015 12:35:10 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH 03/17] btrace: improve stepping debugging Date: Wed, 09 Sep 2015 10:35:00 -0000 Message-Id: <1441794909-32718-4-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1441794909-32718-1-git-send-email-markus.t.metzger@intel.com> References: <1441794909-32718-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00112.txt.bz2 2015-09-09 Markus Metzger gdb/ * record-btrace.c (btrace_thread_flag_to_str) (record_btrace_cancel_resume): New. (record_btrace_step_thread): Call btrace_thread_flag_to_str. (record_btrace_resume): Print execution direction. (record_btrace_resume_thread): Call btrace_thread_flag_to_str. (record_btrace_wait): Call record_btrace_cancel_resume. --- gdb/record-btrace.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index a9ed4b7..7ee681c 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1659,6 +1659,32 @@ record_btrace_to_get_tailcall_unwinder (struct target_ops *self) return &record_btrace_tailcall_frame_unwind; } +/* Return a human-readable string for FLAG. */ + +static const char * +btrace_thread_flag_to_str (enum btrace_thread_flag flag) +{ + switch (flag) + { + case BTHR_STEP: + return "step"; + + case BTHR_RSTEP: + return "reverse-step"; + + case BTHR_CONT: + return "cont"; + + case BTHR_RCONT: + return "reverse-cont"; + + case BTHR_STOP: + return "stop"; + } + + return ""; +} + /* Indicate that TP should be resumed according to FLAG. */ static void @@ -1667,7 +1693,8 @@ record_btrace_resume_thread (struct thread_info *tp, { struct btrace_thread_info *btinfo; - DEBUG ("resuming %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), flag); + DEBUG ("resuming thread %d (%s): %x (%s)", tp->num, + target_pid_to_str (tp->ptid), flag, btrace_thread_flag_to_str (flag)); btinfo = &tp->btrace; @@ -1820,7 +1847,9 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step, struct thread_info *tp, *other; enum btrace_thread_flag flag; - DEBUG ("resume %s: %s", target_pid_to_str (ptid), step ? "step" : "cont"); + DEBUG ("resume %s: %s%s", target_pid_to_str (ptid), + execution_direction == EXEC_REVERSE ? "reverse-" : "", + step ? "step" : "cont"); /* Store the execution direction of the last resume. */ record_btrace_resume_exec_dir = execution_direction; @@ -1865,6 +1894,24 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step, } } +/* Cancel resuming TP. */ + +static void +record_btrace_cancel_resume (struct thread_info *tp) +{ + enum btrace_thread_flag flags; + + flags = tp->btrace.flags & (BTHR_MOVE | BTHR_STOP); + if (flags == 0) + return; + + DEBUG ("cancel resume thread %d (%s): %x (%s)", tp->num, + target_pid_to_str (tp->ptid), flags, + btrace_thread_flag_to_str (flags)); + + tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP); +} + /* Find a thread to move. */ static struct thread_info * @@ -1955,7 +2002,9 @@ record_btrace_step_thread (struct thread_info *tp) flags = btinfo->flags & (BTHR_MOVE | BTHR_STOP); btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP); - DEBUG ("stepping %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), flags); + DEBUG ("stepping thread %d (%s): %x (%s)", tp->num, + target_pid_to_str (tp->ptid), flags, + btrace_thread_flag_to_str (flags)); /* We can't step without an execution history. */ if ((flags & BTHR_MOVE) != 0 && btrace_is_empty (tp)) @@ -2126,7 +2175,7 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid, /* Stop all other threads. */ if (!target_is_non_stop_p ()) ALL_NON_EXITED_THREADS (other) - other->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP); + record_btrace_cancel_resume (other); /* Start record histories anew from the current position. */ record_btrace_clear_histories (&tp->btrace); -- 1.8.3.1