Where are the debug symbols for libstdc++6?

Asked by John Steele Scott

I would like to install the debug symbols for the libstdc++.so.6 which is installed on my system.

$ file /usr/lib/x86_64-linux-gnu/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: symbolic link to libstdc++.so.6.0.28

$ file /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=48f1a714f64ac85caa1496bcb14275c8ff0aeace, stripped

$ dpkg -S /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
libstdc++6:amd64: /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28

$ sudo apt-get install libstdc++6-dbgsym
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libstdc++6-dbgsym
E: Couldn't find any package by regex 'libstdc++6-dbgsym'

$ dpkg -l libstdc++6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-====================-============-=================================
ii libstdc++6:amd64 10-20200411-0ubuntu1 amd64 GNU Standard C++ Library v3

Google shows there was a libstdc++6-dbgsym in xenial, and I see Debian has one in sid, but there doesn't seem to be one in focal?

I know there is a lib64stdc++6-10-dbg, but AFAICS that provides a debug build of libstdc++, rather than debugging symbols for the release build.

$ file /usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.28
/usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.28: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=5f7bf3ed39f2aaa5e5ff856cc685d6f2f1f62258, with debug_info, not stripped

The different build ID suggests that would not be useful against a core produced while running against the non-debug package.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-10 Edit question
Assignee:
No assignee Edit question
Solved by:
Kai Kasurinen
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

If you look at https://launchpad.net/ubuntu/+source/gcc-10 and https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/binutils/+build/19150412 you will see that the two package mentioned by you do stem from the same build job.

Revision history for this message
John Steele Scott (toojays) said :
#2

Thanks Manfred, but I don't see what I'm looking for. I see no libstdc++*dbgsym.

Can you point me at the package which contains debug symbols for the release build of libstdc++?

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

There is no separate package with debug symbols for libstdc++.so.6, but a different copy of the shared library with debug information included.
see e.g. chapter "Versioned C++" in https://randomascii.wordpress.com/2013/01/08/symbols-on-linux-part-one-g-library-symbols/

I do not know what exactly you want to achieve, but one possibility to have libstdc++ debug information available for a program is
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.28 ./myprogram

Revision history for this message
John Steele Scott (toojays) said :
#4

Hi Manfred, yes I understand what is in the libstdc++6-dbg packages. To make use of those I need to be running my program against those packages.

What I am looking for is a way to be able to get useful debug information in libstdc++ for programs which are running against the regular/production build of that library.

E.g.
1) System configured to allow me to get access to core files, rather than apport eating them.
$ cat /proc/sys/kernel/core_pattern
core-%e-%p

2) C++ program that breaks in libstdc++:
$ cat broken.cpp
#include <sstream>

int main ()
{
  std::ostringstream os;
  char *buffer = nullptr;
  os.write(buffer, 4096);
  return 0;
}

3) It crashes, leaves behind a core:
$ file core-broken-362553
core-broken-362553: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), SVR4-style, from './broken', real uid: 1000, effective uid: 1000, real gid: 1000, effective gid: 1000, execfn: './broken', platform: 'x86_64'

4) Look at the core in gdb. No line numbers or function arguments in libstdc++:
(gdb) bt
#0 0x00007fda1c03e3b0 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007fda1c030357 in std::ostream::write(char const*, long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x0000563707d15220 in main () at broken.cpp:7

By comparison, if I am debugging a similar scenario on CentOS 7, gdb kindly tells me:
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.5.x86_64 libgcc-4.8.5-39.el7.x86_64 libstdc++-4.8.5-39.el7.x86_64

And once I have run that command, gdb gives me symbols in the backtrace, like:
(gdb) bt
#0 to_int_type (__c=@0x0: <error reading variable>) at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/char_traits.h:285
#1 std::basic_streambuf<char, std::char_traits<char> >::xsputn (this=0x7ffffa3c5cf8, __s=0x0, __n=4096)
    at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/streambuf.tcc:98
#2 0x00007f7089589402 in sputn (__n=4096, __s=0x0, this=<optimized out>) at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/streambuf:451
#3 _M_write (__n=4096, __s=0x0, this=0x7ffffa3c5cf0) at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/ostream:313
#4 std::ostream::write (this=0x7ffffa3c5cf0, __s=0x0, __n=4096) at /usr/src/debug/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/ostream.tcc:196
#5 0x00000000004007b0 in main () at broken.cpp:7

No need to reproduce the crash against special debug builds of libraries.

It is unfortunate that Ubuntu does not support this method of debugging.

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

I searched the launchpad pages for gcc-10 and it seems to me that the files which you want, simply don't exist for Ubuntu focal.
For Ubuntu groovy the package libstdc++6-dbgsym does exist.

Suggestion:
There are PPAs with versions that include -dbgsym packages, see https://launchpad.net/ubuntu/+ppas?name_filter=gcc-10 for candidates.

Revision history for this message
Kai Kasurinen (kai-kasurinen) said :
#6
Revision history for this message
Best Kai Kasurinen (kai-kasurinen) said :
#7
Revision history for this message
John Steele Scott (toojays) said :
#8

Thanks Kai.

I can confirm these new packages solve the problem for the testcase I described in comment 4.

Sorry for the late reply.

Revision history for this message
John Steele Scott (toojays) said :
#9

Thanks Kai Kasurinen, that solved my question.