norq
norq

Reputation: 1434

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.

Upvotes: 9

Views: 4468

Answers (3)

Sudo Bash
Sudo Bash

Reputation: 433

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.

Upvotes: 8

Tzu7
Tzu7

Reputation: 73

I am working on MacOS to defuse a binary bomb and find "gdb -tui" will be helpful. Than I found "cgdb" can make code colorful. But what we want to see is show disassembled code on the code window, the answer above only show the code line by line or only changeless lines.

Unfortunately, I find a post said that "the cgdb does not support assembly display (yet)." https://groups.google.com/forum/#!topic/cgdb-users/E-jZCJiBAQQ

   Sorry guys, cgdb does not support assembly display (yet).  It's a 
frequently requested feature, and when we get a little more time to 
work on cgdb we will probably add this. 
Starting cgdb with the -tui option is a bad idea -- the TUI (text user 
interface) is an alternative curses interface to gdb, not a part of 
cgdb.  It will not play nice with cgdb. 
Mike 
-- 
Mike Mueller

Well, it's 12/11/15, but it seems still couldn't show the assembly code on code window like gdb in tui mode.

Upvotes: 0

nrz
nrz

Reputation: 10580

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.

Upvotes: 6

Related Questions