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
378378 return noasync printSourceAtAddressPosix(debug_info, out_stream, address, tty_config);
379379}
380380
381/// TODO resources https://github.com/ziglang/zig/issues/4353
381382fn printSourceAtAddressWindows(
382383 di: *DebugInfo,
383384 out_stream: var,
......@@ -604,6 +605,7 @@ pub const TTY = struct {
604605 };
605606};
606607
608/// TODO resources https://github.com/ziglang/zig/issues/4353
607609fn populateModule(di: *DebugInfo, mod: *Module) !void {
608610 if (mod.populated)
609611 return;
......@@ -755,6 +757,7 @@ pub const OpenSelfDebugInfoError = error{
755757 UnsupportedOperatingSystem,
756758};
757759
760/// TODO resources https://github.com/ziglang/zig/issues/4353
758761/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,
759762/// make this `noasync fn` and remove the individual noasync calls.
760763pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {
......@@ -963,6 +966,7 @@ pub fn openDwarfDebugInfo(di: *DwarfInfo, allocator: *mem.Allocator) !void {
963966 try di.scanAllCompileUnits();
964967}
965968
969/// TODO resources https://github.com/ziglang/zig/issues/4353
966970pub fn openElfDebugInfo(
967971 allocator: *mem.Allocator,
968972 data: []u8,
......@@ -997,12 +1001,11 @@ pub fn openElfDebugInfo(
9971001 null,
9981002 };
9991003
1000 efile.close();
1001
10021004 try openDwarfDebugInfo(&di, allocator);
10031005 return di;
10041006}
10051007
1008/// TODO resources https://github.com/ziglang/zig/issues/4353
10061009fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
10071010 var exe_file = try fs.openSelfExe();
10081011 errdefer exe_file.close();
......@@ -1022,6 +1025,7 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
10221025 return openElfDebugInfo(allocator, exe_mmap);
10231026}
10241027
1028/// TODO resources https://github.com/ziglang/zig/issues/4353
10251029fn openSelfDebugInfoMacOs(allocator: *mem.Allocator) !DebugInfo {
10261030 const hdr = &std.c._mh_execute_header;
10271031 assert(hdr.magic == std.macho.MH_MAGIC_64);
......@@ -2074,6 +2078,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con
20742078 return null;
20752079}
20762080
2081/// TODO resources https://github.com/ziglang/zig/issues/4353
20772082fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, address: usize) !LineInfo {
20782083 const ofile = symbol.ofile orelse return error.MissingDebugInfo;
20792084 const gop = try di.ofiles.getOrPut(ofile);