Hi guys, It's been some time since I last juggled with SA, but IIRC when I wanted to take shortcuts of using SA between minor version mismatches, I used to just run the SA tool with the matching version of sa-jdi.jar with the target process.
i.e. if I wanted to run an SA tool from a JDK8u162 against a target process of JDK8u151, I'd just run the SA tool with the JDK8u151's sa-jdi.jar on the classpath, like <jdk8u162>/bin/java -cp <jdk8u151>/lib/sa-jdi.jar ... And I keep a folder of these sa-jdi.jar's for each matching version so that I can quickly do things that I want with the my default Java... I had to do that a lot because sometime when I recompile just HotSpot but not the whole JDK, I have scripts that manually copy the HotSpot artifacts into an existing JDK and that updates the JDK's sa-jdi.jar to match the it, but the JVM itself might not be stable enough, so it's a non-starter to run the SA tool on that JDK directly. Instead I run SA tools from a separate stable JDK with the new sa-jdi.jar on the classpath for debugging this new build of HotSpot. - Kris On Mon, Aug 20, 2018 at 10:32 AM, Sharath Ballal <sharath.bal...@oracle.com> wrote: > Hi Egor, > > Please note that, though SA can be used with the > "-Dsun.jvm.hotspot.runtime.VM.disableVersionCheck", it is recommended to > use the same version for the debugger and debugee. > > > Thanks, > Sharath > > > -----Original Message----- > From: Sharath Ballal > Sent: Monday, August 20, 2018 10:38 PM > To: Egor Ushakov; serviceability-dev@openjdk.java.net > serviceability-dev@openjdk.java.net > Subject: RE: SA Debug attach to another jvm version possible? > > Hello Egor, > > By default, SA checks for the exact match of the version between the > debugger and the debuggee. If you want SA to ignore the version, you need > to provide the "-Dsun.jvm.hotspot.runtime.VM.disableVersionCheck" option > to the java launcher from the command line. This is the case even if you > are not using the debug server. However since 'jstack' and similar tools > don’t take the "-D" option of java, you can invoke it as follows: > > java -cp <jdk>/lib/sa-jdi.jar > -Dsun.jvm.hotspot.runtime.VM.disableVersionCheck > sun.jvm.hotspot.tools.JStack localhost > > If you invoke the SA tools with this option, you will get a warning that > the version check has been disabled. > > Example: > $ <jdk>/bin/java -cp <jdk>/lib/sa-jdi.jar > -Dsun.jvm.hotspot.runtime.VM.disableVersionCheck > sun.jvm.hotspot.tools.JStack localhost > Attaching to remote server localhost, please wait... > WARNING: You have disabled SA and VM version check. You may be using > incompatible version of SA and you may see unexpected results. > Debugger attached successfully. > Server compiler detected. > JVM version is 25.121-b13 > Deadlock Detection: > > No deadlocks found. > > Thread t@ 2804: (state = BLOCKED) > > > Thread t@ 2803: (state = BLOCKED) > - java.lang.Object.wait(long) @bci=0 (Interpreted frame) > - java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=143 > (Interpreted frame) > - java.lang.ref.ReferenceQueue.remove() @bci=2, line=164 (Interpreted > frame) > - java.lang.ref.Finalizer$FinalizerThread.run() @bci=36, line=209 > (Interpreted frame) > > > Thread t@ 2802: (state = BLOCKED) > - java.lang.Object.wait(long) @bci=0 (Interpreted frame) > - java.lang.Object.wait() @bci=2, line=502 (Interpreted frame) > - java.lang.ref.Reference.tryHandlePending(boolean) @bci=54, line=191 > (Interpreted frame) > - java.lang.ref.Reference$ReferenceHandler.run() @bci=1, line=153 > (Interpreted frame) > > > Thread t@ 2798: (state = BLOCKED) > - java.lang.Thread.sleep(long) @bci=0 (Interpreted frame) > - HelloWorld.main(java.lang.String[]) @bci=72, line=15 (Interpreted > frame) > > > Hope this helps. > > Thanks, > Sharath > > > -----Original Message----- > From: Egor Ushakov [mailto:egor.usha...@jetbrains.com] > Sent: Monday, August 20, 2018 3:42 PM > To: serviceability-dev@openjdk.java.net serviceability-dev@openjdk. > java.net > Subject: SA Debug attach to another jvm version possible? > > Hi all, > > documentation for SA Debug Server Attaching Connector here: > https://docs.oracle.com/javase/8/docs/technotes/guides/jpda/conninv.html# > Connectors > states that the SADebugServer has to run on the same vm version as the > debugee process, but "the debugger does not have to be the same bit size > and version." > However any attempts to connect from another version fail with > sun.jvm.hotspot.runtime.VMVersionMismatchException. > > Please help, what do I do wrong (locally for simplicity): > - start the debugee process with jdk1.8.0_162 - get the PID > - start "jdk1.8.0_162\bin>jsadebugd.exe PID" - all starts well > - trying to attach jstack, jdb or whatever from another version: > jdk1.8.0_152\bin>jstack localhost > Attaching to remote server localhost, please wait... > Error attaching to remote server: > sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions > are 25.152-b16. Target VM is 25.162-b12 > sun.jvm.hotspot.debugger.DebuggerException: > sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions > are 25.152-b16. Target VM is 25.162-b12 > > jdk1.8.0_152\bin>jdb -connect > "sun.jvm.hotspot.jdi.SADebugServerAttachingConnecto > r:debugServerName=localhost" > java.io.IOException > at > sun.jvm.hotspot.jdi.SADebugServerAttachingConnector.attach( > SADebugServerAttachingConnector.java:106) > 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.SADebugServerAttachingConnector.createVirtualMachine( > SADebugServerAttachingConnector.java:72) > at > sun.jvm.hotspot.jdi.SADebugServerAttachingConnector.attach( > SADebugServerAttachingConnector.java:91) > ... 4 more > Caused by: sun.jvm.hotspot.debugger.DebuggerException: > sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions > are 25.152-b16. Target VM is 25.162-b12 > 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:183) > at > sun.jvm.hotspot.jdi.VirtualMachineImpl.createVirtualMachineForServer( > VirtualMachineImpl.java:241) > ... 10 more > Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported > versions are 25.152-b16. Target VM is 25.162-b12 > 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 > > Thanks! > > -- > Egor Ushakov > Software Developer > JetBrains > http://www.jetbrains.com > The Drive to Develop > >