tmp: progress towards gdb stub

This commit is contained in:
2023-12-15 00:49:29 -06:00
parent 7f98f4cc26
commit ed72427c71
5 changed files with 50 additions and 1 deletions

42
src/gdb.zig Normal file
View File

@@ -0,0 +1,42 @@
const std = @import("std");
const Server = @import("gdbstub").Server;
const Interface = @import("gdbstub").Emulator;
const System = @import("core/emu.zig").System;
const Scheduler = @import("core/Scheduler.zig");
const Allocator = std.mem.Allocator;
pub const TurboWrapper = struct {
system: System,
scheduler: *Scheduler,
pub fn init(system: System, scheduler: *Scheduler) @This() {
return .{ .system = system, .scheduler = scheduler };
}
pub fn interface(self: *@This(), allocator: Allocator) Interface {
return Interface.init(allocator, self);
}
pub fn read(self: *const @This(), addr: u32) u8 {
return self.cpu.bus.dbgRead(u8, addr);
}
pub fn write(self: *@This(), addr: u32, value: u8) void {
self.cpu.bus.dbgWrite(u8, addr, value);
}
pub fn registers(self: *const @This()) *[16]u32 {
return &self.cpu.r;
}
pub fn cpsr(self: *const @This()) u32 {
return self.cpu.cpsr.raw;
}
pub fn step(self: *@This()) void {
_ = self;
@panic("TODO: Handle ARM7 and ARM9 lol");
}
};

View File

@@ -14,6 +14,7 @@ const ClapResult = clap.Result(clap.Help, &cli_params, clap.parsers.default);
const cli_params = clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-f, --firm <str> Path to NDS Firmware Directory
\\--gdb Run Turbo in GDB Mode
\\<str> Path to the NDS ROM
\\
);