authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-05 15:56:56-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-02-05 15:56:56-05:00
log378d733439a574cc7b961f1d6a09167479225da8
tree92a2c005cbb6b7f5d83e81a0c20bca92ce78818d
parent40b1fecace87abc2e508bfafea955b3d08266301
parentf30feab1b90fe7fa9c9d05acb18d404a3baf717f
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4345 from Rocknest/open-di

Fix double close in openElfDebugInfo

1 files changed, 7 insertions(+), 2 deletions(-)

lib/std/debug.zig+7-2
...@@ -378,6 +378,7 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us...@@ -378,6 +378,7 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us
378 return noasync printSourceAtAddressPosix(debug_info, out_stream, address, tty_config);378 return noasync printSourceAtAddressPosix(debug_info, out_stream, address, tty_config);
379}379}
380380
381/// TODO resources https://github.com/ziglang/zig/issues/4353
381fn printSourceAtAddressWindows(382fn printSourceAtAddressWindows(
382 di: *DebugInfo,383 di: *DebugInfo,
383 out_stream: var,384 out_stream: var,
...@@ -604,6 +605,7 @@ pub const TTY = struct {...@@ -604,6 +605,7 @@ pub const TTY = struct {
604 };605 };
605};606};
606607
608/// TODO resources https://github.com/ziglang/zig/issues/4353
607fn populateModule(di: *DebugInfo, mod: *Module) !void {609fn populateModule(di: *DebugInfo, mod: *Module) !void {
608 if (mod.populated)610 if (mod.populated)
609 return;611 return;
...@@ -755,6 +757,7 @@ pub const OpenSelfDebugInfoError = error{...@@ -755,6 +757,7 @@ pub const OpenSelfDebugInfoError = error{
755 UnsupportedOperatingSystem,757 UnsupportedOperatingSystem,
756};758};
757759
760/// TODO resources https://github.com/ziglang/zig/issues/4353
758/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,761/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,
759/// make this `noasync fn` and remove the individual noasync calls.762/// make this `noasync fn` and remove the individual noasync calls.
760pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {763pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {
...@@ -963,6 +966,7 @@ pub fn openDwarfDebugInfo(di: *DwarfInfo, allocator: *mem.Allocator) !void {...@@ -963,6 +966,7 @@ pub fn openDwarfDebugInfo(di: *DwarfInfo, allocator: *mem.Allocator) !void {
963 try di.scanAllCompileUnits();966 try di.scanAllCompileUnits();
964}967}
965968
969/// TODO resources https://github.com/ziglang/zig/issues/4353
966pub fn openElfDebugInfo(970pub fn openElfDebugInfo(
967 allocator: *mem.Allocator,971 allocator: *mem.Allocator,
968 data: []u8,972 data: []u8,
...@@ -997,12 +1001,11 @@ pub fn openElfDebugInfo(...@@ -997,12 +1001,11 @@ pub fn openElfDebugInfo(
997 null,1001 null,
998 };1002 };
9991003
1000 efile.close();
1001
1002 try openDwarfDebugInfo(&di, allocator);1004 try openDwarfDebugInfo(&di, allocator);
1003 return di;1005 return di;
1004}1006}
10051007
1008/// TODO resources https://github.com/ziglang/zig/issues/4353
1006fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {1009fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
1007 var exe_file = try fs.openSelfExe();1010 var exe_file = try fs.openSelfExe();
1008 errdefer exe_file.close();1011 errdefer exe_file.close();
...@@ -1022,6 +1025,7 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {...@@ -1022,6 +1025,7 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
1022 return openElfDebugInfo(allocator, exe_mmap);1025 return openElfDebugInfo(allocator, exe_mmap);
1023}1026}
10241027
1028/// TODO resources https://github.com/ziglang/zig/issues/4353
1025fn openSelfDebugInfoMacOs(allocator: *mem.Allocator) !DebugInfo {1029fn openSelfDebugInfoMacOs(allocator: *mem.Allocator) !DebugInfo {
1026 const hdr = &std.c._mh_execute_header;1030 const hdr = &std.c._mh_execute_header;
1027 assert(hdr.magic == std.macho.MH_MAGIC_64);1031 assert(hdr.magic == std.macho.MH_MAGIC_64);
...@@ -2074,6 +2078,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con...@@ -2074,6 +2078,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con
2074 return null;2078 return null;
2075}2079}
20762080
2081/// TODO resources https://github.com/ziglang/zig/issues/4353
2077fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, address: usize) !LineInfo {2082fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, address: usize) !LineInfo {
2078 const ofile = symbol.ofile orelse return error.MissingDebugInfo;2083 const ofile = symbol.ofile orelse return error.MissingDebugInfo;
2079 const gop = try di.ofiles.getOrPut(ofile);2084 const gop = try di.ofiles.getOrPut(ofile);