使用命令行 jdb 调试 Android 应用程序
我正在配置 emacs 来调试 Android 应用程序。我的问题是,因为我将 jdb 连接到 DDMS,所以我无法设置正确的类路径(当我尝试将 -classpath 和 -attach 一起设置时,jdb 不会启动)。所以jdb实际上是盲目的——没有类的入口点,没有交互式调试。将调试器附加到 ddms 时如何指定类路径?
I'm configuring emacs to debug android apps. My problem is since I'm attaching jdb to DDMS I cannot set proper classpath (jdb just won't start when I try to set -classpath and -attach together). So jdb is practically blind - no entry point for class, no interactive debugging. How can I specify classpath when attaching debugger to ddms?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 JDB 手册页,“-classpath”属于“转发到调试进程的选项”。换句话说,它不会告诉 jdb 在哪里查找内容,而是告诉正在调试的应用程序在哪里查找内容。
由于您正在连接到正在运行的进程,因此这没有任何意义。
调试进程所需的所有信息都存储在设备上的 DEX 文件中;您不需要主机端 jar/dex 文件来供 jdb 使用。唯一不起作用的是“列表”,但如果你坐在 emacs 中,你可能不需要它。
我已成功使用 jdb 执行各种调试任务。我最常忘记的是,您必须指定完全限定的类名(例如 java.lang.String 而不仅仅是 String)。如果您这样做了,但仍然失败,请在此处粘贴示例 jdb 调试会话。
According to the JDB man page "-classpath" is among the "Options Forwarded to Debuggee Process". In other words, it doesn't tell jdb where to find stuff, it tells the application being debugged where to find stuff.
Since you're connecting to a running process, this doesn't make any sense.
All of the information necessary to debug the process is stored in the DEX files on the device; you don't need host-side jar/dex files for jdb to play with. The only thing that won't work is "list", but if you're sitting in emacs presumably you don't need that.
I have successfully used jdb to perform all sorts of debugging tasks. The thing I forget most often is that you have to specify the fully qualified class name (e.g. java.lang.String rather than just String). If you're doing that, and still getting failures, please paste an example jdb debugging session here.