Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let gdb print both source code corresponding disassembly together?

I compiled my code with "-g" command, and in gdb I can

"L" to list source code

"disass" to list assembly code.

But I wish to display like what I can see in windows visual studio, list one line of source code, list its corresponding disassembly(several lines), then another line of source code, and so on.

I guess gdb should support this, how to specify?

like image 369
Hind Forsum Avatar asked Oct 23 '25 10:10

Hind Forsum


1 Answers

You can mix source and assembly using the /m or /s flags to disassemble. Usually I think the former is what you want. So:

(gdb) disassemble/m main
like image 116
Tom Tromey Avatar answered Oct 26 '25 04:10

Tom Tromey