Android Deep Explore tenth chapter

Source: Internet
Author: User

Tenth Chapter

For complex Linux drivers and libraries such as HAL, you need to debug them in a variety of ways, such as setting breakpoints, stepping through code, outputting debugging information, and so on.

The 1.PRINTK function runs in kernel space, and the printf function runs in user space.

Initialize Linux driver: Static int _init printk_demo_init (void);

Uninstall Linux driver: Static void _exit printk_demo_exit (void);

2. Using the PRINTK function makes it easy to write messages to a log file or console, but using the PRINTK function to manipulate log files or console device files can severely affect the performance of Linux drivers, so this requires the Linux driver to output messages using the PRINTK function only during the development phase. The PRINTK function displays the message in the console through the/dev/console device file, which 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 the message normally.

3. Data interaction: In Linux file systems,/proc is often used as a tool for data interaction between kernel space and user space. /proc is a virtual file system, so reading and writing/proc file systems is much faster than reading/writing/dev file systems. As a result, the/proc file system can also serve as a tool for Linux to interact with user-space programs. In Linux drivers, you can use kernel functions to create and delete virtual files in the/proc directory, as well as to establish and delete virtual directories. The/proc file system, like the/dev file system, also needs to set the action handler function that accesses the file, and the/dev file system through File_operations.read and File_ The Operations.write function pointer variable reads and writes the device file read-write action handler function. The Proc_dir_entry struct represents a virtual directory or file.

4. Debugging tools: The Android emulator can only use the Gdbserver debugger through port mapping, but the board can be connected to the Gdbserver through the serial ports in addition to the IP connection.

Summary: In addition to the traditional PRINTK function debugging technology, this chapter introduces other debugging techniques. When there are too many bugs or are difficult to find through the PRINTK function information, consider using KGDB to position the bug in step by step mode.

Android Deep Explore tenth chapter

Related Article

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.