Debug analysis: PC pointer analysis error based on kernel error information

Publisher:快乐航程Latest update time:2024-08-13 Source: cnblogs Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

2 arm-none-linux-gnueabi-objdump -D vmlinux > ../../module/37_debug_err_led/vmlinux.txt

3 root@Lover snow:/home/study/nfs_home/system/linux-2.6.31# cd ../../module/37_debug_err_led/

4

5 root@Lover snow:/home/study/nfs_home/system/linux-2.6.31#vi vmlinux.txt

6

7 Search for c01e8c74 in vmlinux.txt:

8 506554 c01e8c5c :

9 506555 c01e8c5c: e52de004 str lr, [sp, #-4]!

10 506556 c01e8c60: e59f0038 ldr r0, [pc, #56] ; c01e8ca0 <.text+0x1bfca0>

11 506557 c01e8c64: e24dd004 sub sp, sp, #4; 0x4

12 506558 c01e8c68: ebf97d89 bl c0048294

13 506559 c01e8c6c: e59f1030 ldr r1, [pc, #48] ; c01e8ca4 <.text+0x1bfca4>

14 506560 c01e8c70: e59f0030 ldr r0, [pc, #48] ; c01e8ca8 <.text+0x1bfca8>

15 506561 c01e8c74: e5113f9f ldr r3, [r1, #-3999]

16 506562 c01e8c78: e3c33007 bic r3, r3, #7; 0x7

17 506563 c01e8c7c: e5013f9f str r3, [r1, #-3999]

18 506564 c01e8c80: e5112f9f ldr r2, [r1, #-3999]

19 506565 c01e8c84: e59f3020 ldr r3, [pc, #32] ; c01e8cac <.text+0x1bfcac>

20 506566 c01e8c88: e3822005 orr r2, r2, #5; 0x5

21 506567 c01e8c8c: e5830000 str r0, [r3]

22 506568 c01e8c90: e3a00000 mov r0, #0 ; 0x0

23 506569 c01e8c94: e5012f9f str r2, [r1, #-3999]

twenty four

25 Then reverse the process based on the assembly code.

3c816e32b233a2790f1a21a0fd8ab59a_AebkZz2YW6ecAAAAAAElFTkSuQmCC.png

5. Summarize the analysis methods


From the above steps, we know that whether the program is in the kernel or dynamically loaded, the analysis method is the same.



①. Analyze the error code to get the address and offset address of PC


② Generally speaking, the error code will give the function where the error occurred, and we can directly check the error in that function.


③If no error function is given, we need to determine whether the driver is in the kernel or a program loaded by insmod based on the value of PC


④ Open linux-2.6.31/System.map and cat /proc/kallsyms to match the PC pointer value. If it is in system.map, it is the kernel driver debugging. If it is in /proc/kallsyms, it is the driver error loaded by insmod.


⑤ If it is debugging the driver loaded by insmod, we will disassemble the .ko file.


arm-none-linux-gnueabi-objdump -D err_led.ko > err_led.txt,


Analyze the assembly file based on the offset address and PC value to deduce the wrong code


⑥ If it is a program debugging in the kernel, disassemble /linux-2.6.31/vmlinux


arm-none-linux-gnueabi-objdump -D vmlinux > vmlinux.txt


Search for the cheap address of PC in the disassembled file, analyze the disassembled file, and find out where the error is.


[1] [2] [3]
Reference address:Debug analysis: PC pointer analysis error based on kernel error information

Previous article:Debug analysis: Analyze errors based on kernel error information stack information
Next article:Debugging and analysis of the implementation of mymsg and myprintk under proc in imx257

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号