调试的Andr​​oid NDK本地应用程序应用程序、Andr、oid、NDK

2023-09-12 23:39:49 作者:戚:戚分蛋糕、戚分糖,戚奇企器

我想调试,并通过一个Android应用程序段错误步骤。我试过 NDK-gdb的,但有一点运气。我还提到的Andr​​oid NDK调试没有能够调试我的应用程序。

I'm trying to debug and step through an Android application that segfaults. I've tried ndk-gdb, but with little luck. I've also referred to Android NDK Debugging without being able to debug my app.

当我尝试 NDK-gdb的--start ,我也得到:

$ ndk-gdb --start --verbose
Android NDK installation path: /opt/android-ndk-r7
Using default adb command: /opt/android-sdk-linux/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/opt/android-sdk-linux/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.example.native_plasma
ABIs targetted by application: armeabi armeabi-v7a
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.native_plasma/lib/gdbserver
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /opt/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found data directory: '/data/data/com.example.native_plasma'
Found first launchable activity: android.app.NativeActivity
Launching activity: com.example.native_plasma/android.app.NativeActivity
## COMMAND: /opt/android-sdk-linux/platform-tools/adb shell am start -n com.example.native_plasma/android.app.NativeActivity
Starting: Intent { cmp=com.example.native_plasma/android.app.NativeActivity }
## COMMAND: /opt/android-sdk-linux/platform-tools/adb shell sleep 2
Found running PID: 0
ERROR: Could not extract PID of application on device/emulator.
       Weird, this probably means one of these:

         - The installed package does not match your current manifest.
         - The application process was terminated.

       Try using the --verbose option and look at its output for details.

这表明应用程序segfaulted更加少了,但我不知道怎么在这里设置一个断点,因为GDB从来没有真正给出提示。

This indicates that the application segfaulted more less, but I don't know how to set a breakpoint here since gdb never actually gives a prompt.

我也试过这个命令:

$ ../../toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-addr2line -f -e  libs/armeabi/libnative-plasma.so 
bedb2330
??
??:0

我有调试符号,我相信。

I have debug symbols I believe.

NDK建造-bv = 1 APP_OPTIM =调试 Android.mk JNI / LOCAL_CFLAGS:= -g 蚂蚁调试 ndk-build -B V=1 APP_OPTIM=debug Android.mk in jni/ has LOCAL_CFLAGS := -g ant debug

我也 NDK建造NDK_DEBUG = 1 ,但我仍然得到它看起来像我没有调试符号。

I've also ndk-build NDK_DEBUG=1 but I still get where it looks like I don't have debug symbols.

下面是堆栈跟踪的图像。它没有得到任何更多的信息:

Here's an image of the stack trace. It doesn't get any more informative:

推荐答案

嗯NDK_DEBUG = 1和调试的标志清单设置为true是必需的。当您生成的应用程序,在您的项目/库/ armeabi,应该有一个gdb.setup文件。有符号搜索路径那里,检查它是否有效。而你尝试这样的:

Well NDK_DEBUG=1 and debuggable flag in manifest set to true are required. When you build the app,in your project/libs/armeabi, there should be a gdb.setup file. There is symbol search path there, check whether it is valid. And did you try this:

ndk-gdb --start --verbose --force

和看起来像你得到一个空指针异常。

And looks like you are getting a null pointer exception.