| ... | @@ -682,7 +682,6 @@ test "machoSearchSymbols" { | ... | @@ -682,7 +682,6 @@ test "machoSearchSymbols" { |
| 682 | try testing.expectEqual(&symbols[2], machoSearchSymbols(&symbols, 5000).?); | 682 | try testing.expectEqual(&symbols[2], machoSearchSymbols(&symbols, 5000).?); |
| 683 | } | 683 | } |
| 684 | | 684 | |
| 685 | /// TODO resources https://github.com/ziglang/zig/issues/4353 | | |
| 686 | pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: TTY.Config) !void { | 685 | pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: TTY.Config) !void { |
| 687 | const module = debug_info.getModuleForAddress(address) catch |err| switch (err) { | 686 | const module = debug_info.getModuleForAddress(address) catch |err| switch (err) { |
| 688 | error.MissingDebugInfo, error.InvalidDebugInfo => { | 687 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| ... | @@ -768,7 +767,6 @@ pub const OpenSelfDebugInfoError = error{ | ... | @@ -768,7 +767,6 @@ pub const OpenSelfDebugInfoError = error{ |
| 768 | UnsupportedOperatingSystem, | 767 | UnsupportedOperatingSystem, |
| 769 | }; | 768 | }; |
| 770 | | 769 | |
| 771 | /// TODO resources https://github.com/ziglang/zig/issues/4353 | | |
| 772 | pub fn openSelfDebugInfo(allocator: mem.Allocator) anyerror!DebugInfo { | 770 | pub fn openSelfDebugInfo(allocator: mem.Allocator) anyerror!DebugInfo { |
| 773 | nosuspend { | 771 | nosuspend { |
| 774 | if (builtin.strip_debug_info) | 772 | if (builtin.strip_debug_info) |
| ... | @@ -793,7 +791,6 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) anyerror!DebugInfo { | ... | @@ -793,7 +791,6 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) anyerror!DebugInfo { |
| 793 | | 791 | |
| 794 | /// This takes ownership of coff_file: users of this function should not close | 792 | /// This takes ownership of coff_file: users of this function should not close |
| 795 | /// it themselves, even on error. | 793 | /// it themselves, even on error. |
| 796 | /// TODO resources https://github.com/ziglang/zig/issues/4353 | | |
| 797 | /// TODO it's weird to take ownership even on error, rework this code. | 794 | /// TODO it's weird to take ownership even on error, rework this code. |
| 798 | fn readCoffDebugInfo(allocator: mem.Allocator, coff_file: File) !ModuleDebugInfo { | 795 | fn readCoffDebugInfo(allocator: mem.Allocator, coff_file: File) !ModuleDebugInfo { |
| 799 | nosuspend { | 796 | nosuspend { |
| ... | @@ -863,7 +860,6 @@ fn chopSlice(ptr: []const u8, offset: u64, size: u64) ![]const u8 { | ... | @@ -863,7 +860,6 @@ fn chopSlice(ptr: []const u8, offset: u64, size: u64) ![]const u8 { |
| 863 | | 860 | |
| 864 | /// This takes ownership of elf_file: users of this function should not close | 861 | /// This takes ownership of elf_file: users of this function should not close |
| 865 | /// it themselves, even on error. | 862 | /// it themselves, even on error. |
| 866 | /// TODO resources https://github.com/ziglang/zig/issues/4353 | | |
| 867 | /// TODO it's weird to take ownership even on error, rework this code. | 863 | /// TODO it's weird to take ownership even on error, rework this code. |
| 868 | pub fn readElfDebugInfo(allocator: mem.Allocator, elf_file: File) !ModuleDebugInfo { | 864 | pub fn readElfDebugInfo(allocator: mem.Allocator, elf_file: File) !ModuleDebugInfo { |
| 869 | nosuspend { | 865 | nosuspend { |
| ... | @@ -937,7 +933,6 @@ pub fn readElfDebugInfo(allocator: mem.Allocator, elf_file: File) !ModuleDebugIn | ... | @@ -937,7 +933,6 @@ pub fn readElfDebugInfo(allocator: mem.Allocator, elf_file: File) !ModuleDebugIn |
| 937 | } | 933 | } |
| 938 | } | 934 | } |
| 939 | | 935 | |
| 940 | /// TODO resources https://github.com/ziglang/zig/issues/4353 | | |
| 941 | /// This takes ownership of macho_file: users of this function should not close | 936 | /// This takes ownership of macho_file: users of this function should not close |
| 942 | /// it themselves, even on error. | 937 | /// it themselves, even on error. |
| 943 | /// TODO it's weird to take ownership even on error, rework this code. | 938 | /// TODO it's weird to take ownership even on error, rework this code. |
| ... | @@ -1934,3 +1929,16 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void { | ... | @@ -1934,3 +1929,16 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void { |
| 1934 | ); | 1929 | ); |
| 1935 | std.debug.print("{} sp = 0x{x}\n", .{ prefix, sp }); | 1930 | std.debug.print("{} sp = 0x{x}\n", .{ prefix, sp }); |
| 1936 | } | 1931 | } |
| | 1932 | |
| | 1933 | test "#4353: std.debug should manage resources correctly" { |
| | 1934 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| | 1935 | |
| | 1936 | const writer = std.io.null_writer; |
| | 1937 | var di = try openSelfDebugInfo(testing.allocator); |
| | 1938 | defer di.deinit(); |
| | 1939 | try printSourceAtAddress(&di, writer, showMyTrace(), detectTTYConfig()); |
| | 1940 | } |
| | 1941 | |
| | 1942 | noinline fn showMyTrace() usize { |
| | 1943 | return @returnAddress(); |
| | 1944 | } |