需要帮助进一步调试到SEGV的问题 - 的Andr​​oid NDK [英] Need help debugging further into a SEGV issue - Android NDK

查看:140
本文介绍了需要帮助进一步调试到SEGV的问题 - 的Andr​​oid NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个庞大的身躯源$ C ​​$ C为Android库。如果编译针对Linux x86库工作正常。我用独立的工具链构建它。我曾与pviously此$ P $与其他图书馆的成功,所以我觉得我的设置是好的。无论如何,编译和链接都是不错的,但是当我打开生成的共享库,我得到一个SEGV。这是我得到的跟踪:

I am building a library with a large body of source code for Android. The library works fine if compiled for Linux x86. I am building it with the stand alone tool chain. I have had success with this previously with other libraries, so I feel like my setup is good. Anyway, compiling and linking are all good, but when I load the resultant shared library I get a SEGV. This is the trace that I get:

03-23 23:37:14.213: I/DEBUG(28): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-23 23:37:14.213: I/DEBUG(28): Build fingerprint: 'generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys'
03-23 23:37:14.224: I/DEBUG(28): pid: 332, tid: 332  >>> com.example.hellojni <<<
03-23 23:37:14.224: I/DEBUG(28): signal 11 (SIGSEGV), fault addr 00000000
03-23 23:37:14.224: I/DEBUG(28):  r0 00000000  r1 00000000  r2 80808080  r3 00000000
03-23 23:37:14.224: I/DEBUG(28):  r4 00000000  r5 bea8154c  r6 bea81600  r7 00000000
03-23 23:37:14.224: I/DEBUG(28):  r8 bea81820  r9 41971894  10 00000354  fp bea814fc
03-23 23:37:14.224: I/DEBUG(28):  ip 80a81058  sp bea814c0  lr 80a63cd8  pc afe0e7c8  cpsr 40000010
03-23 23:37:14.313: I/DEBUG(28):          #00  pc 0000e7c8  /system/lib/libc.so
03-23 23:37:14.313: I/DEBUG(28):          #01  pc 00063cd4  /data/data/com.example.hellojni/lib/libgnustl_shared.so
03-23 23:37:14.323: I/DEBUG(28): code around pc:
03-23 23:37:14.323: I/DEBUG(28): afe0e7b8 e31c0003 1afffff6 e1a00002 e59f20d8 
03-23 23:37:14.323: I/DEBUG(28): afe0e7c8 e490c004 e0433000 f5d0f040 e04c13a2 
03-23 23:37:14.323: I/DEBUG(28): afe0e7d8 e0011002 e1d1100c 0490c004 1a000022 
03-23 23:37:14.323: I/DEBUG(28): code around lr:
03-23 23:37:14.323: I/DEBUG(28): 80a63cc8 e1a05000 e1a00001 e1a04001 ebff27d0 
03-23 23:37:14.323: I/DEBUG(28): 80a63cd8 e1a01004 e1a02000 e1a00005 e8bd4070 
03-23 23:37:14.323: I/DEBUG(28): 80a63ce8 eaffffa0 e590c000 e92d45f0 e51ce00c 
03-23 23:37:14.323: I/DEBUG(28): stack:
03-23 23:37:14.323: I/DEBUG(28):     bea81480  001479d0  [heap]
03-23 23:37:14.323: I/DEBUG(28):     bea81484  bea81820  [stack]
03-23 23:37:14.323: I/DEBUG(28):     bea81488  41971894  /dev/ashmem/dalvik-LinearAlloc (deleted)
03-23 23:37:14.323: I/DEBUG(28):     bea8148c  00000354  
03-23 23:37:14.334: I/DEBUG(28):     bea81490  bea814fc  [stack]
03-23 23:37:14.334: I/DEBUG(28):     bea81494  00147a24  [heap]
03-23 23:37:14.334: I/DEBUG(28):     bea81498  00000006  
03-23 23:37:14.334: I/DEBUG(28):     bea8149c  80a63b58  /data/data/com.example.hellojni/lib/libgnustl_shared.so
03-23 23:37:14.334: I/DEBUG(28):     bea814a0  00000006  
03-23 23:37:14.334: I/DEBUG(28):     bea814a4  bea81548  [stack]
03-23 23:37:14.334: I/DEBUG(28):     bea814a8  80a82110  
03-23 23:37:14.334: I/DEBUG(28):     bea814ac  00000000  
03-23 23:37:14.334: I/DEBUG(28):     bea814b0  bea81820  [stack]
03-23 23:37:14.334: I/DEBUG(28):     bea814b4  80a63bcc  /data/data/com.example.hellojni/lib/libgnustl_shared.so
03-23 23:37:14.334: I/DEBUG(28):     bea814b8  df002777  
03-23 23:37:14.334: I/DEBUG(28):     bea814bc  e3a070ad  
03-23 23:37:14.344: I/DEBUG(28): #00 bea814c0  bea814d4  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814c4  00000000  
03-23 23:37:14.344: I/DEBUG(28): #01 bea814c8  bea81548  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814cc  bea81548  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814d0  bea81600  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814d4  8131f228  /data/data/com.example.hellojni/lib/libsharedB.so
03-23 23:37:14.344: I/DEBUG(28):     bea814d8  afe39190  /system/lib/libc.so
03-23 23:37:14.344: I/DEBUG(28):     bea814dc  bea8152c  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814e0  001479a0  [heap]
03-23 23:37:14.344: I/DEBUG(28):     bea814e4  bea81548  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814e8  80a8211c  
03-23 23:37:14.344: I/DEBUG(28):     bea814ec  001479a0  [heap]
03-23 23:37:14.344: I/DEBUG(28):     bea814f0  bea81548  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814f4  bea81548  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814f8  bea8151c  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea814fc  8131eb8c  /data/data/com.example.hellojni/lib/libsharedB.so
03-23 23:37:14.344: I/DEBUG(28):     bea81500  bea8152c  [stack]
03-23 23:37:14.344: I/DEBUG(28):     bea81504  0000272e  
03-23 23:37:14.344: I/DEBUG(28):     bea81508  80a82124  
03-23 23:37:14.344: I/DEBUG(28):     bea8150c  80a8211c  
03-23 23:37:14.884: D/Zygote(30): Process 332 terminated by signal (11)
03-23 23:37:14.893: I/ActivityManager(52): Process com.example.hellojni (pid 332) has died.
03-23 23:37:14.966: I/UsageStats(52): Unexpected resume of com.android.launcher while already resumed in com.example.hellojni

如果我使用addr2line我得到这个信息:

If I use addr2line I get this info:

android-linux-addr2line.exe -C -f -e libc.so 0000e7c8
strlen
??:0

android-linux-addr2line.exe -C -f -e libgnustl_shared.so 00063cd4
std::string::operator=(char const*)
??:0

好了,有可能是一些与字符串的静态分配走错了。这就解释了失败的签名。所以,我怎么揣摩出源$ C ​​$ C这是发生?我如何走下一步,让那里的任务是在引起问题?再次,这是一个庞大的身躯源$ C ​​$ C和它似乎有弦的许多静态分配。我需要它缩小。

Ok, so there might be something going wrong with a static assignment of a string. That would explain the fail signature. So, how do I figure out where in the source code this is occurring? How do I go the next step and get where the assignment was at that caused the issue? Again, this is a large body of source code and it appears there are many static assignments of strings. I need to narrow it down.

推荐答案

好了,所以走线的顶部并没有帮助(这通常是唯一的部分,我要看看):

Ok, so the top section of the trace didn't help (this is normally the only section I have to look at):

03-23     23:37:14.313: I/DEBUG(28):          #00  pc 0000e7c8  /system/lib/libc.so
03-23     23:37:14.313: I/DEBUG(28):          #01  pc 00063cd4  /data/data/com.example.hellojni/lib/libgnustl_shared.so

但再往下我看行的行这样的:

but further down I see lines line this:

03-23 23:37:14.344: I/DEBUG(28):     bea814d4  8131f228  /data/data/com.example.hellojni/lib/libsharedB.so

如果我用这个addr2line和其他行显示,最近在libsharedB.so功能是在栈上,我得到我的答案。唯一的额外的诀窍是8131f228是不是我需要输入地址。相反,我需要进入,0131f228。在8000是图书馆的基址,剩下的就是该空间内的地址。

If I use addr2line on this and the other lines showing that recently a function in libsharedB.so was on the stack, I get my answer. The only additional trick was 8131f228 wasn't the address I needed to enter. Instead, I needed to enter, 0131f228. The 80000000 is the base address of the library, the rest is the address within that space.

这篇关于需要帮助进一步调试到SEGV的问题 - 的Andr​​oid NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆