Книга: Embedded Linux Primer: A Practical, Real-World Approach
14.3.3. gdb User-Defined Commands
14.3.3. gdb User-Defined Commands
You might already realize that gdb looks for an initialization file on startup, called .gdbinit. When first invoked, gdb loads this initialization file (usually found in the user's home directory) and acts on the commands within it. One of my favorite combinations is to connect to the target system and set initial breakpoints. In this case, the contents of .gdbinit would look like Listing 14-10.
Listing 14-10. Simple gdb Initialization File
$ cat ~/.gdbinit
set history save on
set history filename ~/.gdb_history
set output-radix 16
define connect
# target remote bdi:2001
target remote /dev/ttyS0
b panic
b sys_sync
end
This simple .gdbinit file enables the storing of command history in a user-specified file and sets the default output radix for printing of values. Then it defines a gdb user-defined command called connect. (User-defined commands are also often called macros.) When issued at the gdb command prompt, gdb connects to the target system via the desired method and sets the system breakpoints at panic() and sys_sync(). One method is commented out; we discuss this method shortly in Section 14.4.
There is no end to the creative use of gdb user-defined commands. When debugging in the kernel, it is often useful to examine global data structures such as task lists and memory maps. Here we present several useful gdb user-defined commands capable of displaying specific kernel data that you might need to access during your kernel debugging.
- Файлы *.GDB изнутри
- Chapter 15. Graphical User Interfaces for Iptables
- Appendix A. Detailed explanations of special commands
- User-land setup
- Compiling the user-land applications
- User specified chains
- User-land states
- Commands
- Setting up user specified chains in the filter table
- 9.5.3. Маленький секрет User Agent
- users
- Дополнительные сведения о gdb