gdb: show corresponding lines in source and asm

百般思念 提交于 2020-01-30 06:52:08

问题


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?


回答1:


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>



来源:https://stackoverflow.com/questions/59697897/gdb-show-corresponding-lines-in-source-and-asm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!