Thread: Why does GDB try to source headers that don't exist?

  1. #1
    Registered User
    Join Date
    May 2020
    Posts
    2

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

    I'm new to programming in c++ and learning to debug using GDB, so my apologies if the issue is obvious. But I've been struggling for a few days and decided to get some help.

    I compile my code using the following flags

    Code:
     g++ -Wall -g -O0 -lncursesw foo.cc bar.cc
    Then I step through my code in gdb and keep stepping to the standard library. I do not want to do this so I
    I edited my .gdbinit file to script and skip all files under /usr/include/c++/*. This works well.

    GBD also says directories /build/gcc/* are sources. I can check this from inside gdb with
    the info sources command.

    /build/gcc/*, let alone /build/ directories on my machine do not even exist. Why are they appearing as sources?

    Even GDB is telling me "No such file or directory" when I step.

    Code:
    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.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Because you did not build the file you are debugging!

    The person who built that binary file likely had the source code on their build machine.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    May 2020
    Posts
    2
    Thank you for your prompt reply!

    Your reply opens up a few more follow up questions, if I may. I would appreciative if you can answer them or point me to the right resource.

    Because you did not build the file you are debugging!
    Can you elaborate? I thought I was building everything. Are you referring to the ncurses library? It appears that file in question is the std::fstream Input/output stream class to operate on files, which I have the source code for.

    Last question, where was the /build/gcc/* directory information embedded?

    Last edited by brother-bilo; 05-01-2020 at 09:56 AM. Reason: I goofed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2014, 09:36 PM
  2. The name ___ does not exist...
    By Xfer in forum C# Programming
    Replies: 4
    Last Post: 01-08-2011, 12:24 PM
  3. Replies: 0
    Last Post: 06-08-2009, 05:33 PM
  4. Does this exist?
    By Kennedy in forum Tech Board
    Replies: 2
    Last Post: 11-23-2006, 03:04 AM
  5. including headers inside headers
    By kromozom in forum C++ Programming
    Replies: 5
    Last Post: 04-18-2005, 10:56 AM

Tags for this Thread