1

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.

Nfff3
  • 321
  • 8
  • 24
  • Please don't include "thanks" or " Can you help me with this please?". See here for more: https://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts – PiRocks May 09 '20 at 15:05
  • The answer to this question likely depends on if the jvm is interpreting the code in question, or if it had JIT'ed the code. Do you care about both cases? – PiRocks May 10 '20 at 14:01
  • @PiRocks For my use case, I am only interested when the app is run in debug mode. Is JIT activated in that case? – Nfff3 May 11 '20 at 06:17
  • What do you mean by "run in debug mode"? JIT absolutely can be activated while the app is being debugged. Some vms can breakpoint in jit'ed code, I'm not certain how things work in hotspot – PiRocks May 11 '20 at 06:39
  • @PiRocks yeah, I thought JIT is not activated in debug mode. But activating a breakpoint in JITed code is interesting, didn't know about that... – Nfff3 May 11 '20 at 06:59

0 Answers0