skip to Main Content

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 through GLIBC 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:

  1. By default those shared libraries don’t have debug info embedded in the .so

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

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

2

Answers


  1. Chosen as BEST ANSWER

    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:

    #include <iostream>
    #include <vector>
    #include <map>
    #include <stdlib.h>
    #include <signal.h>
    #include <string>
    using namespace std;
    
    int main(){
            string s = "123";
            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;
            cout << s << endl;
            abort();
            //raise(3);
    }
    

    1. I installed the debug packages by this answer

    And by running

    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
    

    I saw those packages get installed.

    ========================================================================================================================
     Package                                      Arch              Version                      Repository            Size
    ========================================================================================================================
    Installing:
     gcc-debuginfo                                x86_64            4.8.5-44.el7                 debuginfo            195 M
     glibc-debuginfo                              x86_64            2.17-307.el7.1               debuginfo            9.5 M
     nss-softokn-debuginfo                        x86_64            3.44.0-8.el7_7               debuginfo            2.1 M
     yum-plugin-auto-update-debug-info            noarch            1.1.31-54.el7_8              os                    29 k
    Installing for dependencies:
     gcc-base-debuginfo                           x86_64            4.8.5-44.el7                 debuginfo            2.9 M
     glibc-debuginfo-common                       x86_64            2.17-307.el7.1               debuginfo            9.7 M
    

    It's interested that there is no something like libstdc++-debuginfo got installed, though libstdc++ shows in the "Missing separate debug info warnings". Could someone explain?


    1. On both servers, I compiled the test program with g++ -g -Wall test.cpp -std=c++11 and run gdb ./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 pressing n) when I press s.

    Server that install the debug infos:

    Breakpoint 1, main () at test.cpp:10
    10          string s = "123";
    (gdb) s
    std::allocator<char>::allocator (this=0x7fffffffe45b)
        at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/allocator.h:113
    113       allocator() throw() { }
    (gdb) s
    std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffe450, 
        __s=0x403b73 "123", __a=...)
        at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.tcc:212
    212     basic_string<_CharT, _Traits, _Alloc>::
    (gdb) s
    
    

    16          cout << s << endl;
    (gdb) n
    123
    17      abort();
    (gdb) s
    __GI_abort () at abort.c:52
    52  {
    (gdb) list
    47  
    48  
    49  /* Cause an abnormal program termination with core-dump.  */
    50  void
    51  abort (void)
    52  {
    53    struct sigaction act;
    54    sigset_t sigs;
    55  
    56    /* First acquire the lock.  */
    

    And that's the differences.


  2. So what’s the difference?

    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 without debuginfo-install.

    Update:

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

    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 of libstdc++ which are not part of the provided headers.

    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.

    Update 2:

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

    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).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search