authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-24 19:14:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-26 20:56:21-07:00
log396bd51c4818752f6309ff10f2d316f41598d5cd
tree452bc2f332c7a3ee6ab9d0274582b4b9da6800d6
parentafbcad9939169f0b9b9b8ecb287718023c58b428

enable debugging infrastructure when using C backend

Thanks to @jacobly0's recent enhancements to the C backend, this stuff works now.

4 files changed, 9 insertions(+), 17 deletions(-)

lib/std/builtin.zig+1-2
......@@ -868,8 +868,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr
868868
869869 // For backends that cannot handle the language features depended on by the
870870 // default panic handler, we have a simpler panic handler:
871 if (builtin.zig_backend == .stage2_c or
872 builtin.zig_backend == .stage2_wasm or
871 if (builtin.zig_backend == .stage2_wasm or
873872 builtin.zig_backend == .stage2_arm or
874873 builtin.zig_backend == .stage2_aarch64 or
875874 builtin.zig_backend == .stage2_x86_64 or
lib/std/debug.zig+2-12
......@@ -1360,13 +1360,7 @@ pub const DebugInfo = struct {
13601360 }
13611361
13621362 pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1363 if (builtin.zig_backend == .stage2_c) {
1364 return @as(error{
1365 InvalidDebugInfo,
1366 MissingDebugInfo,
1367 UnsupportedBackend,
1368 }, error.UnsupportedBackend);
1369 } else if (comptime builtin.target.isDarwin()) {
1363 if (comptime builtin.target.isDarwin()) {
13701364 return self.lookupModuleDyld(address);
13711365 } else if (native_os == .windows) {
13721366 return self.lookupModuleWin32(address);
......@@ -1380,9 +1374,7 @@ pub const DebugInfo = struct {
13801374 }
13811375
13821376 pub fn getModuleNameForAddress(self: *DebugInfo, address: usize) ?[]const u8 {
1383 if (builtin.zig_backend == .stage2_c) {
1384 return null;
1385 } else if (comptime builtin.target.isDarwin()) {
1377 if (comptime builtin.target.isDarwin()) {
13861378 return null;
13871379 } else if (native_os == .windows) {
13881380 return self.lookupModuleNameWin32(address);
......@@ -2191,8 +2183,6 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
21912183}
21922184
21932185test "manage resources correctly" {
2194 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // error.UnsupportedBackend
2195
21962186 if (builtin.os.tag == .wasi) return error.SkipZigTest;
21972187
21982188 if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) {
lib/std/os.zig+4-2
......@@ -5371,8 +5371,10 @@ pub fn dl_iterate_phdr(
53715371) Error!void {
53725372 const Context = @TypeOf(context);
53735373
5374 if (builtin.object_format != .elf)
5375 @compileError("dl_iterate_phdr is not available for this target");
5374 switch (builtin.object_format) {
5375 .elf, .c => {},
5376 else => @compileError("dl_iterate_phdr is not available for this target"),
5377 }
53765378
53775379 if (builtin.link_libc) {
53785380 switch (system.dl_iterate_phdr(struct {
src/Module.zig+2-1
......@@ -6629,7 +6629,8 @@ pub fn backendSupportsFeature(mod: Module, feature: Feature) bool {
66296629 mod.comp.bin_file.options.use_llvm,
66306630 .panic_unwrap_error => mod.comp.bin_file.options.target.ofmt == .c or
66316631 mod.comp.bin_file.options.use_llvm,
6632 .safety_check_formatted => mod.comp.bin_file.options.use_llvm,
6632 .safety_check_formatted => mod.comp.bin_file.options.target.ofmt == .c or
6633 mod.comp.bin_file.options.use_llvm,
66336634 .error_return_trace => mod.comp.bin_file.options.use_llvm,
66346635 .is_named_enum_value => mod.comp.bin_file.options.use_llvm,
66356636 .error_set_has_value => mod.comp.bin_file.options.use_llvm or mod.comp.bin_file.options.target.isWasm(),