When running gdb in TUI mode, showing source and assembly, is there an option to highlight the set of instructions mapping to a selected source line?
-
1Don't think so, but maybe you can script it. Especially for optimized code the relation might be unclear. godbolt can do that if all you want is static analysis.Jester– Jester2020-01-11 19:36:05 +00:00Commented Jan 11, 2020 at 19:36
-
@Jester: Thanks, I will take a look at godbolt. I am debugging using some btraces recorded in gdb, and wanted a source/asm mapping to make the process go a little faster.user001– user0012020-01-11 19:40:21 +00:00Commented Jan 11, 2020 at 19:40
Add a comment
|
1 Answer
You can partially do it with GDB Dashboard.
https://github.com/cyrus-and/gdb-dashboard
From below screenshot you can see that the 1st call to operator<< in this line of code:
std::cout << a << std::endl;
is mapped to 4 assembly instructions:
0x00000000004011a2 main()+28 mov -0x4(%rbp),%eax
0x00000000004011a5 main()+31 mov %eax,%esi
0x00000000004011a7 main()+33 mov $0x404060,%edi
0x00000000004011ac main()+38 callq 0x401070 <_ZNSolsEi@plt>
They are highlighted with green color in Assembly section.
You can move to 2nd call to operator<< in the same line executing ni command several times and you will see the second mapping to 3 assembly instructions:
0x00000000004011b1 main()+43 mov $0x401030,%esi
0x00000000004011b6 main()+48 mov %rax,%rdi
0x00000000004011b9 main()+51 callq 0x401050 <_ZNSolsEPFRSoS_E@plt>
2 Comments
user001
By the way, do you know how to shrink the console section? As I enter commands, it keeps growing, pushing all the other sections of the dashboard off the window.
ks1322
This is probably configurable. Try
help dashboard command or dashboard wiki on github: github.com/cyrus-and/gdb-dashboard/wiki.