How do I tell GDB in *nix to search for source files inside a single directory recursively? For example:
I would need to specify to GDB that all the source files are located in 'a'(parent directory) which GDB should use as a reference and search for source files recursively while debugging a program.
GDB has a list of directories to search for source files; 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.
The source path specifies the directories where the C and C++ source files are located. If you are debugging a user-mode process on the computer where the executable file was built, and if the source files are still in their original location, the debugger can automatically locate the source files.
You can see these breakpoints with the GDB maintenance command `maint info breakpoints' . Using the same format as `info breakpoints' , display both the breakpoints you've set explicitly, and those GDB is using for internal purposes. Internal breakpoints are shown with negative breakpoint numbers.
Use the "file" command. You must compile the program with debug information in order to see the source code while debugging.
What you need for this is the command set substitute-path.
(gdb) set substitute-path /usr/src/include /mnt/include
Only available in recent versions (6.6+) of gdb, though.
Or you can do something like this, for debugging program prog
with source in directory srcdir
:
gdb `find srcdir -type d -printf '-d %p '` prog
I think it's a more direct answer to your question. Also useful if your executable doesn't contain the compilation directories and/or you don't have version 6.6+ of gdb.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With