JVMTI SetBreakpoint only works on certain instructions
Hello,
I'm developing a java decompiler and bytecode debugger application and have been playing around with JVMTI, in particular the SetBreakpoint function (so i can set a breakpoint on each instruction and step-through them).
For example, I have a simple java method which calls System.out.println(n) several times.
This is the decompiled bytecode:
publicvoid method1(){
//(0):getstatic #0, #18
//(1):ldc #52
//(2):invokevirtual #0, #54
//(3):iconst_0
//(4):istore_1
//(5):iinc #1, #1
//(6):getstatic #0, #18
//(7):ldc #57
//(8):invokevirtual #0, #54
//(9):getstatic #0, #18
//(10):ldc #59
//(11):invokevirtual #0, #54
//(12):getstatic #0, #18
//(13):ldc #61
//(14):invokevirtual #0, #54
//(15):getstatic #0, #18
//(16):ldc #63
...etc
}
I can set a breakpoint on any instruction (with no jvmtiErrors returned), but my breakpoint event handler function in my agent is only called when i set breakpoints on instructions: 0, 3, 5, 8, 9, 10, 13, 16.
When i set a breakpoint on line 2 for example, I get a this erro message from the JVM:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d6d1046, pid=4988, tid=1456
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# V [jvm.dll+0x61046]
#
# An error report file with more information is saved as hs_err_pid4988.log
#
# If you would like to submit a bug report, please visit:
#http://java.sun.com/webapps/bugreport/crash.jsp
#
Does anyone have any idea what the cause of this intermittent behaviour is? It seems very odd that I can set a breakpoint on instruction 8 which is an invokevirtual bytecode, but not on instruction 11 which is also an invokevirtual instruction!
Also, what could be causing the EXCEPTION_ACCESS_VIOLATION error inside the JVM?
Any help would be greatly appreciated.
Thank you for your time.
Joe

