jdb 与 Android 应用程序 - 无法打开源文件
我希望使用 jdb 通过 ddms 来调试模拟器中的 Android 应用程序。
我已成功在类的 onCreate 中设置断点,并且调试器 (jdb) 适当中断。但是,如果我尝试“列出”代码,它会说找不到源文件。我从 emacs 中像这样启动 jdb :-
jdb -sourcepath="~/programming/android/projects/myproj/src/net/richardriley/myproj" -attach localhost:8700
并且我知道 myact.java 位于该目录中。我是 jdb 新手,但是 sourcepath 不是处理这个问题的方法吗?如果不是我应该做什么?
I am hoping to use jdb to debug android apps in the emulator via the ddms go between.
I have successfully set a breakpoint in my class' onCreate and the debugger (jdb) duly breaks. However if I try to "list" the code it says it can not find the source file. I start jdb like this from emacs :-
jdb -sourcepath="~/programming/android/projects/myproj/src/net/richardriley/myproj" -attach localhost:8700
and I know for a fact that myact.java is there in that directory. I am a jdb newbie but isnt sourcepath the way to deal with this? And if not what should I be doing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己也是一个JDB新手,我终于找到了如何解决这个问题。
您需要位于 src 文件夹中,而不是位于源文件所在的目录中。这样JDB就可以根据包名找到你的源文件(如果我没记错的话)。
因此,如果您有一个文件 ~/programming/android/projects/myproj/src/net/richardriley/myproj/SomeClass.java 您将在 JDB 中将其引用为 net.richardriley.myproj.SomeClass 并且您会将源路径设置为 ~ /编程/android/项目/myproj/src/
I'm a JDB newbie myself and I finally figured out how to solve this problem.
You need to be in the src folder rather than right in the directory with the source files. That way JDB can follow the package name to find your source files (if I'm not mistaken).
So if you have a file ~/programming/android/projects/myproj/src/net/richardriley/myproj/SomeClass.java you would refer to it in JDB as net.richardriley.myproj.SomeClass and you would set your sourcepath to ~/programming/android/projects/myproj/src/
我遇到了与SO相同的问题,除了提供的解决方案之外,我想指出,您需要从正确的目录执行JDB,在您的情况下
~/programming/android/projects/myproj/src/< /代码>。
如果从不同位置执行 JDB,即使您定义了正确的源路径,
list
命令也将不起作用。或者,即使您通过use
命令更改 JDB 控制台中的源路径。要确定正确的工作目录,您可以使用 javap 检查调试信息。以下警告表明您没有设置正确的工作目录:
I ran into same issue as SO, and in addition to the provided solution, I want to point out, you need to execute JDB from correct directory, in your case
~/programming/android/projects/myproj/src/
.The
list
command will not work if you execute JDB from a different location, even if you have defined the correct source path. Or even if you change the the source path within the JDB console viause
command.To determine correct working directory, you can use
javap
to check for debug information. The following warning indicates that you have not set up the correct working directory: