Pau*_*ien 34 android gdb android-ndk ndk-gdb android-4.3-jelly-bean
我无法为运行Jellybean 4.2.2的Galaxy S4运行run-as(或ndk-gdb).
~ $ adb shell
shell@android:/ $ run-as a.b.c ls
run-as: Package 'a.b.c' is unknown
Run Code Online (Sandbox Code Playgroud)
对于pre-ICS设备,这个问题有多个答案,但这些答案似乎已在ICS中得到修复.
更新 - 2013年8月:在最初出现在带有Jellybean 4.2.2的Galaxy S4之后,现在似乎是所有4.3设备上的运行问题.看到这个Android bug.
请在此处查看已确认的Android问题.
更新 - 2013年11月:谷歌发布了修复Android 4.4中运行的修补程序.
Pau*_*ien 13
通过将此添加到活动中找到成功:
private void startGdbServer() {
try {
new ProcessBuilder()
.command(getFilesDir().getParent() + "/lib/gdbserver", "tcp:5039", "--attach" ,"" + android.os.Process.myPid())
.redirectErrorStream(true)
.start();
} catch (IOException e) {
Log.e(TAG, "IOException failed to start gdbserver");
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将startGdbServer包装在Android服务中并更新ndk-gdb脚本以启动服务器而不是run-as命令.
这是明显的补充:
<service android:enabled="true" android:name="com.apportable.activity.GdbServerService"
android:label="@string/app_name" android:icon="@drawable/icon">
<intent-filter >
<action android:name="apportable.FoundationTests.GdbServerService" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
以下是相关的ndk-gdb更改(在python中):
remote_gdbserver = '/data/data/' + env['APPLICATION_IDENTIFIER'] + '/lib/gdbserver'
print "Attaching to pid " + pid
# Android 4.2 requires the --user 0 option. Earlier versions cannot have it
results = env.Execute([env['ADB'], 'shell', 'am'])
if "--user" in results:
user_option = "--user 0"
else:
user_option = ""
adb.AsyncShell(env, 'am startservice ' + user_option + ' -a ' + env['APPLICATION_IDENTIFIER'] + '.GdbServerService --es gdbserver_name ' + remote_gdbserver + ' --ei gdbserver_port ' + str(env['ANDROID_REMOTE_DEBUG_PORT']))
# HACK: magic number. ensure the gdb server is actually up and running
time.sleep(2) # 1 is usually enough, but not always, like after reboot or with heavy system load
adb.Forward(env, env['ANDROID_LOCAL_DEBUG_PORT'], env['ANDROID_REMOTE_DEBUG_PORT'])
adb.Pull(env, process_path, '/system/bin/app_process')
setup_path = '"' + setup_path + '"'
if env['CGDB'] is not None:
cmd = [env['CGDB'], '-d', env['GDB'], '--', '-x', setup_path]
else:
cmd = [env['GDB'], '-x', setup_path]
env.RunCommand(cmd)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23178 次 |
| 最近记录: |