How to use bts recording?

Metzger, Markus T markus.t.metzger@intel.com
Thu Jan 27 10:45:38 GMT 2022


Hello Simon,

>I see - but something is still not ideal.
>At least on this machine GDB 11.1 said:
>
>(gdb) record btrace bts
>Could not enable branch tracing for Thread 0x7ffff7fe4740 (LWP 2756):
>**Failed to start recording: Operation not supported**
>
>While the Debian GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git reports
>
>Could not enable branch tracing for Thread 0x7ffff79833c0 (LWP 334):
>**BTS support has been disabled for the target cpu**
>
>That's a clear message, I like that.

The first message comes from failing to enable BTS and from printing errno.

The second message comes from cpu_supports_bts() returning false for AMD.
We have not even tried enabling it.


>> I'm afraid that's a fairly common problem, these days, but I don't see how
>> GDB could check that it is running in a guest OS and that the hypervisor did
>> not virtualize PT or BTS.
>
>As you've said: use of virtualized environments is quite common, so it
>may be reasonable to adjust the docs to at least hint at that issue.
>
>I suggest changing
>
>- Hardware-supported instruction recording, supported on Intel processors
>+ Hardware-supported instruction recording, supported on Intel
>processors if not running in a virtual machine.

That's a feature of the hypervisor, not of GDB.  Hypervisors that do virtualize BTS
or PT won't be very happy with such wording inside the GDB manual.


>Failed to open /sys/bus/event_source/devices/intel_pt/type
>
>[note: that message possibly could hint at "Intel PT not available"]

We can probably turn the file open failure into something like "the system does
not support PT".  I agree that this would be a lot more helpful.


>Also: not sure if libipt is the one that is checking that directory, but
>possibly GDB could do this _before_ printing
> > Intel Processor Trace support was disabled at compile time.
>
>... because this led me to believe "just reconfigure and possible
>install libipt before and everything will be fine" - but if I had done
>this the only result would have been another error message.

This would be another check we could do.  Right now, we don't even try since
GDB wouldn't be able to decode the trace, anyway.

Which error message is more helpful is probably subjective.  If you went through
the effort of setting up a bare metal system only to find out that your version of
GDB doesn't support PT, anyway, the other order would be more useful.

Given that most distros meanwhile build GDB with PT support, I'd keep the current
order of errors.

Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


More information about the Gdb mailing list