diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-05 21:28:18 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:51 +0100 |
| commit | 9859440d83e5ef17d353be39f32f2dc0b9ce0e02 (patch) | |
| tree | c94b29a9be0a120d6df33509d50e46915f488a82 /lib/std/debug.zig | |
| parent | c2ada49354897f89a2e2030ad1e083a8ee9b7c3b (diff) | |
| download | zig-9859440d83e5ef17d353be39f32f2dc0b9ce0e02.tar.gz zig-9859440d83e5ef17d353be39f32f2dc0b9ce0e02.zip | |
add freestanding support IN THEORY
untested because this branch has errors rn
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index bc2610fb7c..f2d15e3fe8 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -14,6 +14,8 @@ const builtin = @import("builtin"); const native_arch = builtin.cpu.arch; const native_os = builtin.os.tag; +const root = @import("root"); + pub const Dwarf = @import("debug/Dwarf.zig"); pub const Pdb = @import("debug/Pdb.zig"); pub const SelfInfo = @import("debug/SelfInfo.zig"); @@ -942,19 +944,15 @@ fn printLineInfo( tty_config.setColor(writer, .reset) catch {}; } try writer.writeAll("\n"); - } else |err| switch (err) { - error.WriteFailed => |e| return e, - else => { - // Ignore everything else. Seeing some lines in the trace without the associated - // source line printed is a far better user experience than interleaving the - // trace with a load of filesystem error crap. The user can always just open the - // source file themselves to see the line. - }, } } } } fn printLineFromFile(writer: *Writer, source_location: SourceLocation) !void { + if (@hasDecl(root, "debug") and @hasDecl(root.debug, "printLineFromFile")) { + return root.debug.printLineFromFile(writer, source_location); + } + // Need this to always block even in async I/O mode, because this could potentially // be called from e.g. the event loop code crashing. var f = try fs.cwd().openFile(source_location.file_name, .{}); @@ -1139,11 +1137,16 @@ test printLineFromFile { /// TODO multithreaded awareness var debug_info_arena: ?std.heap.ArenaAllocator = null; +var debug_info_fba: std.heap.FixedBufferAllocator = .init(&debug_info_fba_buf); +var debug_info_fba_buf: [1024 * 1024 * 4]u8 = undefined; fn getDebugInfoAllocator() mem.Allocator { - if (debug_info_arena == null) { - debug_info_arena = .init(std.heap.page_allocator); + if (false) { + if (debug_info_arena == null) { + debug_info_arena = .init(std.heap.page_allocator); + } + return debug_info_arena.?.allocator(); } - return debug_info_arena.?.allocator(); + return debug_info_fba.allocator(); } /// Whether or not the current target can print useful debug information when a segfault occurs. |
