Depends on D87589.
In D87589 I added the basic instruction decoding functionality and the Dump action was printing the raw strings. I'm now pretty printing the instructions, with an output like the following:
pid: '1234', tid: '1981309' a.out`main [57] 0x400549 <+13>: movl %eax, -0x4(%rbp) a.out`bar() [56] 0x40053b <+46>: retq [55] 0x40053a <+45>: leave [54] 0x400537 <+42>: movl -0x4(%rbp), %eax [53] 0x400535 <+40>: jle 0x400525 ; <+24> at main.cpp:7 [52] 0x400531 <+36>: cmpl $0x3, -0x8(%rbp) [51] 0x40052d <+32>: addl $0x1, -0x8(%rbp) [50] 0x40052a <+29>: addl %eax, -0x4(%rbp) a.out`foo() [49] 0x400567 <+15>: retq [48] 0x400566 <+14>: popq %rbp [47] 0x400563 <+11>: movl -0x4(%rbp), %eax [46] 0x40055c <+4>: movl $0x2a, -0x4(%rbp) [45] 0x400559 <+1>: movq %rsp, %rbp [44] 0x400558 <+0>: pushq %rbp
There's also a --raw flag that prints simply the instructions addresses.
An important remark is that the decoder can fail to decode some instructions, which we are printing, for example:
pid: '1234', tid: '3842849'
[4] 0x400529 <+28>: cmpl $0x3, -0x8(%rbp) [3] error -13. 'no memory mapped at this address' [2] 0x40052d <+32>: jle 0x400521
As an implementation note, I'm using lldb's Disassembler. I couldn't move the entire printing logic to the disassembler because it assumes that all instuctions printed are valid, which conflicts with what the intel-pt decoder outputs.
Finally, the instruction dumping command is as follows:
trace dump -i [-rv] [-c <count>] [-o <offset>] [-t <thread-id>]
clang-tidy: error: 'lldb/Core/PluginInterface.h' file not found [clang-diagnostic-error]
not useful