Linux Debug Switch Dev_dbg__linux

Source: Internet
Author: User
Tags dmesg

1, recently in the write I2C under the EEPROM driver, but found that using the I2c_new_probed_device function can not enumerate to the device, so want to debug the function (in driver/i2c/i2c-core.c), see some of the debugging information is as follows:

I2c_new_probed_device (...)
{
...
if (addr_list[i] = = i2c_client_end) {
dev_dbg (&adap->dev, "probing failed, no device found\n");
return NULL;
}
...
}

However, the driver module is loaded and the debugging information is not printed (the debug information is also not found after executing the DMESG command).

2, list the dev_dbg source code realization: (Include/linux/device.h)

#if defined (DEBUG)
#define DEV_DBG (Dev, format, arg ...) \
DEV_PRINTK (kern_debug, Dev, format, # # ARG)

Problem, just define the debug macro before referencing the header file #include/linux/device.h.

Modify the code in Include/linux/i2c.h as follows:

#define DEBUG/* Add for DEBUG EEPROM * *
#include <linux/device.h>/* for struct device * *
#undef Debug/* Add for DEBUG EEPROM * *

After loading the drive module, there is no debug information to print out. The following figure:


But after executing the DMESG command probing failed, no device found has been able to print out the following figure:

That's why


    But after this is turned on, it is not smooth output information, because PRINTK has the default level of information.
    linux/kernel file
#define     KERN_EMERG      "<0>"     
#define     KERN_ALERT     "<1>"     
#define     KERN_CRIT     "<2 > "    
#define     KERN_ERR    " <3> " &NBSP;&NBSP;&NBSP;&NBSP
#define     KERN_WARNING     "<4>" &NBSP;&NBSP;&NBSP;&NBSP
#define     KERN_NOTICE     "<5>" &NBSP;&NBSP;&NBSP;&NBSP
#define     KERN_INFO     "<6>"   &NBSP;&NBSP;&NBSP
#define     KERN_DEBUG     "<7>"    &NBSP;&NBSP
You can see that Kern_debug is the lowest level.

2. modify file Kernel/printk file

#define DEFAULT_MESSAGE_LOGLEVEL 4

#define MINIMUM_CONSOLE_LOGLEVEL 1
#define Default_console_loglevel 8
Where Default_console_loglevel is the lowest level of terminal CONSOLE output, which is more severe than this. When the value is 7, the debug information cannot be exported, and the modification to 8 has all the output. PS: So you can

echo 8 >/PROC/SYS/KERNEL/PRINTK

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.