Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

invertego
Copy link
Contributor

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

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.
@invertego
Copy link
Contributor Author

invertego commented Aug 20, 2024

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.

Copy link
Owner

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zherczeg zherczeg merged commit 4c4802d into zherczeg:master Aug 20, 2024
9 of 11 checks passed
@zherczeg
Copy link
Owner

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

@invertego invertego deleted the arm64-brk branch August 21, 2024 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breakpoint opcode encoding on ARM64
2 participants