Learn the tenth chapter, namely embeddedLinuxof debugging techniques. The main introduction is how to use the Development Board,Androidsimulator and some functions, tools (gdb,Gdbserveras wellKgdb) Debug EmbeddedLinuxkernel modules, executable programs, and shared libraries. 1, print kernel debug information:PRINTK. PRINTKfunction Usage andprintffunction is similar, exceptPRINTKfunction runs in kernel space,printffunctions run in user space,PRINTKfunction inprintk.cimplemented in the file. Regardless of the message level, all throughPRINTKthe message sent by the function is output to the log file (even if the message is output to the console, it is also output to the log file). You can query the log with the following command. 2and preventPRINTKfunction ReductionLinuxDrive performance. While usingPRINTKthe function can easily write messages to the log file or to the console. But a lot of usePRINTKfunction Frequent operation log Ask Kim or console device files can seriously affectLinuxDrive performance. Therefore, this requiresLinuxdrivers are used only during the development phasePRINTKfunction Output message, in the official releaseLinuxmay affect performance when driven.PRINTKfunction is removed. The best way is undoubtedly to useCthe compilation directives in the language. (#if,#else,#endif, etc.). If you do not want to usePRINTKoutput message, as long as the#ifin the1instead0you can not usePRINTKThe output message. 3, through the virtual file system (/pron) for data interaction. /pronA tool used to interact with the user space as a kernel space. /pronis a virtual file system, is a memory map, all read and write/pronis to read and write to the memory, so it can also be used as aLinuxa tool that drives interaction with user-space programs. /pronThe file system is mainly throughProc_dir_entry.read_procand theProc_dir_entry.read_writefunction pointer to set read and write/pronThe action handler function for the virtual file in the directory,Proc_dir_entryA struct represents a virtual directory or file. 4, Debugging Tools. LinuxThe system provides a class of tools that can line-trace the code of the program, respectively: for debugging user-space Programsgdb,Gdbserverand debugging kernel space programs.Kgdb. gdbDebugging a user-space program that tracks the program that is debugging user space, but it can only bePCon the test. GdbserverRemote Debug User space program, withGdbservercan test run on board, phone orAndroidthe program on the emulator. Gdbserveris one that can run onARMserver-side programs on the architecture, used on the Development BoardGdbserverOpen the program that you want to test, and then use the serial, Wired, or wireless network toPCto debug on. KgdbRemote Debugging Kernel program. It provides similarPRINTKfunction, which allows developers to directlyPCon the passGDBlink the target device.
Android Deep Explore Tenth chapter summary