@zigc/lib 0.16.0-test.1 → 0.17.0-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/c/math.zig +135 -35
- package/c/stropts.zig +17 -0
- package/c.zig +1 -0
- package/compiler/aro/aro/Attribute/names.zig +604 -589
- package/compiler/aro/aro/Attribute.zig +202 -116
- package/compiler/aro/aro/Builtins/common.zig +874 -863
- package/compiler/aro/aro/Builtins/eval.zig +15 -7
- package/compiler/aro/aro/Builtins.zig +0 -1
- package/compiler/aro/aro/CodeGen.zig +3 -1
- package/compiler/aro/aro/Compilation.zig +120 -97
- package/compiler/aro/aro/Diagnostics.zig +21 -17
- package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
- package/compiler/aro/aro/Driver.zig +124 -50
- package/compiler/aro/aro/LangOpts.zig +12 -2
- package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
- package/compiler/aro/aro/Parser.zig +336 -142
- package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
- package/compiler/aro/aro/Preprocessor.zig +127 -56
- package/compiler/aro/aro/Target.zig +17 -12
- package/compiler/aro/aro/Tokenizer.zig +31 -14
- package/compiler/aro/aro/Toolchain.zig +4 -7
- package/compiler/aro/aro/Tree.zig +178 -148
- package/compiler/aro/aro/TypeStore.zig +82 -24
- package/compiler/aro/aro/Value.zig +13 -17
- package/compiler/aro/aro/features.zig +1 -0
- package/compiler/aro/aro/pragmas/once.zig +0 -1
- package/compiler/aro/aro/record_layout.zig +3 -3
- package/compiler/aro/assembly_backend/x86_64.zig +3 -4
- package/compiler/aro/backend/Assembly.zig +1 -2
- package/compiler/aro/backend/Interner.zig +2 -2
- package/compiler/aro/backend/Ir.zig +100 -92
- package/compiler/aro/include/ptrcheck.h +49 -0
- package/compiler/aro/main.zig +26 -10
- package/compiler/build_runner.zig +1 -0
- package/compiler/objdump.zig +93 -0
- package/compiler/reduce.zig +5 -1
- package/compiler/resinator/compile.zig +2 -2
- package/compiler/resinator/main.zig +7 -1
- package/compiler/resinator/preprocess.zig +1 -3
- package/compiler/std-docs.zig +8 -1
- package/compiler/test_runner.zig +193 -61
- package/compiler/translate-c/MacroTranslator.zig +80 -11
- package/compiler/translate-c/PatternList.zig +1 -9
- package/compiler/translate-c/Scope.zig +43 -6
- package/compiler/translate-c/Translator.zig +364 -126
- package/compiler/translate-c/ast.zig +19 -11
- package/compiler/translate-c/main.zig +75 -16
- package/compiler_rt/cos.zig +141 -52
- package/compiler_rt/limb64.zig +266 -0
- package/compiler_rt/long_double.zig +37 -0
- package/compiler_rt/mulo.zig +6 -1
- package/compiler_rt/rem_pio2l.zig +173 -0
- package/compiler_rt/sin.zig +140 -55
- package/compiler_rt/sincos.zig +279 -72
- package/compiler_rt/tan.zig +118 -47
- package/compiler_rt/trig.zig +256 -6
- package/compiler_rt.zig +2 -0
- package/fuzzer.zig +855 -307
- package/libc/musl/src/math/pow.c +343 -0
- package/package.json +1 -1
- package/std/Build/Fuzz.zig +6 -19
- package/std/Build/Module.zig +1 -1
- package/std/Build/Step/CheckObject.zig +3 -3
- package/std/Build/Step/Compile.zig +18 -0
- package/std/Build/Step/ConfigHeader.zig +49 -33
- package/std/Build/Step/InstallArtifact.zig +18 -0
- package/std/Build/Step/Run.zig +536 -87
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/Step.zig +8 -15
- package/std/Build/WebServer.zig +29 -17
- package/std/Build/abi.zig +47 -11
- package/std/Build.zig +17 -14
- package/std/Io/Dispatch.zig +2 -0
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/File.zig +1 -0
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io/Threaded.zig +181 -143
- package/std/Io/Uring.zig +2 -1
- package/std/Io.zig +970 -2
- package/std/Target.zig +3 -2
- package/std/Thread.zig +8 -3
- package/std/array_hash_map.zig +96 -555
- package/std/array_list.zig +22 -31
- package/std/bit_set.zig +22 -6
- package/std/builtin/assembly.zig +68 -0
- package/std/c.zig +17 -17
- package/std/compress/flate/Compress.zig +3 -3
- package/std/crypto/Certificate/Bundle.zig +15 -1
- package/std/crypto/codecs/asn1.zig +33 -18
- package/std/crypto/codecs/base64_hex_ct.zig +14 -4
- package/std/debug/Dwarf.zig +29 -9
- package/std/debug/Info.zig +4 -0
- package/std/debug/MachOFile.zig +46 -8
- package/std/debug/Pdb.zig +539 -36
- package/std/debug/SelfInfo/Elf.zig +19 -18
- package/std/debug/SelfInfo/MachO.zig +18 -7
- package/std/debug/SelfInfo/Windows.zig +138 -36
- package/std/debug.zig +179 -65
- package/std/enums.zig +25 -19
- package/std/heap/ArenaAllocator.zig +145 -154
- package/std/heap/debug_allocator.zig +7 -7
- package/std/http/Client.zig +10 -6
- package/std/http.zig +11 -9
- package/std/json/Stringify.zig +3 -3
- package/std/json/dynamic.zig +4 -4
- package/std/math/big/int.zig +16 -17
- package/std/mem/Allocator.zig +4 -5
- package/std/mem.zig +48 -0
- package/std/os/emscripten.zig +2 -18
- package/std/os/linux/arc.zig +144 -0
- package/std/os/linux.zig +21 -4
- package/std/os/windows.zig +2 -2
- package/std/pdb.zig +143 -4
- package/std/posix.zig +6 -12
- package/std/priority_dequeue.zig +13 -12
- package/std/priority_queue.zig +5 -4
- package/std/process/Child.zig +1 -1
- package/std/process/Environ.zig +1 -1
- package/std/start.zig +17 -4
- package/std/std.zig +19 -6
- package/std/testing/FailingAllocator.zig +4 -4
- package/std/testing/Smith.zig +37 -2
- package/std/zig/Ast/Render.zig +186 -458
- package/std/zig/Ast.zig +0 -4
- package/std/zig/AstGen.zig +44 -7
- package/std/zig/AstSmith.zig +2602 -0
- package/std/zig/Client.zig +8 -3
- package/std/zig/Parse.zig +83 -74
- package/std/zig/Server.zig +26 -0
- package/std/zig/Zir.zig +17 -0
- package/std/zig/c_translation/helpers.zig +14 -9
- package/std/zig/llvm/Builder.zig +107 -48
- package/std/zig/system.zig +20 -4
- package/std/zig/tokenizer.zig +2 -1
- package/std/zig.zig +6 -0
- package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
- package/libc/mingw/complex/cabs.c +0 -48
- package/libc/mingw/complex/cabsf.c +0 -48
- package/libc/mingw/complex/cacos.c +0 -50
- package/libc/mingw/complex/cacosf.c +0 -50
- package/libc/mingw/complex/carg.c +0 -48
- package/libc/mingw/complex/cargf.c +0 -48
- package/libc/mingw/complex/casin.c +0 -50
- package/libc/mingw/complex/casinf.c +0 -50
- package/libc/mingw/complex/catan.c +0 -50
- package/libc/mingw/complex/catanf.c +0 -50
- package/libc/mingw/complex/ccos.c +0 -50
- package/libc/mingw/complex/ccosf.c +0 -50
- package/libc/mingw/complex/cexp.c +0 -48
- package/libc/mingw/complex/cexpf.c +0 -48
- package/libc/mingw/complex/cimag.c +0 -48
- package/libc/mingw/complex/cimagf.c +0 -48
- package/libc/mingw/complex/clog.c +0 -48
- package/libc/mingw/complex/clog10.c +0 -49
- package/libc/mingw/complex/clog10f.c +0 -49
- package/libc/mingw/complex/clogf.c +0 -48
- package/libc/mingw/complex/conj.c +0 -48
- package/libc/mingw/complex/conjf.c +0 -48
- package/libc/mingw/complex/cpow.c +0 -48
- package/libc/mingw/complex/cpowf.c +0 -48
- package/libc/mingw/complex/cproj.c +0 -48
- package/libc/mingw/complex/cprojf.c +0 -48
- package/libc/mingw/complex/creal.c +0 -48
- package/libc/mingw/complex/crealf.c +0 -48
- package/libc/mingw/complex/csin.c +0 -50
- package/libc/mingw/complex/csinf.c +0 -50
- package/libc/mingw/complex/csqrt.c +0 -48
- package/libc/mingw/complex/csqrtf.c +0 -48
- package/libc/mingw/complex/ctan.c +0 -50
- package/libc/mingw/complex/ctanf.c +0 -50
- package/libc/mingw/math/arm/s_rint.c +0 -86
- package/libc/mingw/math/arm/s_rintf.c +0 -51
- package/libc/mingw/math/arm/sincos.S +0 -30
- package/libc/mingw/math/arm-common/sincosl.c +0 -13
- package/libc/mingw/math/arm64/rint.c +0 -12
- package/libc/mingw/math/arm64/rintf.c +0 -12
- package/libc/mingw/math/arm64/sincos.S +0 -32
- package/libc/mingw/math/bsd_private_base.h +0 -148
- package/libc/mingw/math/frexpf.c +0 -13
- package/libc/mingw/math/frexpl.c +0 -71
- package/libc/mingw/math/x86/acosf.c +0 -29
- package/libc/mingw/math/x86/atanf.c +0 -23
- package/libc/mingw/math/x86/atanl.c +0 -18
- package/libc/mingw/math/x86/cos.def.h +0 -65
- package/libc/mingw/math/x86/cosl.c +0 -46
- package/libc/mingw/math/x86/cosl_internal.S +0 -55
- package/libc/mingw/math/x86/ldexp.c +0 -23
- package/libc/mingw/math/x86/scalbn.S +0 -41
- package/libc/mingw/math/x86/scalbnf.S +0 -40
- package/libc/mingw/math/x86/sin.def.h +0 -65
- package/libc/mingw/math/x86/sinl.c +0 -46
- package/libc/mingw/math/x86/sinl_internal.S +0 -58
- package/libc/mingw/math/x86/tanl.S +0 -62
- package/libc/mingw/misc/btowc.c +0 -28
- package/libc/mingw/misc/wcstof.c +0 -66
- package/libc/mingw/misc/wcstoimax.c +0 -132
- package/libc/mingw/misc/wcstoumax.c +0 -126
- package/libc/mingw/misc/wctob.c +0 -29
- package/libc/mingw/misc/winbs_uint64.c +0 -6
- package/libc/mingw/misc/winbs_ulong.c +0 -6
- package/libc/mingw/misc/winbs_ushort.c +0 -6
- package/libc/mingw/stdio/_Exit.c +0 -10
- package/libc/mingw/stdio/_findfirst64i32.c +0 -21
- package/libc/mingw/stdio/_findnext64i32.c +0 -21
- package/libc/mingw/stdio/_fstat64i32.c +0 -37
- package/libc/mingw/stdio/_stat64i32.c +0 -37
- package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
- package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
- package/libc/mingw/stdio/_wstat64i32.c +0 -37
- package/libc/musl/src/legacy/isastream.c +0 -7
- package/libc/musl/src/legacy/valloc.c +0 -8
- package/libc/musl/src/math/__cosl.c +0 -96
- package/libc/musl/src/math/__sinl.c +0 -78
- package/libc/musl/src/math/__tanl.c +0 -143
- package/libc/musl/src/math/aarch64/lrint.c +0 -10
- package/libc/musl/src/math/aarch64/lrintf.c +0 -10
- package/libc/musl/src/math/aarch64/rintf.c +0 -7
- package/libc/musl/src/math/cosl.c +0 -39
- package/libc/musl/src/math/fdim.c +0 -10
- package/libc/musl/src/math/finite.c +0 -7
- package/libc/musl/src/math/finitef.c +0 -7
- package/libc/musl/src/math/frexp.c +0 -23
- package/libc/musl/src/math/frexpf.c +0 -23
- package/libc/musl/src/math/frexpl.c +0 -29
- package/libc/musl/src/math/i386/lrint.c +0 -8
- package/libc/musl/src/math/i386/lrintf.c +0 -8
- package/libc/musl/src/math/i386/rintf.c +0 -7
- package/libc/musl/src/math/lrint.c +0 -72
- package/libc/musl/src/math/lrintf.c +0 -8
- package/libc/musl/src/math/powerpc64/lrint.c +0 -16
- package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
- package/libc/musl/src/math/rintf.c +0 -30
- package/libc/musl/src/math/s390x/rintf.c +0 -15
- package/libc/musl/src/math/sincosl.c +0 -60
- package/libc/musl/src/math/sinl.c +0 -41
- package/libc/musl/src/math/tanl.c +0 -29
- package/libc/musl/src/math/x32/lrint.s +0 -5
- package/libc/musl/src/math/x32/lrintf.s +0 -5
- package/libc/musl/src/math/x86_64/lrint.c +0 -8
- package/libc/musl/src/math/x86_64/lrintf.c +0 -8
- package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
|
@@ -30,7 +30,15 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
|
|
|
30
30
|
if (si.unwind_cache) |cache| gpa.free(cache);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
pub fn
|
|
33
|
+
pub fn getSymbols(
|
|
34
|
+
si: *SelfInfo,
|
|
35
|
+
io: Io,
|
|
36
|
+
symbol_allocator: Allocator,
|
|
37
|
+
text_arena: Allocator,
|
|
38
|
+
address: usize,
|
|
39
|
+
resolve_inline_callers: bool,
|
|
40
|
+
symbols: *std.ArrayList(std.debug.Symbol),
|
|
41
|
+
) Error!void {
|
|
34
42
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
35
43
|
const module = try si.findModule(gpa, io, address, .exclusive);
|
|
36
44
|
defer si.rwlock.unlock(io);
|
|
@@ -53,28 +61,21 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {
|
|
|
53
61
|
};
|
|
54
62
|
loaded_elf.scanned_dwarf = true;
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
error.ReadFailed,
|
|
66
|
-
error.EndOfStream,
|
|
67
|
-
error.Overflow,
|
|
68
|
-
error.StreamTooLong,
|
|
69
|
-
=> return error.InvalidDebugInfo,
|
|
70
|
-
}
|
|
64
|
+
return dwarf.getSymbols(
|
|
65
|
+
symbol_allocator,
|
|
66
|
+
text_arena,
|
|
67
|
+
native_endian,
|
|
68
|
+
vaddr,
|
|
69
|
+
resolve_inline_callers,
|
|
70
|
+
symbols,
|
|
71
|
+
);
|
|
71
72
|
}
|
|
72
73
|
// When DWARF is unavailable, fall back to searching the symtab.
|
|
73
|
-
|
|
74
|
+
try symbols.append(symbol_allocator, loaded_elf.file.searchSymtab(gpa, vaddr) catch |err| switch (err) {
|
|
74
75
|
error.NoSymtab, error.NoStrtab => return error.MissingDebugInfo,
|
|
75
76
|
error.BadSymtab => return error.InvalidDebugInfo,
|
|
76
77
|
error.OutOfMemory => |e| return e,
|
|
77
|
-
};
|
|
78
|
+
});
|
|
78
79
|
}
|
|
79
80
|
pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
|
|
80
81
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
@@ -22,8 +22,18 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
|
|
|
22
22
|
si.modules.deinit(gpa);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
pub fn
|
|
25
|
+
pub fn getSymbols(
|
|
26
|
+
si: *SelfInfo,
|
|
27
|
+
io: Io,
|
|
28
|
+
symbol_allocator: Allocator,
|
|
29
|
+
text_arena: Allocator,
|
|
30
|
+
address: usize,
|
|
31
|
+
resolve_inline_callers: bool,
|
|
32
|
+
symbols: *std.ArrayList(std.debug.Symbol),
|
|
33
|
+
) Error!void {
|
|
34
|
+
_ = resolve_inline_callers;
|
|
26
35
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
36
|
+
|
|
27
37
|
const module = try si.findModule(gpa, io, address);
|
|
28
38
|
defer si.mutex.unlock(io);
|
|
29
39
|
|
|
@@ -43,23 +53,23 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {
|
|
|
43
53
|
|
|
44
54
|
const ofile_dwarf, const ofile_vaddr = file.getDwarfForAddress(gpa, io, vaddr) catch {
|
|
45
55
|
// Return at least the symbol name if available.
|
|
46
|
-
return .{
|
|
56
|
+
return symbols.append(symbol_allocator, .{
|
|
47
57
|
.name = try file.lookupSymbolName(vaddr),
|
|
48
58
|
.compile_unit_name = null,
|
|
49
59
|
.source_location = null,
|
|
50
|
-
};
|
|
60
|
+
});
|
|
51
61
|
};
|
|
52
62
|
|
|
53
63
|
const compile_unit = ofile_dwarf.findCompileUnit(native_endian, ofile_vaddr) catch {
|
|
54
64
|
// Return at least the symbol name if available.
|
|
55
|
-
return .{
|
|
65
|
+
return symbols.append(symbol_allocator, .{
|
|
56
66
|
.name = try file.lookupSymbolName(vaddr),
|
|
57
67
|
.compile_unit_name = null,
|
|
58
68
|
.source_location = null,
|
|
59
|
-
};
|
|
69
|
+
});
|
|
60
70
|
};
|
|
61
71
|
|
|
62
|
-
|
|
72
|
+
try symbols.append(symbol_allocator, .{
|
|
63
73
|
.name = ofile_dwarf.getSymbolName(ofile_vaddr) orelse
|
|
64
74
|
try file.lookupSymbolName(vaddr),
|
|
65
75
|
.compile_unit_name = compile_unit.die.getAttrString(
|
|
@@ -73,11 +83,12 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {
|
|
|
73
83
|
},
|
|
74
84
|
.source_location = ofile_dwarf.getLineNumberInfo(
|
|
75
85
|
gpa,
|
|
86
|
+
text_arena,
|
|
76
87
|
native_endian,
|
|
77
88
|
compile_unit,
|
|
78
89
|
ofile_vaddr,
|
|
79
90
|
) catch null,
|
|
80
|
-
};
|
|
91
|
+
});
|
|
81
92
|
}
|
|
82
93
|
pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
|
|
83
94
|
_ = si;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
lock: Io.RwLock,
|
|
2
2
|
ntdll_handle: ?if (load_dll_notification_procs) *anyopaque else noreturn,
|
|
3
3
|
notification_cookie: ?LDR.DLL_NOTIFICATION.COOKIE,
|
|
4
4
|
modules: std.ArrayList(Module),
|
|
5
5
|
|
|
6
6
|
pub const init: SelfInfo = .{
|
|
7
|
-
.
|
|
7
|
+
.lock = .init,
|
|
8
8
|
.ntdll_handle = null,
|
|
9
9
|
.notification_cookie = null,
|
|
10
10
|
.modules = .empty,
|
|
@@ -25,18 +25,33 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
|
|
|
25
25
|
si.modules.deinit(gpa);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
pub fn
|
|
28
|
+
pub fn getSymbols(
|
|
29
|
+
si: *SelfInfo,
|
|
30
|
+
io: Io,
|
|
31
|
+
symbol_allocator: Allocator,
|
|
32
|
+
text_arena: Allocator,
|
|
33
|
+
address: usize,
|
|
34
|
+
resolve_inline_callers: bool,
|
|
35
|
+
symbols: *std.ArrayList(std.debug.Symbol),
|
|
36
|
+
) Error!void {
|
|
29
37
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
30
|
-
try si.
|
|
31
|
-
defer si.
|
|
38
|
+
try si.lock.lockShared(io);
|
|
39
|
+
defer si.lock.unlockShared(io);
|
|
32
40
|
const module = try si.findModule(gpa, address);
|
|
33
41
|
const di = try module.getDebugInfo(gpa, io);
|
|
34
|
-
return di.
|
|
42
|
+
return di.getSymbols(
|
|
43
|
+
symbol_allocator,
|
|
44
|
+
text_arena,
|
|
45
|
+
address - @intFromPtr(module.entry.DllBase),
|
|
46
|
+
resolve_inline_callers,
|
|
47
|
+
symbols,
|
|
48
|
+
);
|
|
35
49
|
}
|
|
50
|
+
|
|
36
51
|
pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
|
|
37
52
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
38
|
-
try si.
|
|
39
|
-
defer si.
|
|
53
|
+
try si.lock.lockShared(io);
|
|
54
|
+
defer si.lock.unlockShared(io);
|
|
40
55
|
const module = try si.findModule(gpa, address);
|
|
41
56
|
return module.name orelse {
|
|
42
57
|
const name = try std.unicode.wtf16LeToWtf8Alloc(gpa, module.entry.BaseDllName.slice());
|
|
@@ -46,8 +61,8 @@ pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
|
|
|
46
61
|
}
|
|
47
62
|
pub fn getModuleSlide(si: *SelfInfo, io: Io, address: usize) Error!usize {
|
|
48
63
|
const gpa = std.debug.getDebugInfoAllocator();
|
|
49
|
-
try si.
|
|
50
|
-
defer si.
|
|
64
|
+
try si.lock.lockShared(io);
|
|
65
|
+
defer si.lock.unlockShared(io);
|
|
51
66
|
const module = try si.findModule(gpa, address);
|
|
52
67
|
return module.base_address;
|
|
53
68
|
}
|
|
@@ -240,7 +255,14 @@ const Module = struct {
|
|
|
240
255
|
arena.deinit();
|
|
241
256
|
}
|
|
242
257
|
|
|
243
|
-
fn
|
|
258
|
+
fn getSymbols(
|
|
259
|
+
di: *DebugInfo,
|
|
260
|
+
symbol_allocator: Allocator,
|
|
261
|
+
text_arena: Allocator,
|
|
262
|
+
vaddr: usize,
|
|
263
|
+
resolve_inline_callers: bool,
|
|
264
|
+
symbols: *std.ArrayList(std.debug.Symbol),
|
|
265
|
+
) Error!void {
|
|
244
266
|
pdb: {
|
|
245
267
|
const pdb = &(di.pdb orelse break :pdb);
|
|
246
268
|
var coff_section: *align(1) const coff.SectionHeader = undefined;
|
|
@@ -270,32 +292,101 @@ const Module = struct {
|
|
|
270
292
|
} orelse {
|
|
271
293
|
return error.InvalidDebugInfo; // bad module index
|
|
272
294
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
295
|
+
|
|
296
|
+
const addr = vaddr - coff_section.virtual_address;
|
|
297
|
+
const maybe_proc = pdb.getProcSym(module, addr);
|
|
298
|
+
const compile_unit_name = fs.path.basename(module.obj_file_name);
|
|
299
|
+
const symbols_top = symbols.items.len;
|
|
300
|
+
if (maybe_proc) |proc| {
|
|
301
|
+
const offset_in_func = addr - proc.code_offset;
|
|
302
|
+
var last_inlinee: ?u32 = null;
|
|
303
|
+
var iter = pdb.getInlinees(module, proc);
|
|
304
|
+
while (iter.next(module)) |inline_site| {
|
|
305
|
+
// Filter out duplicate inline sites. Tools like llvm-addr2line output
|
|
306
|
+
// duplicate sites in the same cases as us if we elide this check,
|
|
307
|
+
// implying that they exist in the underlying data and are not indicative
|
|
308
|
+
// of a parser bug. No useful information is lost here since an inline site
|
|
309
|
+
// can't actually reference itself.
|
|
310
|
+
if (inline_site.inlinee == last_inlinee) continue;
|
|
311
|
+
|
|
312
|
+
// If our address points into this site, get the source location(s) it
|
|
313
|
+
// points at
|
|
314
|
+
for (pdb.getInlineeSourceLines(
|
|
315
|
+
module,
|
|
316
|
+
inline_site.inlinee,
|
|
317
|
+
)) |inlinee_src_line| {
|
|
318
|
+
const maybe_loc = pdb.getInlineSiteSourceLocation(
|
|
319
|
+
text_arena,
|
|
320
|
+
module,
|
|
321
|
+
inline_site,
|
|
322
|
+
inlinee_src_line.info,
|
|
323
|
+
offset_in_func,
|
|
324
|
+
) catch continue;
|
|
325
|
+
const loc = maybe_loc orelse continue;
|
|
326
|
+
|
|
327
|
+
// If we aren't trying to resolve inline callers, and we've matched a
|
|
328
|
+
// new inline site, we want to overwrite the previously appended
|
|
329
|
+
// results.
|
|
330
|
+
if (!resolve_inline_callers and inline_site.inlinee != last_inlinee) {
|
|
331
|
+
symbols.items.len = symbols_top;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Only resolve the name if we're resolving inline callers, otherwise
|
|
335
|
+
// wait until we're done to avoid duplicated work.
|
|
336
|
+
const name = if (resolve_inline_callers)
|
|
337
|
+
pdb.findInlineeName(inline_site.inlinee)
|
|
338
|
+
else
|
|
339
|
+
null;
|
|
340
|
+
|
|
341
|
+
try symbols.append(symbol_allocator, .{
|
|
342
|
+
.name = name,
|
|
343
|
+
.compile_unit_name = compile_unit_name,
|
|
344
|
+
.source_location = loc,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
last_inlinee = inline_site.inlinee;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (resolve_inline_callers) {
|
|
352
|
+
// Inline sites are stored in the pdb in reverse order, so we reverse the
|
|
353
|
+
// matching sites here. We could alternatively use the parent fields to
|
|
354
|
+
// determine the order, but this would introduce seemingly unecessary
|
|
355
|
+
// complexity.
|
|
356
|
+
std.mem.reverse(std.debug.Symbol, symbols.items);
|
|
357
|
+
} else if (last_inlinee) |inlinee| {
|
|
358
|
+
// If we aren't resolving inline callers, then all results will have the
|
|
359
|
+
// same inline site, and we resolve its name once at the end.
|
|
360
|
+
const name = pdb.findInlineeName(inlinee);
|
|
361
|
+
for (symbols.items) |*symbol| symbol.name = name;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// If there's room for another symbol, add the actual proc
|
|
366
|
+
if (resolve_inline_callers or symbols.items.len == 0) {
|
|
367
|
+
try symbols.append(symbol_allocator, .{
|
|
368
|
+
.name = if (maybe_proc) |proc| pdb.getSymbolName(proc) else null,
|
|
369
|
+
.compile_unit_name = compile_unit_name,
|
|
370
|
+
.source_location = pdb.getLineNumberInfo(text_arena, module, addr) catch null,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return;
|
|
281
375
|
}
|
|
376
|
+
|
|
282
377
|
dwarf: {
|
|
283
378
|
const dwarf = &(di.dwarf orelse break :dwarf);
|
|
284
|
-
const
|
|
285
|
-
return dwarf.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
error.EndOfStream,
|
|
294
|
-
error.Overflow,
|
|
295
|
-
error.StreamTooLong,
|
|
296
|
-
=> return error.InvalidDebugInfo,
|
|
297
|
-
};
|
|
379
|
+
const addr = vaddr + di.coff_image_base;
|
|
380
|
+
return dwarf.getSymbols(
|
|
381
|
+
symbol_allocator,
|
|
382
|
+
text_arena,
|
|
383
|
+
native_endian,
|
|
384
|
+
addr,
|
|
385
|
+
resolve_inline_callers,
|
|
386
|
+
symbols,
|
|
387
|
+
);
|
|
298
388
|
}
|
|
389
|
+
|
|
299
390
|
return error.MissingDebugInfo;
|
|
300
391
|
}
|
|
301
392
|
};
|
|
@@ -360,6 +451,7 @@ const Module = struct {
|
|
|
360
451
|
error.SystemFdQuotaExceeded,
|
|
361
452
|
error.FileLocksUnsupported,
|
|
362
453
|
error.FileBusy,
|
|
454
|
+
error.ReadOnlyFileSystem,
|
|
363
455
|
=> return error.ReadFailed,
|
|
364
456
|
};
|
|
365
457
|
errdefer coff_file.close(io);
|
|
@@ -504,6 +596,16 @@ const Module = struct {
|
|
|
504
596
|
error.ReadFailed,
|
|
505
597
|
=> |e| return e,
|
|
506
598
|
};
|
|
599
|
+
pdb.parseIpiStream() catch |err| switch (err) {
|
|
600
|
+
error.UnknownPDBVersion => return error.UnsupportedDebugInfo,
|
|
601
|
+
|
|
602
|
+
error.EndOfStream,
|
|
603
|
+
=> return error.InvalidDebugInfo,
|
|
604
|
+
|
|
605
|
+
error.OutOfMemory,
|
|
606
|
+
error.ReadFailed,
|
|
607
|
+
=> |e| return e,
|
|
608
|
+
};
|
|
507
609
|
|
|
508
610
|
if (!std.mem.eql(u8, &coff_obj.guid, &pdb.guid) or coff_obj.age != pdb.age)
|
|
509
611
|
return error.InvalidDebugInfo;
|
|
@@ -530,7 +632,7 @@ const Module = struct {
|
|
|
530
632
|
}
|
|
531
633
|
};
|
|
532
634
|
|
|
533
|
-
/// Assumes we already hold `si.
|
|
635
|
+
/// Assumes we already hold `si.lock`.
|
|
534
636
|
fn findModule(si: *SelfInfo, gpa: Allocator, address: usize) error{ MissingDebugInfo, OutOfMemory, Unexpected }!*Module {
|
|
535
637
|
for (si.modules.items) |*mod| {
|
|
536
638
|
const base = @intFromPtr(mod.entry.DllBase);
|
|
@@ -600,8 +702,8 @@ fn dllNotification(
|
|
|
600
702
|
.LOADED => {},
|
|
601
703
|
.UNLOADED => {
|
|
602
704
|
const io = std.Options.debug_io;
|
|
603
|
-
si.
|
|
604
|
-
defer si.
|
|
705
|
+
si.lock.lockUncancelable(io);
|
|
706
|
+
defer si.lock.unlock(io);
|
|
605
707
|
for (si.modules.items, 0..) |*mod, mod_index| {
|
|
606
708
|
if (mod.entry.DllBase != data.Unloaded.DllBase) continue;
|
|
607
709
|
mod.deinit(std.debug.getDebugInfoAllocator(), io);
|