lldb/ObjectFile,Disassembler: read some state from the executable
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 10 Mar 2022 20:55:46 +0000 (20:55 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 10 Mar 2022 21:42:06 +0000 (21:42 +0000)
commitc6042076081025bc8060637b05fbeb24dbb82538
treee123dc9066ada85ef8e52308cade35f2c8519c2a
parent1f45a1071dbd3f78f0f27469c0f1151edc5b9aa2
lldb/ObjectFile,Disassembler: read some state from the executable

Add support to inspect the ELF headers for RISCV targets to determine if
RVC or RVE are enabled and the floating point support to enable.  As per
the RISCV specification, d implies f, q implies d implies f, which gives
us the cascading effect that is used to enable the features when setting
up the disassembler.  With this change, it is now possible to attach the
debugger to a remote process and be able to disassemble the instruction
stream.

~~~
$ bin/lldb tmp/reduced
(lldb) target create "reduced"
Current executable set to '/tmp/reduced' (riscv64).
(lldb) gdb-remote localhost:1234
(lldb) Process 5737 stopped
* thread #1, name = 'reduced', stop reason = signal SIGTRAP
    frame #0: 0x0000003ff7fe1b20
->  0x3ff7fe1b20: mv     a0, sp
    0x3ff7fe1b22: jal    1936
    0x3ff7fe1b26: mv     s0, a0
    0x3ff7fe1b28: auipc  a0, 27
~~~
lldb/include/lldb/Utility/ArchSpec.h
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp