0

I need to debug a custom filebuf as some tests fail on libc++. I hence compiled and linked my program with -stdlib=libc++ -g using clang++-9 on Ubuntu and after installing libc++-9-dev and libc++api-9-dev.

When I then step into fstream::putback in GDB I get the error:

std::__1::basic_istream<char, std::__1::char_traits<char> >::putback (this=0x7fffffffd858, __c=101 'e') at ./libcxx/include/istream:1135
1135    ./libcxx/include/istream: File or directory not found.

I'm now confused: Where does this debug information come from? Running the preprocessing only shows, that putback is in /usr/lib/llvm-9/bin/../include/c++/v1/istream as confirmed by the verbose compiler output:

#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/llvm-9/bin/../include/c++/v1
 /usr/local/include
 /usr/lib/llvm-9/lib/clang/9.0.1/include
 /usr/include/x86_64-linux-gnu
 /usr/include

If I check /usr/lib/llvm-9/include/c++/v1/istream at the mentioned line 1135 it seems it matches.

But how can I tell GDB to use this file and why does it tell me ./libcxx/include/istream? I haven't found a single directory named libcxx on my system.

Flamefire
  • 5,313
  • 3
  • 35
  • 70
  • Do you link against the debug version and do you have the source code? Maybe [this question](https://stackoverflow.com/questions/8795871/how-to-link-against-debug-versions-of-libc-and-libstdc-in-gcc) helps... – user1810087 Dec 04 '19 at 09:02
  • I'm sure I linked against the debug version as symbols are showing. Not sure about the sources, I mean: I want to step through the headers which obviously must be there. I installed libc++ packages through `deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main` if that matters. I noticed I could "trick" it to work by using `dir ~/.local/libc++-help` and creating a symlink to the actual includes in that folder – Flamefire Dec 04 '19 at 09:41
  • I would build my own copy of libc++ in order to have debug info for files that are *not* headers. But you can tell gdb to search for files in other places. See `set directories` and `set substitute-path` commands of gdb. – n. m. could be an AI Dec 04 '19 at 09:55
  • See if `apt-get source libc++-9-dev` (or whatever package you installed to get libc++) works. It ought to download the exact source used to build the package and deposit it in your current working directory. (You may need to duplicate that `deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main` line as `deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main` and run `apt update`) – Mark Plotnick Dec 04 '19 at 16:27
  • I already did that but it doesn't has the correct paths: https://packages.debian.org/sid/amd64/libc++-9-dev/filelist – Flamefire Dec 04 '19 at 16:45

0 Answers0