Reputation: 59635
I need to debug a Java application I have no source code for. It is running locally on a Jetty server. Decompiling using JD-GUI works fine. Attaching JDB via a socket connection or shared memory works fine, too.
Where I fail is joining the pieces together. I mainly tried Eclipse with the JD-Eclipse plugin and remote debugging. I failed to find a way to successfully attach the debugger to a running process. Everything seems to assume that I have at least parts of the application available as source code in a project, but I have not. And it is quite a large application (200+ MiB of JAR files and 500+ MiB of other stuff) so trying to build a project from all the decompiled classes and getting this to run is not an option unless it is easy to automate.
What I really need is being able to attach a debugger to a running process, see and navigate the decompiled code, set breakpoints and inspect variables and objects. It does not matter if the code could be recompiled. Conditional breakpoints and expression evaluation would be nice to have.
Upvotes: 9
Views: 14292
Reputation: 1967
here is a possible solution:
java -agentlib:jdwp=transport=dt_shmem,address=XXXXX,server=y,suspend=n -jar YourJar
jdb -attach XXXXX
stop at <TheClassName>:<ThePosition>
I will try it when I'm free, will update if it works
I've figured it out today:
unzip jar file
jdb -sourcepath [unzipped jar path] -classpath [your main class path]
after jdb initializing, excute:
stop at <package>.<yourclass>:<linenunmber>
run <your main class, for example org.springframework.boot.loader.JarLauncher>
Upvotes: 1
Reputation: 5642
You can probably do this with the help of a combination of jd-eclipse and its extension jd-eclipse realignment fragment.
The process for installing this is quite simple:
Upvotes: 2