For complex Linux drivers and libraries such as HAL, you need to test them in a variety of ways. such as setting breakpoints, gradually tracking code, output debugging information and so on. This chapter focuses on how to debug embedded Linux kernel modules, executable programs, and shared libraries using the Development Board, Android emulator, and some functions and tools.
1. Print kernel debug information: PRINTK
The function is similar to the printf function, except that the PRINTK function runs in kernel space and the printf function runs in user space. Function prototypes: Asmlinkage PRINTK (const char *FMT, ... The first parameter represents a format string. The following is a mutable parameter.
2. Prevent the PRINTK function from reducing Linux drive performance.
Although you can easily write messages to a log file or console using the PRINTK function. However, extensive use of the PRINTK function to frequently manipulate log files or console device files can severely affect the performance of Linux drivers. As a result, Linux can use the PRINTK function to output messages during the development phase, which is removed when the Linux driver is officially released. The output of the PRINTK function can be controlled by compiling instructions in the C language.
3. Data interaction through a virtual file system (/PROC)
In Linux file systems,/proc is often used as a tool for data interaction between kernel space and user space. /proc is a virtual file system, which is a memory map. All operations on/proc are read and write to memory. So the speed of reading and writing/proc files is faster than the device file system/dev. There are four functions:
Proc_mkdir
Create_proc_entry
Create_proc_read_entry
Remove_proc_entry
4. Debugging Tools
(1). Debug the user-space program with GDB.
(2). Remote Debug User space program with Gdbserver
(3). Remote Debug Kernel program with KGDB
Software 1308 class 31st Zhang Fan Blog Park address: http://home.cnblogs.com/u/sxauzzz/
Android Deep Explore (Vol. 1) HAL and Driver development tenth chapter Embedded Linux Debugging Technology reading notes