]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
btrace: diagnose "record btrace pt" without libipt
authorMarkus Metzger <markus.t.metzger@intel.com>
Thu, 19 Nov 2015 13:33:41 +0000 (14:33 +0100)
committerMarkus Metzger <markus.t.metzger@intel.com>
Thu, 26 Nov 2015 10:24:28 +0000 (11:24 +0100)
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 <num>\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.

The issue is documented as PR 19297.

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.

gdb/
* btrace.c (btrace_enable): Check whether HAVE_LIBIPT is defined.

testsuite/
* lib/gdb.exp (skip_btrace_pt_tests): Check for a "GDB does not
support" error.

gdb/ChangeLog
gdb/btrace.c
gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdb.exp

index fbc56ac13ffe47b2a688ea9907ccf5ed24fd218c..9c8b9e7e364e0576c9449c1eebeead488f201fa6 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-26  Markus Metzger  <markus.t.metzger@intel.com>
+
+       PR 19297
+       * btrace.c (btrace_enable): Check whether HAVE_LIBIPT is defined.
+
 2015-11-24  Pedro Alves  <palves@redhat.com>
 
        * NEWS: Mention that a few "info" commands now list the
index 2bf71771bb5ded9520a6ac0a983745df76187d3f..35431cbdb2673a9e25b4508d5dc02c6f7804e4be 100644 (file)
@@ -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."));
 
index fd7c1f4c2680f9c49c617ce789b81cbe1d8dc61d..9f6d7e67cfcbba01cd5d59f7524d3a488082f9d7 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-26  Markus Metzger  <markus.t.metzger@intel.com>
+
+       PR 19297
+       * lib/gdb.exp (skip_btrace_pt_tests): Check for a "GDB does not
+       support" error.
+
 2015-11-24  Pedro Alves  <palves@redhat.com>
 
        PR 17539
index a420181c5a2496c448f7020e624d4b688982b62f..90e864467310d15c45ebe84320c6ab7169cca44e 100644 (file)
@@ -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
         }