如何调试标准的C库函数,例如printf? [英] How to debug standard c library functions like printf?

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

问题描述

我想调试printf函数,所以当我进入printf函数(gdb调试器)时,它显示了以下信息:

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.

这是什么意思?

当我再次开始执行步骤时,会有更多这样的语句。

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

请帮助我理解这一点。

推荐答案

我认为这很清楚。 gdb 在某个地方期望源代码存在,因此请下载 glibc 的源代码并将其放在此处。我认为该错误消息包含完整路径。

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.

如果它是Linux发行版,则实际上相当简单,因为通常也会附带源代码包。否则,您需要自己查找源代码,请注意,该源代码必须与用于编译c库组件的源代码完全相同,而不仅仅是相同版本,因为发行商经常会对源代码进行更改。

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.

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

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