Andriod Deep Exploration of-hal and Driver Development Tenth Chapter reading notes and a little experience

Source: Internet
Author: User

Print kernel debug information: PRINTK

The use of the PRINTK function is similar to the printf function except that the PRINTK function runs in kernel space and the printf function runs in user space.

The Prink function is implemented in the Printk.c file, and the path to the file is as follows:

/root/kernel/linux_kernel_2.6.36/kernel/printk.c

The PRINTK function must have at least one parameter (format string) if the format string contains placeholders (%d,%s, etc.), followed by a number of parameters such as placeholder typeface, so that one by one corresponds to the incoming PRINTK function.

The PRINTK file is a simple 4-digit text file with the default values for the text, such as: 6 4 1 7

The meanings of these 4 numbers are as follows:

6: Output The message to the level of the console. Only high and this level of output information will be output to the console.

4: The default message log level. If you do not specify a log level in the PRINTK function, the value is used as the default level.

1: The minimum value (highest priority) at which the console log level can be set.

7: Default value for console log level.

Prevent PRINTK functions from reducing Linux drive performance

The PRINTK function displays messages in the console through the/dev/console device file. The device file only works under the console of the character interface, so the PRINTK function is only used on the console of the character interface to output messages normally.

If you do not want to use the PRINTK output message, simply change the 1 in #if1 to 0.

Data interaction through a virtual file system (/PROC)

The Create_proc_read_entry function is internally implemented by calling the Create_proc_entry function.

The read and write of a Linux file is determined by attributes

Before deleting a virtual directory, delete the virtual files in the virtual directory

Debugging Tools

Debugging a user-space program with GDB

Remote debugging of user space programs with Gdbserver

debugging kernel programs remotely with KGDB

Experience: Linux kernel debugging porting is considered very difficult by many people. Most people prefer to use the PRINTK function to output debugging information directly, or to use various commands for debugging. Because doing so does not necessarily make for more benefits. In addition to the introduction of the PRINTK function debugging technology, but also introduced other debugging techniques. Although not all of these debugging techniques can be used, but it is very necessary to understand.

My blog address: http://home.cnblogs.com/u/jie617530/

Andriod Deep Exploration of-hal and Driver Development Tenth Chapter reading notes and a little experience

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.