android 上調試動態庫方法

來源:互聯網
上載者:User

關於android 上 gdb調試進程的方法請參考前一篇文章。

如果 android應用程式 包含動態庫調用,程式異常退出後 給出一堆地址,

I/DEBUG   (  841): signal 11 (SIGSEGV), fault addr deadbaad
I/DEBUG   (  841):  r0 00000000  r1 afd1498d  r2 00000027  r3 00000070
I/DEBUG   (  841):  r4 afd42328  r5 00000000  r6 00000000  r7 4e6fae30
I/DEBUG   (  841):  r8 00100000  r9 a811c2f9  10 4e5fb000  fp 0013cdb8
I/DEBUG   (  841):  ip 0000173c  sp 4e6fa9d8  lr deadbaad  pc afd11f40  cpsr 60000030
I/DEBUG   (  841):  d0  400000003eaaaaab  d1  3ff0000041f00000
I/DEBUG   (  841):  d2  0000000050baf6de  d3  0000000000000000
I/DEBUG   (  841):  d4  00000007000000b4  d5  3fe999999999999a
I/DEBUG   (  841):  d6  3fe000000000000binder: release proc 1047, transaction 109259, not freed
0  d7  3eaaaaab3f800000
I/DEBUG   (  841):  d8  0000000000000000  d9  0000000000000000
I/DEBUG   (  841):  d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  841):  d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  841):  d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  841):  scr 80000012

根據 pc 地址 及crash的 動態庫可以推斷出現問題的 代碼位置,

利用 gcc 的 命令 arm-eabi-addr2line ,從地址到代碼位置的定位:

具體例子:比如我的 動態庫為 hello.so,把此庫放在本地
帶 symbols 的android lib目錄下,執行

 arm-eabi-addr2line
-C -f -e /path/to/lib/with_sysbols/hello.so
afd11f40

上面的afd11f40
為 crash時的pc 地址:

(I/DEBUG
  (  841):  ip 0000173c  sp 4e6fa9d8  lr deadbaad  pc afd11f40  cpsr 60000030

注意點:

1. 最好把你的動態苦編譯成調試版本(-g)

2. 要把你的動態苦放在android 動態庫的
sysbols版本目錄下,比如我的機器上目錄為:(Eg.) /home/usera/android/out/target/product/generic/symbols/system/lib




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.