3

ADD : This link (https://stackoverflow.com/a/48287761/2554472) had the answer for my question (Mark Plotnick's answer). Different title, duplicate answer.

I'm using ddd(with gdb) to analyze a program(qemu).
Before the main() starts, there are some codes running using functions in glibc.
For example I want to see what libc_csu_init is doing(initializing static variables maybe..).
But since my qemu program is linked to release version of libc, I can't see the libc code.
How can I install debug info for libc and see the source code during debug? Do I have to install the debug version libc and compile qemu using that? or can I just install the debug version libc and see the libc source while running dbg?
By the way, if I do ldd qemu-system-aarch64, I can see a line below.

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2feafb3000)

this means it was compiled against glibc because the libc is under x86_64-linux-gnu directory, isn't it? Please correct me if I'm wrong.

Chan Kim
  • 5,177
  • 12
  • 57
  • 112
  • The method of installing debuginfo and source code varies with the GNU/Linux distribution. Which distribution and version do you have? – Mark Plotnick Feb 06 '21 at 11:41
  • I'm on ubuntu 16.04 and I found libc6-dbg package is already installed. – Chan Kim Feb 06 '21 at 13:34
  • On Ubuntu, debuginfo and source are in separate packages. You already have the debuginfo installed, likely done when gdb was installed. I wrote up instructions for how to install glibc source on Ubuntu 18.04 as an answer to a [similar question](https://stackoverflow.com/a/48287761/2554472); please see if it helps you. – Mark Plotnick Feb 06 '21 at 14:06
  • Thanks your linked worked for me! (but your similar question doesn't have a proper title, so I'll leave my question here.) Better yet, you can post your answer to my question (just show the link) so that I can select it and others who searched for this solution can go to your answer. – Chan Kim Feb 06 '21 at 14:38
  • 1
    Glad it worked. They don’t like link-only answers here. Can you mark your question as a duplicate of the other? That way your question will remain here (I agree it has a more useful title). – Mark Plotnick Feb 07 '21 at 02:19

0 Answers0