Do we have a way to view assembly and c code both using gdb.
disassemble function_name shows only assembly, I was trying to find a way to easliy map c code to assembly.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can run gdb in Text User Interface (TUI) mode:
The
layout splitcommand divides the window into two parts – one of them displaying the source code, the other one the corresponding assembly.A few others tricks:
If you do not want to use the TUI mode (e.g. your terminal does not like it), you can always do:
which means print 12 instructions from current program counter address – this also works with the tricks above (demangling, stepping instructions, etc.).
The “x /12i $pc” trick works in both gdb and cgdb, whereas “layout split” only works in gdb.
Enjoy 🙂