diff options
Diffstat (limited to 'src/cli')
| -rw-r--r-- | src/cli/serve.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cli/serve.zig b/src/cli/serve.zig index 2361a2f..47ec1ed 100644 --- a/src/cli/serve.zig +++ b/src/cli/serve.zig @@ -99,6 +99,7 @@ pub fn run(init: std.process.Init, args: []const [:0]const u8) !void { try server.reply(&d, if (d.done) .exited else .failed, @errorName(err), 0); continue; }; + if ((std.mem.eql(u8, cmd, "inspect") or std.mem.eql(u8, cmd, "symbols")) and rec.delta.items.len > 0) try rec.commit(); try rec.flush(); const elapsed: u64 = @intCast(started.durationTo(std.Io.Clock.awake.now(init.io)).toNanoseconds()); try server.reply(&d, if (d.done) .exited else .stopped, reason, elapsed); @@ -115,6 +116,20 @@ fn execute(d: *zt.Debugger, s: *Server, cmd: []const u8, arg: []const u8, buf: [ const sig = try std.fmt.parseInt(u32, arg, 0); if (sig > 64) return error.InvalidSignal; d.proc.resume_signal = sig; + } else if (std.mem.eql(u8, cmd, "symbols")) { + if (arg.len == 0) return error.MissingPath; + try d.loadJit(arg); + return "JIT symbols loaded; target unchanged"; + } else if (std.mem.eql(u8, cmd, "inspect")) { + var words = std.mem.tokenizeScalar(u8, arg, ' '); + const kind = words.next() orelse return error.MissingKind; + const address = try std.fmt.parseInt(u64, words.next() orelse return error.MissingAddress, 0); + const count = try std.fmt.parseInt(usize, words.next() orelse return error.MissingCount, 0); + if (words.next() != null or count == 0 or count > 4096) return error.InvalidCount; + if (std.mem.eql(u8, kind, "code")) try d.inspectCode(address, count) else if (std.mem.eql(u8, kind, "memory")) { + try d.snapshot(address, @min(count, std.math.maxInt(u64) - address)); + } else return error.InvalidKind; + return "inspected; target unchanged"; } else if (std.mem.eql(u8, cmd, "continue") or std.mem.eql(u8, cmd, "stepi") or std.mem.eql(u8, cmd, "step")) { try s.reply(d, .running, cmd, 0); const stop = if (std.mem.eql(u8, cmd, "continue")) try d.cont() else if (std.mem.eql(u8, cmd, "stepi")) try d.stepi() else try d.step(); |
