Compare commits

..

No commits in common. "bc47ff4883dcafb485e411a70d8eb5e823742ff2" and "7ae72ed5a892d2fc6cc3f5511e2b96134d928b59" have entirely different histories.

2 changed files with 9 additions and 26 deletions

View File

@ -195,19 +195,12 @@ pub fn parse(self: *Self, allocator: Allocator, state: *Server.State, emu: *Emul
},
'H' => return .{ .static = "" },
'v' => {
if (substr(self.contents[1..], "MustReplyEmpty")) return .{ .static = "" };
if (substr(self.contents[1..], "Cont")) {
switch (self.contents[5]) {
'?' => return .{ .static = "" }, // TODO: Implement vCont
else => {},
}
}
if (!substr(self.contents[1..], "MustReplyEmpty")) {
log.warn("Unimplemented: {s}", .{self.contents});
}
return .{ .static = "" };
},
'T' => return .{ .static = "OK " }, // We assume single threaded here
'q' => {
if (self.contents[1] == 'C' and self.contents.len == 2) return .{ .static = "QC1" };
@ -215,19 +208,11 @@ pub fn parse(self: *Self, allocator: Allocator, state: *Server.State, emu: *Emul
if (substr(self.contents[1..], "sThreadInfo")) return .{ .static = "l" };
if (substr(self.contents[1..], "Attached")) return .{ .static = "1" }; // Tell GDB we're attached to a process
if (substr(self.contents[1..], "ThreadExtraInfo")) {
const extra_info = "FIXME: what is even expected here?";
const ret = try allocator.dupe(u8, &std.fmt.bytesToHex(extra_info, .lower));
return .{ .alloc = ret };
}
if (substr(self.contents[1..], "Supported")) {
const format = "PacketSize={x:};swbreak+;hwbreak+;qXfer:features:read+;{s}";
const mem_map = if (state.memmap_xml == null) "" else "qXfer:memory-map:read+";
const format = "PacketSize={x:};swbreak+;hwbreak+;qXfer:features:read+;qXfer:memory-map:read+";
// TODO: Anything else?
const ret = try std.fmt.allocPrint(allocator, format, .{ Self.max_len, mem_map });
const ret = try std.fmt.allocPrint(allocator, format, .{Self.max_len});
return .{ .alloc = ret };
}
@ -264,8 +249,6 @@ pub fn parse(self: *Self, allocator: Allocator, state: *Server.State, emu: *Emul
}
if (substr(self.contents[1..], "Xfer:memory-map:read")) {
const mem_map = state.memmap_xml.?;
var tokens = std.mem.tokenize(u8, self.contents[1..], ":,");
_ = tokens.next(); // Xfer
_ = tokens.next(); // memory-map
@ -277,11 +260,11 @@ pub fn parse(self: *Self, allocator: Allocator, state: *Server.State, emu: *Emul
const length = try std.fmt.parseInt(usize, length_str, 16);
// see above
const len = @min(length, (mem_map.len + 1) - offset);
const len = @min(length, (state.memmap_xml.len + 1) - offset);
const ret = try allocator.alloc(u8, len);
ret[0] = if (ret.len < length) 'l' else 'm';
@memcpy(ret[1..], mem_map[offset..]);
@memcpy(ret[1..], state.memmap_xml[offset..]);
return .{ .alloc = ret };
}

View File

@ -21,10 +21,10 @@ emu: Emulator,
pub const State = struct {
should_quit: bool = false,
target_xml: []const u8,
memmap_xml: ?[]const u8,
memmap_xml: []const u8,
};
const Xml = struct { target: []const u8, memory_map: ?[]const u8 };
const Xml = struct { target: []const u8, memory_map: []const u8 };
pub fn init(emulator: Emulator, xml: Xml) !Self {
var server = std.net.StreamServer.init(.{});