NDK生成的so动态库怎么调试

2023-01-04 14:43:04 浏览数 (1)

    很多时候Android业务层开发,和SDK开发是分开的,SDK更多与NDK生成so,这期间双方代码不共享,对调试带来很大难度,所以把一些方法汇总下:


需要用到工具:

  1. AndroidSDKplatform-toolsadb
  2. NDK
  3. so生成库中间文件:objlocalarmeabi-v7a  到这层即可,arm v8 同理
  4. 安卓手机肯定不能少了,还有APK 文件

步骤:

1. 启动adb命令,如下:

代码语言:javascript复制
adb logcat | ndk-stack -sym D:workplace****objlocalarmeabi-v7a

 2. 启动app,运行至崩溃地方

 3.如果NDK崩溃即可在终端打印 堆栈信息,进行分析即可,如下

代码语言:javascript复制
********** Crash dump: **********
Build fingerprint: 'Xiaomi/polaris/polaris:10/QKQ1.190828.002/V11.0.1.0.QDGCNXM:user/release-keys'
pid: 16964, tid: 17013, name: w.myapplication  >>> com.ictt.www.myapplication <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #00 pc 00066d10  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (SipMsgAnalyse::InviteSdpMsgParser(eXosip_event*, InviteSdpMsg*&) 188) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine SipMsgAnalyse::InviteSdpMsgParser(eXosip_event*, InviteSdpMsg*&) at /home/ziloong/Desktop/iDAS/src/GBSip/ProtocolStack/analyse/SipMsgAnalyse.cpp:39
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #01 pc 0006035c  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (InviteHandle::execTaskEvent(eXosip_event*) 112) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine InviteHandle::execTaskEvent(eXosip_event*) at /home/ziloong/Desktop/iDAS/src/GBSip/TransactionUser/InviteHandle.cpp:41 (discriminator 2)
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #02 pc 000609b0  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (InviteHandle::Run_handleEvent() 192) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine InviteHandle::Run_handleEvent() at /home/ziloong/Desktop/iDAS/src/GBSip/TransactionUser/InviteHandle.cpp:158
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #03 pc 000607b8  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (InviteHandle::rootState_processEvent() 232) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine InviteHandle::rootState_processEvent() at /home/ziloong/Desktop/iDAS/src/GBSip/TransactionUser/InviteHandle.cpp:113
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #04 pc 000cfb6c  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (OMReactive::processEvent(IOxfEvent*) 232) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine OMReactive::processEvent(IOxfEvent*) at /home/ziloong/work/LangCpp/oxf/omreactive.cpp:505
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #05 pc 000cf1b8  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (OMReactive::handleEvent(IOxfEvent*) 200) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine OMReactive::handleEvent(IOxfEvent*) at /home/ziloong/work/LangCpp/oxf/omreactive.cpp:238
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #06 pc 000d1ab4  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (OMThread::dispatch(IOxfEvent*) 152) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine OMThread::dispatch(IOxfEvent*) at /home/ziloong/work/LangCpp/oxf/omthread.cpp:375
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #07 pc 000d1d44  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (OMThread::execute() 428) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine OMThread::execute() at /home/ziloong/work/LangCpp/oxf/omthread.cpp:496
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #08 pc 000d1b20  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (OMThread::doExecute(void*) 44) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine OMThread::doExecute(void*) at /home/ziloong/work/LangCpp/oxf/omthread.cpp:390
Stack frame 03-25 19:53:17.720 17063 17063 F DEBUG   :       #09 pc 000cb758  /data/app/com.ictt.www.myapplication-8q6kwRaor0fmisPtqEdPgg==/lib/arm/libiUAC.so (LinuxThread::preExecFunc(void*) 232) (BuildId: 57eb7f4d9f61c85e9e9d3477b463cde22d9cef45): Routine LinuxThread::resume() at /home/ziloong/work/LangCpp/oxf/linuxos.cpp:515
Stack frame 03-25 19:53:17.721 17063 17063 F DEBUG   :       #10 pc 000a109b  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*) 20) (BuildId: 21ece86427ccb892a7d044a6b4b4babb)
Stack frame 03-25 19:53:17.721 17063 17063 F DEBUG   :       #11 pc 00058113  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread 30) (BuildId: 21ece86427ccb892a7d044a6b4b4babb)
Crash dump is completed

4.基于以上堆栈信息,即可成功定位代码段错误了。

0 人点赞