其他分享
首页 > 其他分享> > 驱动开发crash问题debug方法之一

驱动开发crash问题debug方法之一

作者:互联网

有时候在开发过程中遇到crash的问题,back trace印的比较少或者没有印,或者看到back trace你觉得可以不是死在这边,都可以用下面的方法进行debug,定位到具体是哪一个函数的某一行。

[Thu Jul 16 07:24:18.560 2020] [ 9.983629] Internal error: Oops: 86000007 [#1] PREEMPT SMP
[Thu Jul 16 07:24:18.560 2020] [ 9.989206] Modules linked in: mwgifker(PO) utpa2k(O) libdmdbraslia(O) mdrv_ldm(O) kdrv_hdr10plus_ref(O) kdrv_alg(O) kdrv_platform(O) kdrv_dolby_vision(O) iniparser(O) firmware_class kdrv_xc(O) mali_kbase(O) f81232 ftdi_sio cp210x ch341 pl2303 usbserial
[Thu Jul 16 07:24:18.560 2020] [ 10.011667] Process irq/207-(null) (pid: 1862, stack limit = 0x00000000a46a663f)
[Thu Jul 16 07:24:18.560 2020] [ 10.019068] CPU: 0 PID: 1862 Comm: irq/207-(null) Tainted: P O 4.19.79-dtv2020-t31-20200701 #1
[Thu Jul 16 07:24:18.560 2020] [ 10.028982] Hardware name: M7642 (DT)
[Thu Jul 16 07:24:18.560 2020] [ 10.032645] pstate: 80000005 (Nzcv daif -PAN -UAO)
[Thu Jul 16 07:24:18.560 2020] [ 10.037438] pc : 0x12ba228
[Thu Jul 16 07:24:18.560 2020] [ 10.040471] lr : MDrv_SC_isr+0x120/0x150 [utpa2k]
[Thu Jul 16 07:24:18.560 2020] [ 10.045176] sp : ffffff800fc43cf0
[Thu Jul 16 07:24:18.560 2020] [ 10.048490] x29: ffffff800fc43cf0 x28: 0000000000000000 
[Thu Jul 16 07:24:18.560 2020] [ 10.053806] x27: ffffffc039f442a4 x26: 0000000000000029 
[Thu Jul 16 07:24:18.560 2020] [ 10.059121] x25: 000000000000002d x24: ffffff80015a2000 
[Thu Jul 16 07:24:18.560 2020] [ 10.064435] x23: ffffff8008ddd000 x22: ffffffc03640b380 
[Thu Jul 16 07:24:18.560 2020] [ 10.069749] x21: 0000000000018000 x20: 000000000000000a 
[Thu Jul 16 07:24:18.575 2020] [ 10.075064] x19: 0000000000000001 x18: ffffff8008ddd000 
[Thu Jul 16 07:24:18.575 2020] [ 10.080378] x17: 0000000000000000 x16: 0000000000000001 
[Thu Jul 16 07:24:18.575 2020] [ 10.085693] x15: ffffffc07f567a10 x14: 0000000000000000 
[Thu Jul 16 07:24:18.575 2020] [ 10.091007] x13: ffffff80025a4000 x12: 0000000000000000 
[Thu Jul 16 07:24:18.575 2020] [ 10.096322] x11: ffffffffffffffff x10: ffffff05ffffffff 
[Thu Jul 16 07:24:18.575 2020] [ 10.101637] x9 : 04ffffffffffffff x8 : ffffff00ffffffff 
[Thu Jul 16 07:24:18.575 2020] [ 10.106951] x7 : ffffffffffffffff x6 : ff0302ffffffff01 
[Thu Jul 16 07:24:18.575 2020] [ 10.112266] x5 : ffffffffffffffff x4 : ffffff06ffffffff 
[Thu Jul 16 07:24:18.575 2020] [ 10.117580] x3 : 00000000012ba228 x2 : ffffff800d003534 
[Thu Jul 16 07:24:18.575 2020] [ 10.122894] x1 : 0000000000000000 x0 : 000000000000002d 
[Thu Jul 16 07:24:18.575 2020] [ 10.128208] Call trace:
[Thu Jul 16 07:24:18.575 2020] [ 10.130655] 0x12ba228
[Thu Jul 16 07:24:18.575 2020] [ 10.133203] MApi_CMA_Pool_Release+0xaa8/0xab0 [utpa2k]

 

找到toolchain的路径,export一下,如下

export PATH=/mtkeda/dtv/tools/mstar_toolchain/linaro_aarch64_linux-2014.09_r20170413/tools/arm/MStar/linaro_aarch64_linux-2014.09_r20170413/bin/:$PATH

aarch64-linux-gnu-objdump -D xxx.o(xxx.ko) > dump.log     //64为arm,把crash的文件给ojbdump出来,注意要是debug版本,首先,要(使用 -Wl 选项)通知链接器生成一个映像文件,并(使用 -g 选项)通知编译器生成调试符号

arm-none-linux-gnueabi-objdump

然后到dump.log里面grep 到MDrv_SC_isr  。例如下面这样就能找到对应的地址

nm  utopia.ko |grep MDrv_SC_isr

MDrv_SC_isr+0x120/0x150

》》这条trace表示,xxx.ko中MDrv_SC_isr的总长度为0x150,挂的位置为MDrv_SC_isr的起始地址+ 0x120的offset

在调用 Addr2line 工具时,要使用 -e 选项来指定可执行映像是 utopia.ko。通过使用 -f 选项,可以告诉工具输出函数名。

Addr2line 工具(它是标准的 GNU Binutils 中的一部分)是一个可以将指令的地址和可执行映像转换成文件名、函数名和源代码行数的工具。

00000000001c6e70 <MDrv_SC_isr>:    00000000001c6e70 + 0x120得到下面的地址

 aarch64-linux-gnu-addr2line -e utpa2k.o 1c6f90

xxx/xxx/mdrv_sc_isr.c:407

标签:24,crash,07,16,Thu,Jul,2020,debug,驱动
来源: https://www.cnblogs.com/kaosine/p/13368539.html