Gdb tool debugging
Make your program stop on specified conditions. Examine what has happened, when your program has stopped. Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another. Those programs might be executing on the same machine as GDB native , on another machine remote , or on a simulator. News September 13th, GDB The latest version of GDB, version New --force-condition option for the '-break-insert' and '-dprintf-insert' commands.
New --force option for the '-break-condition' command. The '-file-list-exec-source-files' now accepts an optional regular expression to filter the source files included in the result.
The results from '-file-list-exec-source-files' now include a 'debug-fully-read' field to indicate if the corresponding source's debugging information has been partially read false or has been fully read true. TUI Improvements: Mouse actions are now supported. The mouse wheel scrolls the appropriate window.
Key combinations that do not have a specific action on the focused window are now passed to GDB. Many options have both long and short forms; both are shown in the following list. GDB also recognizes the long forms if you truncate them, so long as enough of the option is present to be unambiguous. Init files use the same syntax as command files see section Command files and are processed by GDB in the same way.
On some configurations of GDB, the init file is known by a different name these are typically environments where a specialized form of GDB may need to coexist with other forms, hence a different name for the specialized version's init file. These are the environments with special init file names:. It is safe to type the interrupt character at any time because GDB does not allow it to take effect until a time when it is safe. If you have been using GDB to control an attached process or device, you can release it with the detach command see section Debugging an already-running process.
If you need to execute occasional shell commands during your debugging session, there is no need to leave or suspend GDB; you can just use the shell command. The utility make is often needed in development environments. A symbol table works for a particular version of the program — if the program changes, a new table must be created.
Debug builds are often larger and slower than retail non-debug builds; debug builds contain the symbol table and other ancillary information. If you wish to debug a binary program you did not compile yourself, you must get the symbol tables from the author.
To let GDB be able to read all that information line by line from the symbol table, we need to compile it a bit differently. Normally we compile our programs as:. GDB offers a big list of commands, however the following commands are the ones used most frequently:. Compiles myprogram. You still get an a. Opens GDB with file a. You can run it directly r , pass arguments r arg1 arg2 , or feed in a file.
You will usually set breakpoints before running. Lists help topics help or gets help on a specific topic h breakpoints. GDB is well-documented. Stepping lets you trace the path of your program, and zero in on the code that is crashing or returning invalid input.
Lists 10 lines of source code for current line l , a specific line l 50 , or for a function l myfunction. Runs the program until next line, then pauses. If the current line is a function, it executes the entire function, then pauses. Runs the next instruction, not line.
If the current instruction is setting a variable, it is the same as next. Finishes executing the current function, then pause also called step out. Useful if you accidentally stepped into a function.
Breakpoints play an important role in debugging. They pause break a program when it reaches a certain point.
0コメント