The tenth chapter debugging technology of Embedded Linux

Source: Internet
Author: User
Tags function prototype

The tenth chapter debugging technology of Embedded Linux

This chapter focuses on how to debug embedded Linux kernel modules, executable programs, and shared libraries using the Development Board, Android emulator, and Functions, tools (GDB, Gdbserver, and Kgdb).

1. Print kernel debug information: PRINTK

The use of the PRINTK function is similar to the printf function, but the PRINTK function runs in kernel space, while printf runs in user space, PRINTK function is implemented in the Printk.c file, and the path is/root/lernel/linux_kernel_ 2.6.36/kernel/printk.c. He has his own function prototype, where the value of the first parameter does not add information level, the default value is kern_warning. This function can either write log information to a log file or write log information to the console. The PRINTK file is a simple 4-digit text file with the default values as follows: 6 4 1 7, where 6 outputs the message to the level of the console, and only output information above that level is output to the console, 4 the default information log level. 1 The minimum value that the console log level can be set, which is the highest priority. 7 The default value of the console log level.

2. Prevent PRINTK functions from reducing Linux drive performance

Extensive use of the PRINTK function to frequently manipulate log files or console device files (/dev/console) can severely affect the performance of Linux-driven drivers. Therefore, the Linux driver is required to use the PRINTK function to output messages only during the development phase, and in the official release of Linux drivers, the PRINTK function that may affect performance is removed. Then the most convenient method is the C language of the compilation instructions.

(1) variable-parameter macros

(2) do{}while (0), the sub-cycle is executed only once to exit.

3. Data interaction through a virtual file system (/PROC)

/proc is not a real file system, but a memory map, which he can use as a tool for Linux to interact with user-space programs. You can use kernel functions to create and delete virtual files in the/proc directory, as well as to establish and delete virtual directories.

4. Debugging Tools

(1) Debugging the user-space program with GDB

(2) Remote debugging kernel program with KGDB

In short, the Linux kernel debugging has been considered difficult by many people, most people prefer to use the PRINTK function directly output debugging information, but also do not want to use a variety of commands to debug. Because it does not necessarily get more benefits. The debugging technique introduced in this chapter needs us to comprehend unceasingly according to own experience, becomes belongs to own best resources.

http://www.cnblogs.com/xxyue/

The tenth chapter debugging technology of Embedded Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.