Gdb has a list of directories to search for source files When debugging the executable using gdb, is there a command to list all the source files (static) used to build the executable. This is called the source path
Each time gdb wants a source file, it tries all the directories in the list, in the order they are present in the list, until it finds a file with the desired name. New to the project, have multiple source files used for compilation and some could be dynamic libraries, loaded at runtime You only need the file name with a function name to avoid ambiguity when there are identically named functions in different source files.
Conclusion gdb uses debug info stored in dwarf format to find source level info Each time gdb wants a source file, it tries all the directories in the list, in the order they are present in the list, until it finds a file with the desired name Note that the executable search path is not used for this purpose. Examining source files gdb can print parts of your program's source, since the debugging information recorded in the program tells gdb what source files were used to build it
When your program stops, gdb spontaneously prints the line where it stopped. Remarks if you want to see the list of all source files rather than information about the current source file, use the info sources command Examples below is a sample output of the info source command: