Bug 19297

Summary: Internal error on "record btrace": Unexpected branch trace format.
Product: gdb Reporter: Markus Metzger <markus.t.metzger>
Component: recordAssignee: Markus Metzger <markus.t.metzger>
Status: RESOLVED FIXED    
Severity: normal CC: mark, mervegunesli
Priority: P2    
Version: 7.10   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Markus Metzger 2015-11-26 10:22:41 UTC
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.
Comment 1 Sourceware Commits 2015-11-26 10:27:37 UTC
The master branch has been updated by Markus Metzger <mmetzger@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=46a3515b49ce30315e2b621525b29cd8263aed15

commit 46a3515b49ce30315e2b621525b29cd8263aed15
Author: Markus Metzger <markus.t.metzger@intel.com>
Date:   Thu Nov 19 14:33:41 2015 +0100

    btrace: diagnose "record btrace pt" without libipt
    
    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.
Comment 2 Sourceware Commits 2015-11-26 12:20:05 UTC
The gdb-7.10-branch branch has been updated by Markus Metzger <mmetzger@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bab694b7f968cc5703a69df694b5968384d6c0b4

commit bab694b7f968cc5703a69df694b5968384d6c0b4
Author: Markus Metzger <markus.t.metzger@intel.com>
Date:   Thu Nov 19 14:33:41 2015 +0100

    btrace: diagnose "record btrace pt" without libipt
    
    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.
Comment 3 Markus Metzger 2015-11-26 12:22:56 UTC
Fixed in commit 46a3515b49ce30315e2b621525b29cd8263aed15 (master) and commit bab694b7f968cc5703a69df694b5968384d6c0b4 (7.10).