eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
311 stars 202 forks source link

The disassembly view dosen't show opcode #397

Open ljw66 opened 1 year ago

ljw66 commented 1 year ago

Describe the bug When I debug a remote riscv project. I run gdb in cmd and input "disas /r" command. The output has opcodes. When I use the same gdb debug the same execute file. I open disassembly view and click show opcodes. The disassembly text move to the right a little but no opcode. In the gdb console, I write "disas /r" and the output contains opcode.

Screenshots image image image image

jld01 commented 1 year ago

Hi @ljw66, can you provide the version of CDT and the version of GDB that you are using please? GDB version example:

C:\Users\MyUserId> riscv64-unknown-elf-gdb --version
GNU gdb (SiFive GDB-Metal 10.1.0-2020.12.7) 10.1

Also, can you provide example -data-disassemble commands and responses from the GDB traces console when Show Opcodes is enabled with your RISC-V target? For example:

196,402 52-data-disassemble --thread 1 -s 140712279148817 -e 140712279148977 -- 3
196,411 52^done,asm_insns=[{address="0x00007ffa216a0911",func-name="ntdll!LdrInitShimEngineDynamic",\
offset="865",opcodes="eb 00",inst="jmp    0x7ffa216a0913 <ntdll!LdrInitShimEngineDynamic+867>"},{add\
ress="0x00007ffa216a0913",func-name="ntdll!LdrInitShimEngineDynamic",offset="867",opcodes="48 83 c4 \
38",inst="add    $0x38,%rsp"},{address="0x00007ffa216a0917",func-name="ntdll!LdrInitShimEngineDynami\
c",offset="871",opcodes="c3",inst="retq   "},{address="0x00007ffa216a0918",func-name="ntdll!LdrInitS\
[message truncated to 5 lines. More lines can be set in the Preference->Debug->GDB eclipse preference page.]
196,411 (gdb) 

You can enable access to the GDB traces consoles from the C/C++ > Debug > GDB page of the workspace preferences dialog.

ljw66 commented 1 year ago

@jld01 Thanks for help. I found my toolchain use big endian mode to show opcode. But it seems that cdt only show little endian. Am I right?

jonahgraham commented 1 year ago

CDT shouldn't care about endianess in this case because CDT really just passes the string it gets from GDB to the UI. It is possible that the tool chain is providing the disassembly in a format not understood by CDT.

In particular CDT uses the now deprecated mode 1 and 3 of -data-disassemble command. Perhaps the version of GDB you are using has simply stop implementing those modes?

Please provide the traces from GDB so we can track it down - https://github.com/eclipse-cdt/cdt/tree/main/FAQ#ive-been-asked-for-gdb-traces-where-can-i-find-them