I cloned OpenJDK8's source code and wanted to check where exactly JVMTI's Breakpoint
callback is called. What I found is that all the breakpoints are stored in a list of type JvmtiBreakpoint
. What I couldn't find was where exactly the breakpoint events are fired.
Edit: I found this method, but not sure if this fires the event:
JvmtiExport::post_raw_breakpoint
Which is called by:
InterpreterRuntime:_breakpoint
which lead me to the bytecodeInterpreter.cpp
file, where this method is called. In this file we have:
switch (opcode):
...
CASE(_breakpoint): {
...
CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc), handle_exception);
...}
But I still don't understand what happens when I place a breakpoint in the code? Does the JVM instrument the bytecode at that location and place a breakpoint opcode?
Edit2: I found out that when setting a breakpoint, eventually
Method::set_breakpoint
is called.