如何调试像 printf 这样的标准 c 库函数? [英] How to debug standard c library functions like printf?

查看:21
本文介绍了如何调试像 printf 这样的标准 c 库函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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") at printf.c:28
28  printf.c: No such file or directory.

What is the meaning of this?

And when I again started step then there are a lot more statements like this.

Please help me to understand this.

解决方案

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.

这篇关于如何调试像 printf 这样的标准 c 库函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆