在摩托罗拉手机上运行 ndk-gdb 时找不到包错误 [英] Running ndk-gdb with package not found error on motorola phone

查看:15
本文介绍了在摩托罗拉手机上运行 ndk-gdb 时找不到包错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C++ Android 应用程序,我正在尝试使用 ndk-gdb 进行调试.该应用程序确实使用了多个线程,但据说 ndk 的 r5 支持多个线程.另外,我什至没有达到 gdb 启动的地步.我运行命令:

I have a C++ Android application that I'm trying to debug with ndk-gdb. The application does use multiple threads, but supposedly r5 of the ndk supports multiple threads. Also, I'm not even getting to the point where gdb starts up. I run the command:

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

然后它会为 ndk 和 sdk(或至少 adb)以及所需的 ABI 等找到正确的路径.

It then finds the proper path for the ndk and sdk (or at least adb), and the needed ABIs and whatnot.

$ ndk-gdb --start --force --verbose
Android NDK installation path: /home/leif/eclipse/android-ndk-r5b
Using default adb command: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: '/home/leif/eclipse/android-sdk-linux_86/platform-tools/adb'
Using auto-detected project path: .
Found package name: net.leifandersen.mobile.android.marblemachine
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi

然后它会查找 gdb 服务器并找到它,包括正确的 PID,然后启动活动.

It then looks for gdb server, and finds it, including the proper PID, followed by starting the activity.

然后,它告诉我找不到包:

But then, it tells me that the the package cannot be found:

Setup network redirection
## COMMAND: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb shell run-as <package name> lib/gdbserver +debug-socket --attach 16040
## COMMAND: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb forward tcp:5039 localfilesystem:run-as: Package '<package name>' is unknown/debug-socket

然后它会吐出如果您不正确地使用 adb(帮助文件)会得到什么,然后是:

It then spits out what you would get if you improperly use adb (the help file), followed by:

ERROR: Could not setup network redirection to gdbserver?
       Maybe using --port=<port> to use a different TCP port might help?
run-as: Package '<package name>' is unknown

我查看了/data/system/packages.list,是的,我的 apk 肯定在其中,并且它指向的位置在文件系统上是正确的.所以这不是问题.

I looked into /data/system/packages.list, and yes, my apk is most certainly in there, and the location it's pointing to is correct on the file system. So that's not the problem.

本教程:http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/ 建议删除并重新安装,以及清理您的 Eclipse 构建.

This tutorial: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/ recommends deleting and reinstalling, as well as cleaning your eclipse build.

我没有使用 eclipse 构建包,但我确实清理了所有内容并从头开始编译、删除并重新安装,但没有成功.

I didn't use eclipse to build the package, but I did clean everything out and compile from scratch, deleted, and reinstalled to no luck.

有没有人遇到过类似的问题,您是如何解决的?谢谢.

Has anyone had similar problems, and how did you resolve them? Thank you.

哦,我尝试了不同的端口但无济于事,无论如何,5039(默认端口)上似乎没有任何东西.而且,我没有任何防火墙阻止该连接.我也在 Ubuntu 11.04 上开发.

Oh, and I have tried a different port to no avail, there does not appear to be anything on 5039 (the default port) anyway. And afaik, I don't have any firewalls blocking that connection. I'm developing on Ubuntu 11.04 as well.

Edit2:嗯...看起来新的 ndk (r5c),错误信息现在也改变了:

Hmm...it looks like with the new ndk (r5c), the error message has now changed too:

ERROR: Could not extract package's data directory. Are you sure that
       your installed application is debuggable?

是的,debuggable 在清单中设置为 true,并且所有本机代码都是使用以下代码构建的:

And yes, debuggable is set to true in the manifest, and all of the native code is built with:

LOCAL_CFLAGS           := -Wall -g
LOCAL_LDFLAGS          := -Wl,-Map,xxx.map

推荐答案

run-as: Package 'net.leifandersen.mobile.android.marblemachine' is unknown

因此,很遗憾,您的设备无法与 ndk-gdb 一起使用,因为 run-as 不起作用.如果你想使用那个设备,你必须有root权限.

Thus, unfortunately, your device is not able to be used with ndk-gdb, because run-as doesn't work. If you want to use that device, you must have root privilege.

修改ndk-gdb脚本,去掉run-as的依赖.它仅适用于 root 权限('adb shell whoami' 应该是 'root').

Modify ndk-gdb script to get rid of the dependency of run-as. It works only on root privilege ('adb shell whoami' should be 'root').

--- ndk-gdb 2011-02-24 16:55:07.000000000 +0900
+++ ndk-gdb-root    2011-06-09 08:35:04.000000000 +0900
@@ -465,7 +465,7 @@
 log "Using app out directory: $APP_OUT"

 # Find the <dataDir> of the package on the device
-DATA_DIR=`adb_shell run-as $PACKAGE_NAME /system/bin/sh -c pwd`
+DATA_DIR="/data/data/$PACKAGE_NAME"
 log "Found data directory: '$DATA_DIR'"
 if [ $? != 0 -o -z "$DATA_DIR" ] ; then
     echo "ERROR: Could not extract package's data directory. Are you sure that"
@@ -543,7 +543,7 @@

 # Launch gdbserver now
 DEBUG_SOCKET=debug-socket
-run $ADB_CMD shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID &
+run $ADB_CMD shell "(cd $DATA_DIR; lib/gdbserver +$DEBUG_SOCKET --attach $PID)" &
 if [ $? != 0 ] ; then
     echo "ERROR: Could not launch gdbserver on the device?"
     exit 1

这篇关于在摩托罗拉手机上运行 ndk-gdb 时找不到包错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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