Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ares/n64/cpu/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ struct CPU : Thread {
Exception(CPU& self) : self(self) {}

auto trigger(u32 code, u32 coprocessor = 0, bool tlbMiss = 0) -> void;
auto reportGDBException(int code, u64 pc) -> void;

auto interrupt() -> void;
auto tlbModification() -> void;
Expand Down
27 changes: 22 additions & 5 deletions ares/n64/cpu/exceptions.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
auto CPU::Exception::trigger(u32 code, u32 coprocessor, bool tlbMiss) -> void {
self.debugger.exception(code);

if(code != 0) {
auto sig = (code == 2 || code == 3) ? GDB::Signal::SEGV : GDB::Signal::TRAP;
GDB::server.reportSignal(sig, self.ipu.pc);
}
reportGDBException(code, self.ipu.pc);

u64 vectorBase = !self.scc.status.vectorLocation ? (s32)0x8000'0000 : (s32)0xbfc0'0200;

Expand Down Expand Up @@ -64,3 +60,24 @@ auto CPU::Exception::nmi() -> void {
self.scc.epcError = self.ipu.pc;
self.pipeline.setPc(0xffff'ffff'bfc0'0000);
}

auto CPU::Exception::reportGDBException(int code, u64 pc) -> void {
switch(code) {
case 0: GDB::server.reportSignal(GDB::Signal::WINCH, pc); break; // ignored by default
case 1: GDB::server.reportSignal(GDB::Signal::SEGV, pc); break;
case 2: GDB::server.reportSignal(GDB::Signal::SEGV, pc); break;
case 3: GDB::server.reportSignal(GDB::Signal::SEGV, pc); break;
case 4: GDB::server.reportSignal(GDB::Signal::BUS, pc); break;
case 5: GDB::server.reportSignal(GDB::Signal::BUS, pc); break;
case 6: GDB::server.reportSignal(GDB::Signal::ABORT, pc); break;
case 7: GDB::server.reportSignal(GDB::Signal::ABORT, pc); break;
case 8: GDB::server.reportSignal(GDB::Signal::SYS, pc); break;
case 9: GDB::server.reportSignal(GDB::Signal::STOP, pc); break;
case 10: GDB::server.reportSignal(GDB::Signal::ILL, pc); break;
case 11: GDB::server.reportSignal(GDB::Signal::URG, pc); break; // ignored by default
case 12: GDB::server.reportSignal(GDB::Signal::FPE, pc); break;
case 13: GDB::server.reportSignal(GDB::Signal::TRAP, pc); break;
case 15: GDB::server.reportSignal(GDB::Signal::FPE, pc); break;
case 23: GDB::server.reportSignal(GDB::Signal::LOST, pc); break;
}
}
21 changes: 20 additions & 1 deletion nall/gdb/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,29 @@ enum class Signal : u8 {
HANGUP = 1,
INT = 2,
QUIT = 3,
ILLEGAL = 4,
ILL = 4,
TRAP = 5,
ABORT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
PROF = 27,
WINCH = 28,
LOST = 29,
};

/**
Expand Down
Loading