//! Small control messages shared by a debugger controller and its clients. const std = @import("std"); pub const Status = enum { stopped, running, exited, failed }; pub const Reply = struct { status: Status, pid: i32, tid: u32, moments: u64, pc: u64, elapsed_ns: u64 = 0, reason: []const u8 = "", }; pub fn send(w: *std.Io.Writer, reply: Reply) !void { try std.json.Stringify.value(reply, .{}, w); try w.writeByte('\n'); try w.flush(); } test "control messages preserve 64-bit addresses" { var buf: [512]u8 = undefined; var w: std.Io.Writer = .fixed(&buf); const value: Reply = .{ .status = .stopped, .pid = 1, .tid = 2, .moments = 3, .pc = 0xffffffffffffffff }; try send(&w, value); const parsed = try std.json.parseFromSlice(Reply, std.testing.allocator, w.buffered(), .{}); defer parsed.deinit(); try std.testing.expectEqual(value.pc, parsed.value.pc); }