为gdb安装缺少的调试信息包后,该怎么办? [英] What can I do differently after I install those missing debug info packages for gdb?

查看:68
本文介绍了为gdb安装缺少的调试信息包后,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经全新安装了 CentOS Linux版本7.2.1511(核心),并且 gdb 版本是 GNU gdb(GDB)Red Hat Enterprise Linux 7.6.1-119.el7 .

I have a fresh install CentOS Linux release 7.2.1511 (Core), and gdb verison is GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-119.el7.

我看到了缺少的单独的debuginfos警告

I saw the Missing separate debuginfos warning

Missing separate debuginfos, use: debuginfo-install glibc-2.17-307.el7.1.x86_64 libgcc-4.8.5-44.el7.x86_64 libstdc++-4.8.5-44.el7.x86_64

我了解到:

缺少 glibc-2.17-157.el7_3.1.x86_64 只会阻止您逐步浏览 GLIBC 本身.

Missing glibc-2.17-157.el7_3.1.x86_64 will only prevent you from stepping through GLIBC itself.

从此答案缺少单独的调试信息,请使用:debuginfo-install glibc-2.17-157.el7_3.1.x86_64

现在,我已经成功安装了所有这些调试信息.但是我看不出有什么区别.现在,安装了这些额外的软件包后,我可以做什么其他事情?

Now I've succeeded installing all those debug infos pacakges. But I can't see a difference. What are the additionals things that I can do now with those extra packages installed?

以这个C ++程序为例:

Take this C++ program as an example:

#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
        vector<int> a = {1,2,3};
        vector<int> b = {4,5,6};
        map<int, vector<int>> m = {{1, a}, {2, b}};
        cout << m[1][0] << endl;
        cout << m[2][0] << endl;
}

使用 g ++ -Wall -g test.cpp -std = c ++ 11 进行编译.

在安装这些调试信息包之前和之后,我可以逐步完成 libstdc ++ .那有什么区别?

I can step through libstdc++ both before and after installing those debug info packages. So what's the difference?

我了解的逐步操作是,例如,当我在此行中按 s 时, cout<<m [1] [0]<<endl; gdb 显示我在 stl_map.h:481 中:

What I understand step through is that for example when I press s at this line cout << m[1][0] << endl;, gdb shows that I am in stl_map.h:481 :

std::map<int, std::vector<int, std::allocator<int> >, std::less<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int> > > > >::operator[](int&&) (this=0x7fffffffe3f0, 
    __k=<unknown type in /root/a.out, CU 0x0, DIE 0x7b70>) at /usr/include/c++/4.8.2/bits/stl_map.h:481
481     iterator __i = lower_bound(__k);

相关问题:缺少单独的调试信息

解决方案更新:

阅读此如何使用libc的调试版本后,我弄清楚了细节.我还了解了单独的调试信息文件的工作方式,并尝试了通过此

I figured out the details after reading this How to use debug version of libc. I also read about how separate debug info files work and tried manually redirecting gdb to find source files with set substitute-path by this answer.

最后,我了解了事物如何协同工作:

And eventually I learn how the things work together:

  1. 默认情况下,这些共享库的 .so

并且调试信息存储在另一个目录中,该目录将尝试从中加载 gdb .

And the debug infos are stored in another directory where gdb would try to load from.

除此之外,我仍然需要源文本文件到 list 周围.

Beyond that, I still need the source text files to list around.

推荐答案

那有什么区别?

不同之处在于,您现在可以列出GLIBC的来源(与 libstdc ++ 不同)并逐步浏览它们.

The difference is that you can now list sources of GLIBC (which is not the same as libstdc++) and step though them.

尝试(gdb)列表中止,带和不带 debuginfo-install .

更新:

我可以列出libstdc ++的源代码"吗?并逐步执行"没有那些包裹?

Am I able to "list soucre of libstdc++" and "step through them" without those packages?

libstdc ++ 与GLIBC的不同之处在于,其大部分功能由模板提供,这些模板包含在您自己的资源中.当您逐步执行时/usr/include/c ++/4.8.2/bits/stl_map.h ,这完全是发生的事情.

libstdc++ is different from GLIBC in that significant portion of its functionality is provided by templates, which are included into your own sources. When you step through e.g. /usr/include/c++/4.8.2/bits/stl_map.h, that is exactly what's happening.

但是您可能仍然需要 debuginfo-install libstdc ++-4.8.5-44.el7.x86_64 才能列出并逐步遍历 libstdc ++ 的各个部分提供的标头中的 not 部分.

But you may still need to debuginfo-install libstdc++-4.8.5-44.el7.x86_64 to be able to list and step though parts of libstdc++ which are not part of the provided headers.

IIRC, std :: basic_string< char,...> 的实现以及 std :: basic_ios 的各个部分都属于该类别.您可以运行 nm -C libstdc ++.so.6 |.egrep'[TW]'查看此类符号的列表.

IIRC, implementation of std::basic_string<char, ...> and various parts of std::basic_ios fall into that category. You can run nm -C libstdc++.so.6 | egrep ' [TW] ' to see a list of such symbols.

更新2:

那些已安装的调试信息仅仅是glibc和gcc源文本文件吗?

Are those installed debug infos just glibc and gcc soure text files?

否.

调试信息是一组文件,允许调试器将特定偏移量与库的 .text 与在该偏移量处生成机器代码的源代码相关联.它还对参数和变量的类型,给定函数内局部变量的位置等进行编码.您可以在此处阅读更多信息..

The debug info is a set of files which allows debugger to associate a particular offset into the .text of the library with the source code that produced machine code at that offset. It also encodes types of parameters and variables, location of local variables within a given function, and more. You can read more about debug info here.

某些系统上,调试信息包包括该库的源代码,但这在Linux系统上并不通用,并且不是调试信息包的主要目的(如果需要的话,可以安装 source 包).

On some systems, debug info package also includes the source of the library, but that isn't universal across Linux systems, and isn't the main purpose of the debug info package (you can install source package if all you wanted are the sources).

这篇关于为gdb安装缺少的调试信息包后,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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