zherczeg / sljit

Platform independent low-level JIT compiler
Other
843 stars 74 forks source link

Emit brk #0xf000 for breakpoint opcode on arm64 #267

Closed invertego closed 2 months ago

invertego commented 2 months ago

Implement SLJIT_BREAKPOINT with the same instruction emitted by MSVC for the debugbreak intrinsic (brk #0xf000) and by Clang for builtin_debugtrap. On Windows, this triggers a breakpoint exception just as int3 does on x86. The previously emitted instruction (brk #0) triggers an illegal instruction exception instead.

LLDB also has special handling for this brk variant on Windows and macOS, automatically advancing to the next instruction so execution can be easily continued.

Fixes #266

invertego commented 2 months ago

I can move the immediate directly into the definition of BRK if desired (i.e. #define BRK 0xd43e0000 ). I did it this way to make the choice of immediate more readily apparent.

zherczeg commented 2 months ago

The hint is not part of the instruction, its an argument, so it is better this way.