How to debug standard c library functions like printf?

后端 未结 3 1841
鱼传尺愫
鱼传尺愫 2020-12-06 23:48

I wanted to debug printf function, so when I step inside the printf function (gdb debugger) it showed me this:

__printf (format=0x80484d0 \" my name is Adam\         


        
3条回答
  •  Happy的楠姐
    2020-12-07 00:49

    I think it's pretty clear. There is a place where the gdb expects the source code to be, so download glibc's source code and put it there. I think the error message contains the full path.

    If it's a linux distro it's fairly simple in fact because usually source packages are shipped too. Otherwise you need to find the source code yourself, note that it MUST be exactly the same that was used to compile the c library components, not just the same version because distributors often make changes to the sources.

提交回复
热议问题