[a64] Fix debug break trap codes

The `BRK` instruction code needs to be specified correctly so that a debugger can handle it properly(and continue from it). `brk 0xF000` implements a debug-breakpoint that can be continued from, and `brk 0xF001` is implemented an assertion failing. Any other codes like `0` and `F1` will not be able to be continued from or handled correctly by debuggers.

These seem to be standard brk codes:
```
Breakpoint    0xF000
Assert        0xF001
Debug Service 0xF002
Fastfail      0xF003
Divide by 0   0xF004
```
This commit is contained in:
Wunkolo
2026-03-23 20:05:25 -07:00
committed by Heel
parent 4ed7fa3af3
commit aff3999876
2 changed files with 5 additions and 5 deletions

View File

@@ -335,9 +335,9 @@ ResolveFunctionThunk A64HelperEmitter::EmitResolveFunctionThunk() {
ldp(x29, x30, ptr(sp, 0x50)); ldp(x29, x30, ptr(sp, 0x50));
add(sp, sp, static_cast<uint32_t>(thunk_stack)); add(sp, sp, static_cast<uint32_t>(thunk_stack));
cbz(x9, 8); // skip br x9 if null, fall through to brk cbz(x9, 8); // skip br x9 if null, fall through to brk
br(x9); // Jump to the resolved function (tail call — preserves LR). br(x9); // Jump to the resolved function (tail call — preserves LR).
brk(0xF0); // Resolution failed — trap for debugging. brk(0xF000); // Resolution failed — trap for debugging.
code_offsets.tail = getSize(); code_offsets.tail = getSize();
@@ -446,7 +446,7 @@ void* A64HelperEmitter::EmitGuestAndHostSynchronizeStackHelper() {
L(underflow); L(underflow);
// Should be impossible — stackpoint array underflowed. // Should be impossible — stackpoint array underflowed.
brk(0xF1); brk(0xF001); // assertion failure
code_offsets.epilog = getSize(); code_offsets.epilog = getSize();
code_offsets.tail = getSize(); code_offsets.tail = getSize();

View File

@@ -318,7 +318,7 @@ void A64Emitter::MarkSourceOffset(const hir::Instr* i) {
entry->code_offset = static_cast<uint32_t>(getSize()); entry->code_offset = static_cast<uint32_t>(getSize());
} }
void A64Emitter::DebugBreak() { brk(0); } void A64Emitter::DebugBreak() { brk(0xF000); }
void A64Emitter::Trap(uint16_t trap_type) { brk(trap_type); } void A64Emitter::Trap(uint16_t trap_type) { brk(trap_type); }