简体   繁体   中英

Why does GDB try to list headers that don't exist?

I am a noob learning c++ and using gdb for debugging.

In a Makefile, I compile my individual objs using:

g++ -Wall -g -O0 -c foo.cc
g++ -Wall -g -O0 -c bar.cc
...

then compile the entire executable using:

g++ -Wall -g -O0 foo.o bar.o -lncursesw 

Then I use gdb to step through my code. It keeps stepping into the standard lib so I followed this script recommendation to skip over absolute file names that are prefixed with /usr/include/c++/* .

Now my issue

gdb tries to list files that are not on my machine. If from inside gdb (after start command) I execute info sources , there are a bunch of files that are prefixed with /build/gcc/* which are not on my machine. Why did GDB try to access them?

When stepping through, I cannot skip over the files since gdb will tell me "No such file or directory"

std::basic_ifstream<wchar_t, std::char_traits<wchar_t> >::basic_ifstream (this=0x7fffffffc680, __in_chrg=<optimized out>,
__vtt_parm=<optimized out>) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/fstream:518

/build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/fstream: No such file or directory.

Why did GDB source them?

When you execute start command, gdb starts running the program and stops at the beginning of main . Among other things, gdb loads all dynamically linked libraries that your program is linked with. One of them is libstdc++, standard C++ library. When it is loaded, gdb also loads it's debug info where files with /build/gcc/* prefix are present. If you are not going to debug libstdc++, there is no need to keep them on your machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM