Android Deep Explore (Vol. 1) HAL and Driver development tenth chapter Embedded Linux Debugging Technology reading notes

Source: Internet
Author: User

For complex Linux drivers and libraries such as HAL, you need to test them in a variety of ways. such as setting breakpoints, gradually tracking code, output debugging information and so on. This chapter focuses on how to debug embedded Linux kernel modules, executable programs, and shared libraries using the Development Board, Android emulator, and some functions and tools.

1. Print kernel debug information: PRINTK

The function is similar to the printf function, except that the PRINTK function runs in kernel space and the printf function runs in user space. Function prototypes: Asmlinkage PRINTK (const char *FMT, ... The first parameter represents a format string. The following is a mutable parameter.

2. Prevent the PRINTK function from reducing Linux drive performance.

Although you can easily write messages to a log file or console using the PRINTK function. However, extensive use of the PRINTK function to frequently manipulate log files or console device files can severely affect the performance of Linux drivers. As a result, Linux can use the PRINTK function to output messages during the development phase, which is removed when the Linux driver is officially released. The output of the PRINTK function can be controlled by compiling instructions in the C language.

3. 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. /proc is a virtual file system, which is a memory map. All operations on/proc are read and write to memory. So the speed of reading and writing/proc files is faster than the device file system/dev. There are four functions:

Proc_mkdir

Create_proc_entry

Create_proc_read_entry

Remove_proc_entry

4. Debugging Tools

(1). Debug the user-space program with GDB.

(2). Remote Debug User space program with Gdbserver

(3). Remote Debug Kernel program with KGDB

Software 1308 class 31st Zhang Fan Blog Park address: http://home.cnblogs.com/u/sxauzzz/

Android Deep Explore (Vol. 1) HAL and Driver development tenth chapter Embedded Linux Debugging Technology reading notes

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.