Print kernel debug information: PRINTK
The PRINTK function runs in kernel space, and the printf function runs in user space. The Linux kernel program can only output debug information using the PRINTK function.
Prevent PRINTK function Lower Linux Drive Performance
The Linux driver uses the PRINTK function to output messages only during the development phase. The official release of Linux drivers is to remove the PRINTK function that might affect performance. Take advantage of the compiler directives in C (#if, #else, #endif等)
via Virtual file system (/PROC) Interacting with Data
/proc is often used as a tool for data interaction between kernel spaces and user controls. The/proc file system behaves in a similar manner to the device file system/dev. /proc is not a real file system, but a memory map.
Proc_mkdir
Name: Virtual directory names
Parent: proc_dir_entry struct pointer for the parent directory of the virtual directory
Create_proc_entry
Name: Virtual file names
Mode: Access to virtual files, equivalent to Linux ask price access rights
Parent: The proc_dir_entry struct pointer to the parent directory of the virtual file.
Create_proc_read_entry
Name: Virtual file names
Mode: Virtual file access, equivalent to the Linux ask price access rights.
Base: proc_dir_entry struct pointer to the parent directory of the virtual file.
Read_proc: A function pointer that handles read actions.
Data: Used for the virtual file system.
Remove_proc_entry
Name: The names of the virtual files to be deleted
Parent: proc_dir_entry struct pointer to the parent directory of the virtual file
Debugging Tools
These tools can track program code line by row
1. Debugging the user-space program with GDB
A program that tracks debugging user space. Can only be tested on a PC
2. Remote debugging of user space programs with Gdbserver
Test the program that runs on the Development Board, mobile phone, or Android emulator. Server-side programs that can run on the ARM architecture
3. Remote Debug kernel program with KGDB
Provides a log output function similar to the PRINTK function, allowing developers to connect target devices directly to the PC via GDB.
Debugging technology of Embedded Linux