#local
Allocation_Action_Strings := str.[
- " alloc",
- " free",
+ "alloc",
+ "free",
"resize",
];
res := allocator.func(allocator.data, aa, size, align, oldptr);
use core { tprintf }
- msg := tprintf("{} with size {}, align {}, oldptr {} returns {}\n",
- Allocation_Action_Strings[cast(u32) aa], size, align, oldptr, res);
+ msg := tprintf("{} = {}(size={}, align={}, oldptr={})",
+ res, Allocation_Action_Strings[cast(u32) aa], size, align, oldptr);
log(.Info, "Core", msg);
deserialize :: #match #local {}
#overload
-deserialize :: ($T: type_expr, s: str) -> ?T {
+deserialize :: ($T: type_expr, s: str, allocator := context.allocator) -> ?T {
reader, stream := io.reader_from_string(s);
defer cfree(stream);
target: T;
- if !deserialize(&target, T, &reader) {
+ if !deserialize(&target, T, &reader, allocator) {
// This could leak memory if we partially deserialized something.
return .{};
}
}
#overload
-deserialize :: (target: rawptr, type: type_expr, r: &io.Reader) -> bool {
+deserialize :: (target: rawptr, type: type_expr, r: &io.Reader, allocator := context.allocator) -> bool {
info := type_info.get_type_info(type);
switch info.kind {
case .Enum {
e_info := cast(&type_info.Type_Info_Enum, info);
- try(deserialize(target, e_info.backing_type, r));
+ try(deserialize(target, e_info.backing_type, r, allocator));
}
case .Distinct {
d_info := cast(&type_info.Type_Info_Distinct, info);
- try(deserialize(target, d_info.base_type, r));
+ try(deserialize(target, d_info.base_type, r, allocator));
}
case .Array {
elem_size := type_info.size_of(a_info.of);
for a_info.count {
- try(deserialize(base + it * elem_size, a_info.of, r));
+ try(deserialize(base + it * elem_size, a_info.of, r, allocator));
}
}
untyped_slice := cast(&array.Untyped_Array, target);
untyped_slice.count = count;
- untyped_slice.data = raw_alloc(context.allocator, elem_size * count);
+ untyped_slice.data = raw_alloc(allocator, elem_size * count);
memory.set(untyped_slice.data, 0, elem_size * count);
if info.kind == .Dynamic_Array {
untyped_slice.capacity = count;
- untyped_slice.allocator = context.allocator;
+ untyped_slice.allocator = allocator;
}
base: [&] u8 = untyped_slice.data;
for count {
- try(deserialize(base + it * elem_size, s_info.of, r));
+ try(deserialize(base + it * elem_size, s_info.of, r, allocator));
}
}
base: [&] u8 = target;
for& member: s_info.members {
- try(deserialize(base + member.offset, member.type, r));
+ try(deserialize(base + member.offset, member.type, r, allocator));
}
}
}
u32 command_id = parse_int(debug, ctx);
if (command_id >= sizeof(command_handlers) / sizeof(command_handlers[0])) {
+ printf("[ERROR] Unrecognized command id %x\n", command_id);
send_response_header(debug, msg_id);
return;
}
unlink(local_addr.sun_path); // TODO: Remove this line for the same reason.
int len = strlen(local_addr.sun_path) + sizeof(local_addr.sun_family);
bind(debug->listen_socket_fd, (struct sockaddr *)&local_addr, len);
-
+
//
// Currently, there can only be 1 connected debugger instance at a time.
listen(debug->listen_socket_fd, 1);