enable debugging infrastructure when using C backend

Thanks to @jacobly0's recent enhancements to the C backend, this stuff
works now.
This commit is contained in:
Andrew Kelley 2023-04-24 19:14:54 -07:00
parent afbcad9939
commit 396bd51c48
4 changed files with 9 additions and 17 deletions

View File

@ -868,8 +868,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr
// For backends that cannot handle the language features depended on by the // For backends that cannot handle the language features depended on by the
// default panic handler, we have a simpler panic handler: // default panic handler, we have a simpler panic handler:
if (builtin.zig_backend == .stage2_c or if (builtin.zig_backend == .stage2_wasm or
builtin.zig_backend == .stage2_wasm or
builtin.zig_backend == .stage2_arm or builtin.zig_backend == .stage2_arm or
builtin.zig_backend == .stage2_aarch64 or builtin.zig_backend == .stage2_aarch64 or
builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_x86_64 or

View File

@ -1360,13 +1360,7 @@ pub const DebugInfo = struct {
} }
pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo { pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
if (builtin.zig_backend == .stage2_c) { if (comptime builtin.target.isDarwin()) {
return @as(error{
InvalidDebugInfo,
MissingDebugInfo,
UnsupportedBackend,
}, error.UnsupportedBackend);
} else if (comptime builtin.target.isDarwin()) {
return self.lookupModuleDyld(address); return self.lookupModuleDyld(address);
} else if (native_os == .windows) { } else if (native_os == .windows) {
return self.lookupModuleWin32(address); return self.lookupModuleWin32(address);
@ -1380,9 +1374,7 @@ pub const DebugInfo = struct {
} }
pub fn getModuleNameForAddress(self: *DebugInfo, address: usize) ?[]const u8 { pub fn getModuleNameForAddress(self: *DebugInfo, address: usize) ?[]const u8 {
if (builtin.zig_backend == .stage2_c) { if (comptime builtin.target.isDarwin()) {
return null;
} else if (comptime builtin.target.isDarwin()) {
return null; return null;
} else if (native_os == .windows) { } else if (native_os == .windows) {
return self.lookupModuleNameWin32(address); return self.lookupModuleNameWin32(address);
@ -2191,8 +2183,6 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
} }
test "manage resources correctly" { test "manage resources correctly" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // error.UnsupportedBackend
if (builtin.os.tag == .wasi) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest;
if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) { if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) {

View File

@ -5371,8 +5371,10 @@ pub fn dl_iterate_phdr(
) Error!void { ) Error!void {
const Context = @TypeOf(context); const Context = @TypeOf(context);
if (builtin.object_format != .elf) switch (builtin.object_format) {
@compileError("dl_iterate_phdr is not available for this target"); .elf, .c => {},
else => @compileError("dl_iterate_phdr is not available for this target"),
}
if (builtin.link_libc) { if (builtin.link_libc) {
switch (system.dl_iterate_phdr(struct { switch (system.dl_iterate_phdr(struct {

View File

@ -6629,7 +6629,8 @@ pub fn backendSupportsFeature(mod: Module, feature: Feature) bool {
mod.comp.bin_file.options.use_llvm, mod.comp.bin_file.options.use_llvm,
.panic_unwrap_error => mod.comp.bin_file.options.target.ofmt == .c or .panic_unwrap_error => mod.comp.bin_file.options.target.ofmt == .c or
mod.comp.bin_file.options.use_llvm, mod.comp.bin_file.options.use_llvm,
.safety_check_formatted => mod.comp.bin_file.options.use_llvm, .safety_check_formatted => mod.comp.bin_file.options.target.ofmt == .c or
mod.comp.bin_file.options.use_llvm,
.error_return_trace => mod.comp.bin_file.options.use_llvm, .error_return_trace => mod.comp.bin_file.options.use_llvm,
.is_named_enum_value => mod.comp.bin_file.options.use_llvm, .is_named_enum_value => mod.comp.bin_file.options.use_llvm,
.error_set_has_value => mod.comp.bin_file.options.use_llvm or mod.comp.bin_file.options.target.isWasm(), .error_set_has_value => mod.comp.bin_file.options.use_llvm or mod.comp.bin_file.options.target.isWasm(),