Need to debug already running java program

0

I am trying to debug already running java program. I have performed following at my end but getting version issues. I am using CentOS 6.8.

I have attached to the program using gdb and seeing around 1370 lower level threads, most of the threads show stack pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0, some as pthread_cond_timedwait@@GLIBC_2.3.2 and epoll_wait, now I am unable to figure out the actual java source code, for this I am trying jdb, installed jdb using "sudo yum install java-1.8.0-openjdk-devel", connecting to process using command ** sudo jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=13204** but getting following errors

sudo jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=13204
    java.io.IOException
        at sun.jvm.hotspot.jdi.SAPIDAttachingConnector.attach(SAPIDAttachingConnector.java:126)
        at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
        at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
        at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
        at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1082)
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.jvm.hotspot.jdi.SAPIDAttachingConnector.createVirtualMachine(SAPIDAttachingConnector.java:87)
        at sun.jvm.hotspot.jdi.SAPIDAttachingConnector.attach(SAPIDAttachingConnector.java:111)
        ... 4 more
    Caused by: sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.121-b13. Target VM is 25.51-b03
        at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:435)
        at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
        at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
        at sun.jvm.hotspot.jdi.VirtualMachineImpl.createVirtualMachineForPID(VirtualMachineImpl.java:222)
        ... 10 more
    Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.121-b13. Target VM is 25.51-b03
        at sun.jvm.hotspot.runtime.VM.checkVMVersion(VM.java:227)
        at sun.jvm.hotspot.runtime.VM.<init>(VM.java:294)
        at sun.jvm.hotspot.runtime.VM.initialize(VM.java:370)
        at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:431)
        ... 13 more

    Fatal error:
    Unable to attach to target VM.

I am executing command "sudo yum --showduplicates list java-1.8.0-openjdk-devel" to see if I can install required version, but its not shown in the list.

So just to rephrase my question , I need to connect to already running java program ( which was started without any debug options) for debugging. Any help is appreciated. Thanks.

sarslan

Posted 2019-04-22T13:09:55.623

Reputation: 1

No answers