How to make cgdb show assembly code?
Asked Answered
S

3

9

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.

Squire answered 4/2, 2012 at 17:38 Comment(0)
A
7

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.

Alliteration answered 29/3, 2017 at 17:23 Comment(0)
A
6

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.

Accusal answered 9/3, 2013 at 13:56 Comment(2)
This sorta defies the purpose of cgdb. Why would one use it instead of plain gdb to debug sourceless applications if this functionality is achieved only via a gdb command?Electroanalysis
There is a way to do this now with :set dis (as of version 0.7.0). See my answer.Alliteration
S
0

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.

Swanger answered 30/10, 2016 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.