Debugging technology of Embedded Linux

Source: Internet
Author: User

Print kernel debug information: PRINTK

The PRINTK function runs in kernel space, and the printf function runs in user space. The Linux kernel program can only output debug information using the PRINTK function.

Prevent PRINTK function Lower Linux Drive Performance

The Linux driver uses the PRINTK function to output messages only during the development phase. The official release of Linux drivers is to remove the PRINTK function that might affect performance. Take advantage of the compiler directives in C (#if, #else, #endif等)

via Virtual file system (/PROC) Interacting with Data

/proc is often used as a tool for data interaction between kernel spaces and user controls. The/proc file system behaves in a similar manner to the device file system/dev. /proc is not a real file system, but a memory map.

Proc_mkdir

Name: Virtual directory names

Parent: proc_dir_entry struct pointer for the parent directory of the virtual directory

Create_proc_entry

Name: Virtual file names

Mode: Access to virtual files, equivalent to Linux ask price access rights

Parent: The proc_dir_entry struct pointer to the parent directory of the virtual file.

Create_proc_read_entry

Name: Virtual file names

Mode: Virtual file access, equivalent to the Linux ask price access rights.

Base: proc_dir_entry struct pointer to the parent directory of the virtual file.

Read_proc: A function pointer that handles read actions.

Data: Used for the virtual file system.

Remove_proc_entry

Name: The names of the virtual files to be deleted

Parent: proc_dir_entry struct pointer to the parent directory of the virtual file

Debugging Tools

These tools can track program code line by row

1. Debugging the user-space program with GDB

A program that tracks debugging user space. Can only be tested on a PC

2. Remote debugging of user space programs with Gdbserver

Test the program that runs on the Development Board, mobile phone, or Android emulator. Server-side programs that can run on the ARM architecture

3. Remote Debug kernel program with KGDB

Provides a log output function similar to the PRINTK function, allowing developers to connect target devices directly to the PC via GDB.

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.