Location specifications (debugging with gdb)by contrast, location specs you type will many times omit some of these attributes A substitution rule specifies how to rewrite source directories stored in the program’s debug information in case the sources were moved to a different directory between compilation and debugging. For example, it is customary to specify just the source line number to mean a line in the current source file, or specify just the basename of the file, omitting its directories
In other words, a location spec is usually incomplete, a kind of blueprint, and gdb needs. In addition to the source path, gdb provides a set of commands that manage a list of source path substitution rules Gdb stands for gnu project debugger and is a powerful debugging tool for c (along with other languages like c++)
Gdb operates on executable files which are binary files produced by the compilation process For demo purposes, the example below. 21 i can set a breakpoint in main and debug the code with the correct source code, but i don't know where gdb is taking the source code from The source code is not present in cwd (current working directory)
How do i find from which location gdb is taking the code? How gdb finds source code to find the sources gdb parses.debug_info section to find all dies with tag dw_tag_compile_unit Several gdb commands accept arguments that specify a location of your program's code For that reason, locations are also known as linespecs.
Spend a few hours to learn one so you can avoid dozens of hours of frustration in the future This is a quick guide, more information here A breakpoint is a special location in the program, and gdb will pause the execution of the program once this location is reached A breakpoint is identified by a file name and a line number (like hello_world.c:10, meaning the 10th line in file hello_world.c)