Issue
For some reason I reinstalled my OS(manjaro linux) yesterday, and installed gcc
and gdb
by pacman
, then I write a very small example program to make sure my environment is correct, because I am a beginner in linux and gdb. After compile,it went according to my expectations. Then I wanted to take a look at the STL source code through gdb, so I opened my gdb
with tui mode. Everything seemed normal at first, but my gdb can't step into ss.insert()
that I want to see, with [ No Source Available ] on the top side of the screen. And I've found the directory of the source file of operator<<
is different to the version that before reinstall OS, and /usr/shared/c++/
doesn't exist anymore!
This is the version information of GCC(g++)
and gdb
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Solution
Why gdb complain to me that No Source Available (with g++ -ggdb3)
Because you are stopped inside libstdc++
, which was built in a temporary directory (here /build/gcc/src/gcc-build/...
) and that directory is not present on your machine.
It is exceedingly unlikely that you actually need to look at the source of operator<<()
, but if you really do want to do that, install GCC sources, and use (gdb) directory
to point GDB to the relevant sources.
Answered By - Employed Russian Answer Checked By - David Goodson (WPSolving Volunteer)