Fedora 35中使用gdb
工作学习在Fedora上一段时间,发现很多有用的工具,几乎可以完成所有需要的任务。工作原因需要学习数值计算,需要认真学习c++,可是容易内存泄漏之类,需要熟练掌握debug工具, 其中gun gdb是很流行的debug工具。GDB supports the following languages (in alphabetical order): Ada, Assembly, C/C++,D, Fortran, Go, Objective-C, OpenCL, Modula-2, Pascal, Rust。
但是gun gdb更新了新版本11.2,用法跟之前有所不同,启用了debuginfod,因为它可以透明地按需获取必要的调试数据和源代码,而不是处理混乱的调试包。上个版本跟glibc2.34还有兼容问题(?)
测试gdb的时候,显示Downloading -0.00 MB separate debug info for /lib64/libc.so.6, 但是下载始终没有进展,不得不终止进程。那是因为fedora自动安装了debuginfod, 可能网站地址不通,通过echo $DEBUGINFOD_URLS查看地址。
debuginfod的极简用法
1, 安装
2, 新建配置文件~/.gdbinit, 每次使用gdb都使用debuginfo, 可设置set debuginfod enabled on; 反之set debuginfod enabled off, 不设置的话每次都询问.
3, 如果需要使用debuginfod, 建议将DEBUGINFOD_URLS改为其他地址,比如https://debuginfod.archlinux.org/ 可以访问到。
另外,如果安装dnf debuginfo-install -y glibc时,报错“Could not find debugsource package for the following installed packages”,我是通过先更新系统(dnf update)再安装来解决的。
参考
https://www.oschina.net/news/136799/fedora-35-debuginfod
https://fedoraproject.org/wiki/Debuginfod
https://wiki.archlinux.org/title/Debuginfod
https://wiki.debian.org/Debuginfod
https://developers.redhat.com/blog/2019/10/14/introducing-debuginfod-the-elfutils-debuginfo-server#
本文来自博客园,作者:安然春夏,转载请注明原文链接:https://www.cnblogs.com/weixicai/p/15983716.html。测试只能证明程序有错误,而不能证明程序没有错误。你必须非常努力,才能看起来毫不费力。