https://reviews.llvm.org/D33035 added in 2017 basic support for intel-pt. I plan to improve it and use it to support reverse debugging.
I fixed a couple of issues and now this plugin works again:
- pythonlib needed to be linked against it for the SB framework. Linking was failing because of this
- the decoding functionality was broken because it lacked handling for instruction events. It seems old versions of libipt, the actual decoding library, didn't require these, but modern version require it (you can read more here https://github.com/intel/libipt/blob/master/doc/howto_libipt.md). These events signal overflows of the internal PT buffer in the CPU, enable/disable events of tracing, async cpu events, interrupts, etc.
I ended up refactoring a little bit the code to reduce code duplication.
In another diff I'll implement some basic tests.
This is a simple execution of the library:
(lldb) target create "/data/users/wallace/rr-project/a.out" Current executable set to '/data/users/wallace/rr-project/a.out' (x86_64). (lldb) plugin load liblldbIntelFeatures.so (lldb) b main Breakpoint 1: where = a.out`main + 8 at test.cpp:10, address = 0x00000000004007fa (lldb) b test.cpp:14 Breakpoint 2: where = a.out`main + 50 at test.cpp:14, address = 0x0000000000400824 (lldb) r Process 902754 stopped * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x00000000004007fa a.out`main at test.cpp:10 7 } 8 9 int main() { -> 10 int z = 0; 11 for(int i = 0; i < 10000; i++) 12 z += fun(z); 13 Process 902754 launched: '/data/users/wallace/rr-project/a.out' (x86_64) (lldb) processor-trace start all (lldb) c Process 902754 resuming Process 902754 stopped * thread #1, name = 'a.out', stop reason = breakpoint 2.1 frame #0: 0x0000000000400824 a.out`main at test.cpp:14 11 for(int i = 0; i < 10000; i++) 12 z += fun(z); 13 -> 14 cout << z<< endl; 15 return 0; 16 } (lldb) processor-trace show-instr-log thread #1: tid=902754 0x7ffff72299b9 <+9>: addq $0x8, %rsp 0x7ffff72299bd <+13>: retq 0x4007ed <+16>: addl $0x1, %eax 0x4007f0 <+19>: leave 0x4007f1 <+20>: retq 0x400814 <+34>: addl %eax, -0x4(%rbp) 0x400817 <+37>: addl $0x1, -0x8(%rbp) 0x40081b <+41>: cmpl $0x270f, -0x8(%rbp) ; imm = 0x270F 0x400822 <+48>: jle 0x40080a ; <+24> at test.cpp:12 0x400822 <+48>: jle 0x40080a ; <+24> at test.cpp:12