简体   繁体   English

为什么将 gdbserver 附加到本机 android 应用程序失败?

[英]Why is attaching gdbserver to a native android app failing?

I am developing a fully native application in using C++ and pure CMake as the build system - no Android Studio involved at all (proof of concept here )我正在开发一个完全原生的应用程序,使用 C++ 和纯 CMake 作为构建系统 - 完全不涉及 Android Studio(概念证明在这里

The code builds, apk is generated and can be installed and run via ADB without issue but I cannot get gdbserver64 to attach to the process for debugging.代码构建,apk 生成,可以通过 ADB 安装和运行,没有问题,但我无法让 gdbserver64 附加到进程进行调试。

More details:更多细节:

  • App is built against SDK/NDK API level 30应用程序是针对 SDK/NDK API 级别 30 构建的
  • Attempting to debug on an Android 11 emulator instance without Google Play尝试在没有 Google Play 的情况下在 Android 11 模拟器实例上进行调试
  • I can run adb root just fine我可以运行 adb root 就好了
  • Image already includes gdbserver and gdbserver64, attempting to use those图像已经包含 gdbserver 和 gdbserver64,试图使用它们
  • Developer options and USB debugging enebled in emulator在模拟器中启用开发者选项和 USB 调试
  • App has android:debuggable="true" in manifest应用程序在清单中有android:debuggable="true"

But every time I try gdbserver64:5039 --attach $(pidof my.app.id)但每次我尝试gdbserver64:5039 --attach $(pidof my.app.id)

I get /bin/sh: <app_pid>: inaccessible or not found我得到/bin/sh: <app_pid>: inaccessible or not found

What am I missing?我错过了什么? And no, I cannot just move to Android Studio - this is a cross platform project that needs to be buildable using only CMake.不,我不能只移动到 Android Studio - 这是一个跨平台项目,需要仅使用 CMake 即可构建。

According to my observation, this may be a bug of prebuilt gdbserver.根据我的观察,这可能是预建的 gdbserver 的一个错误。 It treats the parameter after --attach as a program name and tries to start it.它将 --attach 之后的参数视为程序名称并尝试启动它。

It's not really an answer, but in similar configuration to yours I got same error message and unable to overcome this.这不是真正的答案,但在与您类似的配置中,我收到了相同的错误消息并且无法克服这个问题。 For me, switching to lldb helped, see eg对我来说,切换到 lldb 有帮助, 例如

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM