4

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?

RichieHH
  • 2,116
  • 4
  • 28
  • 30

2 Answers2

2

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/

rofer
  • 1,211
  • 2
  • 12
  • 16
0

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 via use 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:

<workingDir>$ javap -l MainActivity
    Warning: File ./MainActivity.class does not contain class MainActivity
    Compiled from "MainActivity.java"
Hölderlin
  • 424
  • 1
  • 3
  • 16