From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13193 invoked by alias); 19 Jan 2016 12:41:26 -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 13167 invoked by uid 89); 19 Jan 2016 12:41:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_05,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*r:sk:mmetzge, gaps, thread_info, Recording 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; Tue, 19 Jan 2016 12:41:24 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 19 Jan 2016 04:41:22 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2016 04:41:21 -0800 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 u0JCfK57019819; Tue, 19 Jan 2016 12:41:20 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u0JCfKsK021410; Tue, 19 Jan 2016 13:41:20 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id u0JCfKNG021406; Tue, 19 Jan 2016 13:41:20 +0100 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH 1/3] btrace: fix gap indication Date: Tue, 19 Jan 2016 12:41:00 -0000 Message-Id: <1453207280-21138-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg00427.txt.bz2 Trace gaps due to overflows or non-contiguous trace are ignored in the 'info record' command. Fix that. Also add a warning when decoding the trace and print the instruction number preceding the trace gap in that warning message. It looks like this: (gdb) info record Active record target: record-btrace Recording format: Intel Processor Trace. Buffer size: 16kB. warning: Decode error (-13) at instruction 101044 (offset = 0x29f0, pc = 0x7ffff728a642): no memory mapped at this address. Recorded 101044 instructions in 2093 functions (1 gaps) for thread 1 (process 5360). (gdb) record instruction-history 101044 101044 0x00007ffff728a640: pop %r13 [decode error (-13): no memory mapped at this address] Remove the dead code that was supposed to print a gaps warning at the end of trace decode. This isn't really needed since we now print a warning for each gap. 2016-01-19 Markus Metzger gdb/ * btrace.c (ftrace_add_pt): Fix gap indication. Add warning for non- contiguous trace and overflow. Rephrase trace decode warning and print instruction number. Remove dead gaps warning. (btrace_compute_ftrace_bts): Rephrase warnings and print instruction number. --- gdb/btrace.c | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 7c4da09..af8f16a 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -629,11 +629,12 @@ btrace_compute_ftrace_bts (struct thread_info *tp, beginning. */ if (begin != NULL) { - warning (_("Recorded trace may be corrupted around %s."), - core_addr_to_string_nz (pc)); - end = ftrace_new_gap (end, BDE_BTS_OVERFLOW); ngaps += 1; + + warning (_("Recorded trace may be corrupted at instruction " + "%u (pc = %s)."), end->insn_offset - 1, + core_addr_to_string_nz (pc)); } break; } @@ -671,14 +672,15 @@ btrace_compute_ftrace_bts (struct thread_info *tp, /* We can't continue if we fail to compute the size. */ if (size <= 0) { - warning (_("Recorded trace may be incomplete around %s."), - core_addr_to_string_nz (pc)); - /* Indicate the gap in the trace. We just added INSN so we're not at the beginning. */ end = ftrace_new_gap (end, BDE_BTS_INSN_SIZE); ngaps += 1; + warning (_("Recorded trace may be incomplete at instructionn %u " + "(pc = %s)."), end->insn_offset - 1, + core_addr_to_string_nz (pc)); + break; } @@ -749,11 +751,10 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, { struct btrace_function *begin, *end, *upd; uint64_t offset; - int errcode, nerrors; + int errcode; begin = *pbegin; end = *pend; - nerrors = 0; for (;;) { struct btrace_insn btinsn; @@ -784,11 +785,29 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, flag. The ENABLED instruction flag means that we continued from some other instruction. Indicate this as a trace gap. */ if (insn.enabled) - *pend = end = ftrace_new_gap (end, BDE_PT_DISABLED); + { + *pend = end = ftrace_new_gap (end, BDE_PT_DISABLED); + *ngaps += 1; + + pt_insn_get_offset (decoder, &offset); + + warning (_("Non-contiguous trace at instruction %u (offset " + "= 0x%" PRIx64 ", pc = 0x%" PRIx64 ")."), + end->insn_offset - 1, offset, insn.ip); + } /* Indicate trace overflows. */ if (insn.resynced) - *pend = end = ftrace_new_gap (end, BDE_PT_OVERFLOW); + { + *pend = end = ftrace_new_gap (end, BDE_PT_OVERFLOW); + *ngaps += 1; + + pt_insn_get_offset (decoder, &offset); + + warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 + ", pc = 0x%" PRIx64 ")."), end->insn_offset - 1, + offset, insn.ip); + } } upd = ftrace_update_function (end, insn.ip); @@ -819,19 +838,16 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, if (begin == NULL) continue; - pt_insn_get_offset (decoder, &offset); - - warning (_("Failed to decode Intel Processor Trace near trace " - "offset 0x%" PRIx64 " near recorded PC 0x%" PRIx64 ": %s."), - offset, insn.ip, pt_errstr (pt_errcode (errcode))); - /* Indicate the gap in the trace. */ *pend = end = ftrace_new_gap (end, errcode); *ngaps += 1; - } - if (nerrors > 0) - warning (_("The recorded execution trace may have gaps.")); + pt_insn_get_offset (decoder, &offset); + + warning (_("Decode error (%d) at instruction %u (offset = 0x%" PRIx64 + ", pc = 0x%" PRIx64 "): %s."), errcode, end->insn_offset - 1, + offset, insn.ip, pt_errstr (pt_errcode (errcode))); + } } /* A callback function to allow the trace decoder to read the inferior's -- 1.8.3.1