Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get gdb tui assembly output to show instruction?

Tags:

c++

g++

gdb

I wanted to see the assembly output but found that in TUI, it would output function signature + offset: which is cool, except for the fact that I'm programming in C++ and the function signature is fully resolved so I get namespaces and template parameters which make the function sig 2 or more lines long. This gets truncated in the TUI of course so it doesn't even get to display the assembly instruction.

Is there any way to shorten, change the prefix (perhaps to a file/line format) or not output this prefix at all to the assembly instruction?

like image 920
Adrian Avatar asked Jun 05 '13 00:06

Adrian


1 Answers

Although there is no way at the moment to truncate this prefix, a work around is to set the focus to the assembly window using the focus asm command (if the asm window is not the one in focus) and then by using the right arrow key, you can scroll the window to the right which will eventually show the assembly output.

NOTE:

    This is a workaround, and still has problems as it will snap back to the first column when you step or scroll the CMD window. Also, it seems that when you do a next command, the entire prefix for the current command and it's assembly code is displayed (i.e. it is not truncated) in the ASM window, wrapping around the screen, buggering up the display. Though annoying, this can be fixed using Ctrl-L to refresh the screen.
    Also, scrolling the ASM window up and down can actually cause the debugger to crash. This is probably caused by a buffer overrun, so it is inadvisable to do this, and is possibly better to only show the assembly window only when needed and hide it when not.

Another workaround option as suggested by hasturkun is set print max-symbolic-offset N (you will have to scroll down to find it's description) which tells "gdb to only display the symbolic form of an address if the offset between the closest earlier symbol and the address is less than" N. Setting N to 1 would remove most of the prefixes, but keeps you guessing as to what instruction matches which source line.

like image 68
Adrian Avatar answered Oct 04 '22 21:10

Adrian