2008年1月17日木曜日
The GNU Debugger, usually called just GDB, is the standard debugger for the GNU software system. It is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, FreeBASIC, and Fortran.
History
Technical details
GDB offers extensive facilities for tracing and altering the execution of computer programs. The user can monitor and modify the values of programs' internal variables, and even call functions independently of the program's normal behavior.
GDB target processors (as of 2003) include: Alpha, ARM, AVR, H8/300, System/370, System 390, X86 and X86-64, IA-64 "Itanium", Motorola 68000, MIPS, PA-RISC, PowerPC, SuperH, SPARC, and VAX.
Lesser-known target processors supported in the standard release have included A29K, ARC, CRIS, D10V, D30V, FR-30, FR-V, Intel i960, M32R, 68HC11, Motorola 88000, MCORE, MN10200, MN10300, NS32K, Stormy16, V850, and Z8000. (Newer releases will likely not support some of these.)
GDB has compiled-in simulators for target processors even for lesser-known target processors such like M32R or V850.
GDB is still actively developed. As of early 2007, the focus is on adding "reversible debugging" support — allowing a debugging session to step backwards, much like rewinding a crashed program to see what happened.
Features
GDB offers a 'remote' mode often used when debugging embedded systems. Remote operation is when GDB runs on one machine and the program being debugged runs on another. GDB can communicate to the remote 'stub' which understands GDB protocol via Serial or TCP/IP.
The same mode is also used by KGDB for debugging a running Linux kernel on the source level with gdb. With kgdb, kernel developers can debug a kernel in much the same way as they debug application programs. It makes it possible to place breakpoints in kernel code, step through the code and observe variables. On architectures where hardware debugging registers are available, watchpoints can be set which trigger breakpoints when specified memory addresses are executed or accessed. kgdb requires an additional machine which is connected to the machine to be debugged using a serial cable or ethernet. On FreeBSD, it is also possible to debug using Firewire DMA.
Remote debugging
The debugger does not contain its own graphical user interface, and defaults to a command-line interface. Several front-ends have been built for it, such as DDD, Eclipse CDT, Xcode debugger, GDBtk/Insight and the "GUD mode" in GNU Emacs. These offer facilities similar to debuggers found in integrated development environments.
GDB does not correctly support C++ templates.
Some other debugging tools have been designed to work with GDB, such as memory leak detectors.
Examples of commands
This is an example GDB session on the example program in Stack trace:
The program is being run. After the cause of the segmentation fault is found, the program is edited to use the correct behavior. The corrected program is recompiled with GCC and then run.
An example session
Binary File Descriptor (libbfd) Bibliography
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿