加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

调试C运行时

发布时间:2020-12-16 09:38:09 所属栏目:百科 来源:网络整理
导读:我想详细了解使用GDB在main()之前和之后发生的事情.仅仅用-g重新编译glibc并链接它就足够了吗? 解决方法 如果你想使用调试器,你可以这样使用GDB: 安装`glibc`包的debug-info(here是使用Fedora的方法,我不知道其他的发行版) 或将GDB指向一致的调试文件目录
我想详细了解使用GDB在main()之前和之后发生的事情.仅仅用-g重新编译glibc并链接它就足够了吗?

解决方法

如果你想使用调试器,你可以这样使用GDB:

>安装`glibc`包的debug-info(here是使用Fedora的方法,我不知道其他的发行版)

>或将GDB指向一致的调试文件目录:

(gdb) show debug-file-directory
The directory where separate debug symbols are searched for is "/usr/lib/debug".
(gdb) set debug-file-directory ...

(在我的系统中是/usr/lib/debug/lib64/libc-2.14.so.debug)

>告诉GDB在你的`main`之前显示回溯:

(gdb) show backtrace past-entry
Whether backtraces should continue past the entry point of a program is off.
(gdb) set backtrace past-entry on

>那么你应该看看你在寻找什么,并浏览它:

(gdb) where
#0  main () at test.c:4
#1  __libc_start_main (main=0x40050f <main>,argc=1,...) at libc-start.c:226
#2  _start ()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读