Android的NDK调试:设备无法打开 [英] Android NDK debugging: device can't be opened

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

问题描述

我想现在我调试了一段时间本地库,它只是将无法工作。本机code ++工程,并编译但优化的目的,我真的需要调试本地code。

I am trying to debug my native library for some time now and it just won't work. The native code works and compiles but for optimization purposes I would really need to debug the native code.

我已阅读并遵循许多教程(如的教程1 tutorial2 )一步一步,但我得到了一些错误,我无法找到。解决办法

I have read and followed many tutorials (e.g. tutorial1, tutorial2) step by step but I get some errors that I can't find a solution for.

我已经设置了Android和C ++调试配置后,我与Android调试配置调试它加载库(只有一个)后命中断点。我去Cygwin和查看是否检测到我的设备(它是)。然后运行:

I have set up the Android and C++ debug configuration and after I debug with the Android debug configuration it hits the breakpoint after loading the library (only one). I go to cygwin and see if my device is detected (which it is). Then run:

$ ndk-gdb --start --verbose

这给了我下面的输出:

Which gives me the following output:

Android NDK installation path: /cygdrive/c/Android/android-ndk/android-ndk-r8
Using default adb command: /cygdrive/c/Android/android-sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using ADB flags:
Using auto-detected project path: .
Found package name: com.mypackage
ABIs targetted by application: armeabi-v7a
Device API Level: 15
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.mypackage/lib/gdbserver
Found data directory: '/data/data/com.mypackage'
Found first launchable activity: .MainActivity
Launching activity: com.mypackage/.MainActivity
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb shell am start -n com.mypackage/.MainActivity
Starting: Intent { cmp=com.mypackage/.MainActivity }
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb shell sleep 2
Found running PID: 6907
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb shell run-as com.mypackage lib/gdbserver +debug-socket --attach 6907
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.mypackage/debug-socket
Attached; pid = 6907
Could not open remote device: Invalid argument.
Detaching process(es): 6907
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb pull /system/bin/app_process obj/local/armeabi-v7a/app_process
2405 KB/s (9852 bytes in 0.004s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb pull /system/lib/libc.so obj/local/armeabi-v7a/libc.so
4994 KB/s (286412 bytes in 0.056s)
Pulled libc.so from device/emulator.

User@This-PC /cygdrive/c/Development/MyAppAndroid/trunk/MyApp
$

我可以看到gdbserver的成功推出,这是很好的,但我不知道为什么会这样:

I can see that the gdbserver has been launched successfully, which is good, but I don't know why this happens:

Could not open remote device: Invalid argument

由于亚行可以连接到设备(如前测试)。之后,在我看来,(我不是太有Cygwin的熟悉)的GDB只是关闭一切,这将使在Eclipse中的C ++调试也失败。当我运行它,出现以下错误:

because adb can connect to the device (as tested before). After that it seems to me (I am not too versed with cygwin) that gdb just closes everything and that would make the c++ Debug in eclipse fail as well. When I run it, the following error:

76-target-select remote localhost:5039
&"Remote communication error: Bad file descriptor.\n"
Remote communication error: Bad file descriptor.
76^error,msg="Remote communication error: Bad file descriptor."

有没有什么东西可以prevent由亚行检测到我的设备?我使用这个设备用于测试(不包括C ++调试)所有的时间没有问题。

Is there anything that could prevent my device from being detected by the adb? I use this device for testing (without c++ debugging) all the time without problem.

还是问题出在港口的错误?

Or does the problem lie in the port error?

推荐答案

我有同样的问题,所以我换成下面的行NDK-GDB文件:

I had same problem so I replaced the following lines in ndk-gdb file :

原文:

run adb_cmd shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID & 

替换:

run adb_cmd shell run-as $PACKAGE_NAME lib/gdbserver tcp:5888 --attach $PID & 

和原文:

run adb_cmd forward tcp:$DEBUG_PORT localfilesystem:$DATA_DIR/$DEBUG_SOCKET 

替换:

run adb_cmd forward tcp:5039 tcp:5888

这是固定的无效参数问题。

which is fixed the "Invalid argument" problem.

P上。

这篇关于Android的NDK调试:设备无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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