Search code examples
javajvmbreakpoints

Why is the JDK's BREAKPOINT define given special values on ARM?


Here is the breakpoint code in jdk.

#ifdef ARM
  #ifdef SOLARIS
    #define BREAKPOINT __asm__ volatile (".long 0xe1200070")
  #else
    #define BREAKPOINT __asm__ volatile (".long 0xe7f001f0")
  #endif
#else
  extern "C" void breakpoint();
  #define BREAKPOINT ::breakpoint()
#endif

I want to know whether '.long 0xe1200070' and '.long 0xe7f001f0' have special meanings?


Solution

  • When porting HotSpot to ARM I've found useful to have a breakpoint inlined rather than call an external breakpoint() function. If JVM reaches this place, there will be a meaningful context of the crash: nearby instructions and relevant register values.

    .long 0xe7f001f0 is the encoding for undefined instruction. ARM 0x.7f...f. instruction space is reserved to generate undefined instruction exception. Obviously there is no mnemonic for it, hence the numeric literal. GDB uses the same opcode for breakpoints on arm-eabi.

    .long 0xe1200070 is the manually encoded BKPT opcode. I haven't seen Solaris/ARM platforms, but I guess this is how breakpoints are typically encoded there.