This chapter focuses on Linux debugging techniques. Print Kernel debug information: The PRINTK,PRINTK function runs in kernel space, and the Linux kernel program can only use the PRINTK function to output debugging information. The PRINTK file consists of a 4-digit text file. 6: Output The message to the level of the console. 4: The default message log level. 1: The minimum value that can be set for the console log level. 7: Default value for console log level.
When you do not want to use the Prink output message, you also need to know about the variable parameter macros and do while. Data interaction through a virtual file system: The/proc is used in the Linux file system as a tool for data interaction between kernel space and user space. The/proc file system, like the/dev file system, needs to be set to access the file's action handler function. The/proc file system uses Proc_dir_entry.read_proc and Proc_dir_entry.read_write function pointers to set up read-write processing functions.
Debugging Tools: GDB, Gdbserver, and debug kernel space program kgdb. GDB can track programs that debug user space. Quit is used to exit the GDB debugging interface; list is used to list the code in the program. Remote debugging of the user space program with Gdbserver is a service-side program that can run on an arm architecture. First enter the Android emulator terminal and then enter the Data/local directory. The Android emulator can only use the Gdbserver debugger through port mapping.
Using KGDB to debug kernel programs remotely, KGDB provides a log output function similar to Prink functions, and allows developers to link target devices on a PC. The KGDB consists of two parts: the KGDB core and a set of link interfaces, which support serial TTY device connections and Ethernet connections. Before debugging the Linux kernel with KGDB, you need to configure the Linux kernel and set kernel parameters, using the Make Menuconfig command into the Linux kernel configuration menu.
Android Deep explore HAL and Driver Development-—— 10th Chapter