When I attach gdb to a process that uses many source files, such as PHP, sometimes I want to set a breakpoint on line x of file y. How do I specify the file for gdb?
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.
gdb will work in an ordinary terminal window, and this is fine for debugging assembly code. For use with higher-level source code, it is more convenient to use gdb from within the emacs editor (a good one to learn!) or using a graphical front-end like xxgdb or /pkgs/gnu/bin/ddd. The basic commands remain the same.
The following registers are mentioned in the article: ESP (points to the top of the stack) EBP (is used as a reference when accessing local variables and arguments of the function) EIP (points to the address of the next instruction)
gdb ./test.exe
//test.exe is create by you program.b 117
//if only single file and line 117 is the function you want to run into
b filename.c:110
//filename:line NOr
//running the progn
c
//continues
//sign in the function you want to testuntil 1120
//if there is for
branch and you want to skip the brand, given 1120 is after the for
branchYou can shorten almost all commands in GDB up to the point where they remain unambiguous.
It's as simple as:
b filename.c:XYZ
See the documentation for more info.
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