Is there is any way to switch to assembly when debugging a C or C++ program in gdb ? (Given that all source files and their corresponding assembly files are available)
gdb is the GNU source-level debugger that is standard on linux (and many other unix) systems. It can be used both for programs written in high-level languages like C and C++ and for assembly code programs; this document concentrates on the latter.
You can always leave or enter TUI at any time durring debug session. For example you can do it with ctrl + x a key binding.
asmwill display the assembly and command windows. splitwill display the source, assembly, and command windows. regswill display the register, source, and command windows when in src layout. When in asm or split layout, will display the register, assembler, and command windows.
stepi: Step one instruction exactly. nexti: Step one instruction, but proceed through subroutine calls. since we are dealing with instructions and machine code here (the smallest part of a program in execution) I can't figure out what the subroutine calls are. c++ c debugging gdb.
You can switch to asm layout in gdb:
(gdb) layout asm
See here for more information.
There is a way to disassemble a function or a certain section of code, is that what you are after?
The command to do so would be disassemble <function name>
or a memory location.
Is this what you are referring to?
(gdb) help disassemble Disassemble a specified section of memory. Default is the function surrounding the pc of the selected frame. With a single argument, the function surrounding that address is dumped. Two arguments are taken as a range of memory to dump.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With