嵌入式Linux熱門培訓內容之Linux內核使用gdb調試

時間:2018-12-13 17:37:23

我們在編寫linux內核代碼的時候,難免會遇到oops的問題,類似空指針crash,在crash的時候,會打印一些當時的棧信息,我們可以通過這些信息結合vmlinux來調試具體在哪個函數上出現了問題。Vmlinux是一個內核符號表,編譯進內核的函數列表之類的都可以從里面提取出來。

在內核的.config里面要打開 DEBUG_INFO和DEBUG_VM

[email protected]:~/weiqifa/tm100$ ./prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/arm-eabi-gdb ./out/target/product/tm100/obj/KERNEL_OBJ/vmlinux

GNU gdb (GDB) 7.3.1-gg2

Copyright (C) 2011 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".

For bug reporting instructions, please see:

<http://source.android.com/source/report-bugs.html>...

Reading symbols from /home/weiqifa/weiqifa/tm100/out/target/product/tm100/obj/KERNEL_OBJ/vmlinux...done.

(gdb) 

定位故障代碼

(gdb) l * qrd7627a_add_io_devices+0x100

0xc07cd05c is in qrd7627a_add_io_devices (/home/kernel/arch/arm/mach-msm/msm8x25/goso-msm7627a-io.c:1851).

1846            } else if (machine_is_msm8625q_skud() || machine_is_msm8625q_evbd()) {

1847        #ifndef CONFIG_CALA02

1848                    platform_device_register(&pmic_mpp_leds_pdev_skud);

1849        #endif

1850                    /* enable the skud flash and torch by gpio leds driver */

1851                    platform_device_register(&gpio_flash_skud);

1852            } else if (machine_is_msm8625q_skue()) {

1853                     /* enable the skue flashlight by gpio leds driver */

1854                    platform_device_register(&gpio_flash_skue);

? 江苏快3号码表