Read "Android Deep Exploration (Volume 1) HAL and drive development" some thoughts 10

Source: Internet
Author: User

Print kernel debug information: PRINTK

The PRINTK function is prototyped as follows:

asmlinkage int PRINTK (const char * fmt, ...)

The PRINTK file is a simple 4-digit text file that is the default for that file.

6 4 1 7

If you want to modify the contents of the PRINTK file, require that any information be output to the console, you can execute the following command on the Linux terminal.

#echo 8 >/PROC/SYS/KERNEL/PRINTK

The contents of the modified PRINTK file are as follows:

8 4 1 7

Execute a command like the following to compile and install the Printk_demo driver.

# sh build.sh

Prevent PRINTK functions from reducing Linux drive performance:

Modifies the Printk_demo driver code of the upper-section, defines a Pr_debug macro by compiling instructions, and controls whether the PRINTK function is invoked by modifying the conditional value of the compilation instruction.

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. The/proc file system behaves in a similar manner to the device file system (/dev). /proc is a virtual file system, which means that/proc is not a real file system, but a memory map.

Debugging Tools:

Debug the user space program with GDB, remotely debug the user space program with Gdbserver, and debug the kernel program remotely with KGDB.

When you find that there are too many bugs in a piece of code, it is difficult to find out through the PRINTK function output information, consider using KGDB to locate the bug in step by step mode.

Read "Android Deep Exploration (Volume 1) HAL and drive development" some thoughts 10

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.