2

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?

2
  • 1
    Don'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. Commented 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. Commented Jan 11, 2020 at 19:40

1 Answer 1

2

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>

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

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.
This is probably configurable. Try help dashboard command or dashboard wiki on github: github.com/cyrus-and/gdb-dashboard/wiki.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.