Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make cgdb show assembly code?

I can't find a way for cgdb to disassemble a binary and show the assembly code with the current instruction in the code window. Is this possible and what command should I use? I'm using Mac OS X and got cgdb from the homebrew repository.

like image 772
ihatetoregister Avatar asked Feb 04 '12 17:02

ihatetoregister


2 Answers

display/i $pc shows disassembly always for the current instruction, in the console window.

To show disassembly for more instructions, prefix i with the number of instructions.

For example,

display/5i $pc

shows disassembly always for the next 5 instructions.

like image 197
nrz Avatar answered Oct 02 '22 09:10

nrz


A recent update (Feb 2017) to cgdb makes it possible to do this. You will need cgdb version 0.7.0 or newer. (At the time of writing this is the latest release). You may need to compile this from source yourself given how recent it is.

More details on adding disassembly support can be found here: https://github.com/cgdb/cgdb/issues/44

To view the disassembly in cgdb hit esc and type :set disenter.

To go back to the source (if available), repeat this, except type :set nodis.

like image 31
Sudo Bash Avatar answered Oct 02 '22 09:10

Sudo Bash