From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86218 invoked by alias); 20 Nov 2015 09:17:12 -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 86207 invoked by uid 89); 20 Nov 2015 09:17:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Nov 2015 09:17:10 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 20 Nov 2015 01:17:08 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2015 01:17:07 -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 tAK9H7ff032637; Fri, 20 Nov 2015 09:17:07 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id tAK9H6Po004613; Fri, 20 Nov 2015 10:17:06 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id tAK9H6Nq004609; Fri, 20 Nov 2015 10:17:06 +0100 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH] btrace: diagnose "record btrace pt" without libipt Date: Fri, 20 Nov 2015 09:17:00 -0000 Message-Id: <1448011026-4192-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00413.txt.bz2 If GDB has been configured without libipt support, i.e. HAVE_LIBIPT is undefined, and is running on a system that supports Intel(R) Processor Trace, GDB will run into an internal error when trying to decode the trace. (gdb) record btrace (gdb) s usage (name=0x7fffffffe954 "fib-64") at src/fib.c:12 12 fprintf(stderr, "usage: %s \n", name); (gdb) info record Active record target: record-btrace Recording format: Intel(R) Processor Trace. Buffer size: 16kB. gdb/btrace.c:971: internal-error: Unexpected branch trace format. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) This requires a system with Linux kernel 4.1 or later running on a 5th Generation Intel Core processor or later. When trying to enable branch tracing, in addition to checking the target support for the requested branch tracing format, also check whether GDB supports. it. 2015-11-20 Markus Metzger gdb/ * btrace.c (btrace_enable): Check whether HAVE_LIBIPT is defined. testsuite/ * gdb.exp (skip_btrace_pt_tests): Check for a "GDB does not support" error. --- gdb/btrace.c | 5 +++++ gdb/testsuite/lib/gdb.exp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/gdb/btrace.c b/gdb/btrace.c index 2bf7177..35431cb 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1035,6 +1035,11 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf) if (tp->btrace.target != NULL) return; +#if !defined (HAVE_LIBIPT) + if (conf->format == BTRACE_FORMAT_PT) + error (_("GDB does not support Intel(R) Processor Trace.")); +#endif /* !defined (HAVE_LIBIPT) */ + if (!target_supports_btrace (conf->format)) error (_("Target does not support branch tracing.")); diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index a420181..90e8644 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2826,6 +2826,9 @@ gdb_caching_proc skip_btrace_pt_tests { -re "Could not enable branch tracing.*\r\n$gdb_prompt $" { set skip_btrace_tests 1 } + -re "GDB does not support.*\r\n$gdb_prompt $" { + set skip_btrace_tests 1 + } -re "^record btrace pt\r\n$gdb_prompt $" { set skip_btrace_tests 0 } -- 1.8.3.1