Skip to content

Commit 396bd51

Browse files
committed
enable debugging infrastructure when using C backend
Thanks to @jacobly0's recent enhancements to the C backend, this stuff works now.
1 parent afbcad9 commit 396bd51

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

lib/std/builtin.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

21932185
test "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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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(),

0 commit comments

Comments
 (0)