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
.
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
and I learnt that:
Missing
glibc-2.17-157.el7_3.1.x86_64
will only prevent you from stepping throughGLIBC
itself.
from this answer Missing separate debuginfos, use: 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?
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;
}
compile with g++ -Wall -g test.cpp -std=c++11
.
I can step through libstdc++
both before and after installing those debug info packages. So what’s the difference?
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);
related question: Missing separate debuginfos
Solution Update:
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:
-
By default those shared libraries don’t have debug info embedded in the
.so
-
And the debug infos are stored in another directory where
gdb
would try to load from. -
Beyond that, I still need the source text files to
list
around.
2
Answers
Thanks to @Employed Russian's answer, now I know the exact differences.
Here's what I observe from 2 fresh install CentOS 7.2, one with debug info installed, one is not.
OS version:
CentOS Linux release 7.2.1511 (Core)
GDB version:
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-119.el7
Test program:
And by running
I saw those packages get installed.
It's interested that there is no something like
libstdc++-debuginfo
got installed, thoughlibstdc++
shows in the "Missing separate debug info warnings". Could someone explain?g++ -g -Wall test.cpp -std=c++11
and rungdb ./a.out
b main
,r
.On the server that installs the debug info, I can step into
string s = "123";
,abort
and just look around. On the other server, it just step over the line(act like pressingn
) when I presss
.Server that install the debug infos:
And that's the differences.
The difference is that you can now list sources of GLIBC (which is not the same as
libstdc++
) and step though them.Try
(gdb) list abort
with and withoutdebuginfo-install
.Update:
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.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 oflibstdc++
which are not part of the provided headers.IIRC, implementation of
std::basic_string<char, ...>
and various parts ofstd::basic_ios
fall into that category. You can runnm -C libstdc++.so.6 | egrep ' [TW] '
to see a list of such symbols.Update 2:
No.
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.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).