调试Android NDK本机应用程序 [英] Debugging Android NDK native apps

查看:155
本文介绍了调试Android NDK本机应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试并逐步通过一个破坏的Android应用程序。我尝试过 ndk-gdb ,但是运气不大。我还提到了 Android 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.

这表示应用程序被删除更少,但是我不知道如何在这里设置断点因为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

我有相关调试符号。


  • ndk-build -BV = 1 APP_OPTIM = debug

  • 中的Android.mk jni / LOCAL_CFLAGS:= -g

  • ant debug

  • ndk-build -B V=1 APP_OPTIM=debug
  • Android.mk in jni/ has LOCAL_CFLAGS := -g
  • ant debug

我还有 ndk-build 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和manifest中的可调试标志设置为true是必需的。当您构建应用程序时,在您的项目/ libs / 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.

这篇关于调试Android NDK本机应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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