Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: How to list all source files used for compilation

New to the project, have multiple source files used for compilation and some "could" be dynamic libraries, loaded at runtime. When debugging the executable using "GDB", is there a command to list all the source files (static) used to build the executable. Once I have all the source files, it's easy for me to set breakpoints, list functions etc. I couldn't find a command to do it in GDB (I'm sure there should be one). In DDD (gui based gdb), there is a Menu: File->List, which lists all the source files used and static libraries used for building the executable. Unfortunately, for command line based debugger (GDB), I couldnt find an equivalent command.

like image 715
Mike Avatar asked Apr 02 '14 19:04

Mike


People also ask

Which command is used to display the source code for the current file?

Use the "file" command. You must compile the program with debug information in order to see the source code while debugging.

What does GDB list do?

(gdb) help list List specified function or line. With no argument, lists ten more lines after or around previous listing. "list -" lists the ten lines before a previous ten-line listing. One argument specifies a line, and ten lines are listed around that line.

How do I list breakpoints in GDB?

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.


1 Answers

You are probably looking for info sources. info functions could also be helpful.

Don't forget you can do things like type break and then just press tab, which will list all relevant functions.

like image 136
dbrank0 Avatar answered Oct 06 '22 08:10

dbrank0