堆栈跟踪让我的code之前停止(在使用的Andr​​oid NDK) [英] stack traces stop before getting to my code (on Android using NDK)

查看:163
本文介绍了堆栈跟踪让我的code之前停止(在使用的Andr​​oid NDK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用NDK R5B的Andr​​oid 2.3.x。偶尔我的code崩溃,我想知道在哪里。我已经知道如何得到相应的线在我的应用程序时,我有一个有一个指针(即从Android的堆栈跟踪。)

不过,我经常看到这样的无用的堆栈跟踪(完整的堆栈跟踪):

 #00件0006561a /system/lib/egl/libGLESv2_adreno200.so
     #01件0006b900 /system/lib/egl/libGLESv2_adreno200.so
     #02件0005aac8 /system/lib/egl/libGLESv2_adreno200.so
     #03件0001687a /system/lib/egl/libGLESv1_CM_adreno200.so
     #04件000096ce /system/lib/egl/libGLESv1_CM_adreno200.so
 

或者这样的:

 (GDB)BT
#0 0xafd0c51c在epoll_wait()从/Volumes/Secure$c$c/webos/rta/android/obj/local/armeabi/libc.so
在#1 0xa81216a6? ()
 

这甚至没有提到我的code在所有。

有没有什么办法都得到比这更好的堆栈跟踪?为什么有些库函数不透明,因为他们不允许回溯到看穿调用函数,造成​​停在堆栈跟踪?

据我所知,调试这样的问题的唯一方法是使用记录在每一个点在程序和/或通过使用gdb每行一步。

是否有可用的ROM与这些机器人库,而不是那些运行调试版本,并会帮助吗? (我用一个电话仅用于开发,所以我不担心保存完整的功能。)( 其实 的,我注意到,路径 libc.so 在上述 GDB 堆栈跟踪是在我的应用程序目录中。我可不可以只是用不同的(调试)打包 libc.so ,并会帮助吗?)

这可能有助于最后一件事:在上面的堆栈跟踪从logcat的(第一个,)我的库中提到的原始堆栈转储:

 堆栈:
  ...
  ...
  4471cb88 00000028
  4471cb8c afd4649c
  4471cb90 80b4eb71 /data/data/com.audia.dev.rta/lib/librta.so
  4471cb94 00299180
  ...
  ...
 

但是这不是一个函数指针。那会是什么,并且会是任何帮助后,该应用程序崩溃?我猜大概不会,如果它是一个堆指针或类似的东西。

解决方案
  

有没有什么办法都得到更好的堆栈跟踪比这个?

据我所知,你必须建立并自己写了Android的图像。它可以让您拥有了Android的整个完整的符号(可执行文件和共享库),除了专用的共享库。

此外,它提供了用gdb使用的符号。

  $亚行外壳setprop debug.db.uid 32767
$ ADB将TCP:5039 TCP:5039

/ *
 方案终止,debuggerd捕获的异常如下所示。
 使用的gdbclient第三个参数的PID号。
 I / DEBUG(2154):*********** *************
 I / DEBUG(2154):*处理2508已经崩溃时暂停。至
 I / DEBUG(2154):* gdbserver的连接在端口5039一GDB连接:
 I / DEBUG(2154):*
 I / DEBUG(2154):*亚行外壳的gdbserver:5039 --attach 2508和放大器;
 I / DEBUG(2154):*
 I / DEBUG(2154):* preSS HOME键让程序继续崩溃。
 I / DEBUG(2154):*********** *************)
* /

$ gdbclient2508
 

编辑:

您仍然可以使用NDK-gdb的,而不是gdbclient命令。请指定符号文件共享库。

 (GDB)设置solib搜索路径(ANDROID_SOURCE_PATH)/输出/目标/产品/(PRODUCT_NAME)/符号/系统/ lib目录
 

EDITED 2:

如果您不需要Android系统的共享库,就亚行拉共享库的符号,并设置sollib-搜索路径。

  $ ADB拉/系统/ lib下的lib

$ NDK-GDB
...
(GDB)设置solib搜索路径LIB
 

I'm developing on Android 2.3.x using NDK r5b. Occasionally my code crashes and I'd like to know where. I already know how to get the corresponding line in my application when I have a have a pointer (i.e. from Android's stack traces.)

However, oftentimes I see useless stack traces like this (full stack trace):

     #00  pc 0006561a  /system/lib/egl/libGLESv2_adreno200.so
     #01  pc 0006b900  /system/lib/egl/libGLESv2_adreno200.so
     #02  pc 0005aac8  /system/lib/egl/libGLESv2_adreno200.so
     #03  pc 0001687a  /system/lib/egl/libGLESv1_CM_adreno200.so
     #04  pc 000096ce  /system/lib/egl/libGLESv1_CM_adreno200.so

or this:

(gdb) bt
#0  0xafd0c51c in epoll_wait () from /Volumes/SecureCode/webos/rta/android/obj/local/armeabi/libc.so
#1  0xa81216a6 in ?? ()

that don't even mention my code at all.

Is there any way at all to get better stack traces than this? Why are some library functions "opaque" in that they don't allow the backtrace to "see through" to the calling function, causing a stop in the stack trace?

As far as I can tell, the only way to debug a problem like this is to use logging at each point in the program and/or step through each line with gdb.

Are there ROMs available with debug versions of these Android libraries instead of runtime ones, and would that help? (I use one phone solely for development, so I'm not concerned about keeping full functionality.) (Actually, I noticed that the path to libc.so in the above gdb stack trace is within my application directory. Could I possibly just package it with a different (debug) libc.so, and would that help?)

One last thing that might help: in the above stack trace from logcat (the first one,) my library is mentioned in the raw stack dump:

stack:
  ...
  ...
  4471cb88  00000028  
  4471cb8c  afd4649c  
  4471cb90  80b4eb71  /data/data/com.audia.dev.rta/lib/librta.so
  4471cb94  00299180  
  ...
  ...

but that is not a function pointer. What could that be, and would it be of any help after the app has crashed? I'm guessing probably not if it's a heap pointer or something like that.

解决方案

Is there any way at all to get better stack traces than this?

As far as I know, you must build and write the Android image by yourself. It enables you to have the whole complete symbols of the Android (executable files and shared libraries) except proprietary shared libraries.

Also it provides to use the symbols using gdb.

$ adb shell setprop debug.db.uid 32767
$ adb forward tcp:5039 tcp:5039

/*
 program terminated and debuggerd caught exception like the following.
 Use the PID number for gdbclient 3rd parameter.
 I/DEBUG   ( 2154): ******************************************************** 
 I/DEBUG   ( 2154): * Process 2508 has been suspended while crashing.  To
 I/DEBUG   ( 2154): * attach gdbserver for a gdb connection on port 5039:
 I/DEBUG   ( 2154): *
 I/DEBUG   ( 2154): *     adb shell gdbserver :5039 --attach 2508 &
 I/DEBUG   ( 2154): *
 I/DEBUG   ( 2154): * Press HOME key to let the process continue crashing.
 I/DEBUG   ( 2154): ********************************************************)
*/

$ gdbclient "" "" 2508

EDITED:

You can still use ndk-gdb instead of gdbclient command. Please specify the symbol files for shared libraries.

(gdb) set solib-search-path (ANDROID_SOURCE_PATH)/out/target/product/(PRODUCT_NAME)/symbols/system/lib

EDITED 2:

If you don't need the symbols of the Android system shared libraries, just adb pull shared libraries and set sollib-search-path to it.

$ adb pull /system/lib lib

$ ndk-gdb
...
(gdb) set solib-search-path lib

这篇关于堆栈跟踪让我的code之前停止(在使用的Andr​​oid NDK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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