| ... | @@ -63,16 +63,22 @@ pub const cpu_context = @import("debug/cpu_context.zig"); | ... | @@ -63,16 +63,22 @@ pub const cpu_context = @import("debug/cpu_context.zig"); |
| 63 | /// ``` | 63 | /// ``` |
| 64 | pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfInfo")) | 64 | pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfInfo")) |
| 65 | root.debug.SelfInfo | 65 | root.debug.SelfInfo |
| 66 | else switch (std.Target.ObjectFormat.default(native_os, native_arch)) { | 66 | else |
| 67 | .coff => if (native_os == .windows) @import("debug/SelfInfo/Windows.zig") else void, | 67 | TargetInfo(native_os, native_arch); |
| 68 | .elf => switch (native_os) { | 68 | |
| 69 | .freestanding, .other => void, | 69 | /// Returns the default `SelfInfo` for the given `os` and `arch`. |
| 70 | else => @import("debug/SelfInfo/Elf.zig"), | 70 | pub fn TargetInfo(os: std.Target.Os.Tag, arch: std.Target.Cpu.Arch) type { |
| 71 | }, | 71 | return switch (std.Target.ObjectFormat.default(os, arch)) { |
| 72 | .macho => @import("debug/SelfInfo/MachO.zig"), | 72 | .coff => if (os == .windows) @import("debug/SelfInfo/Windows.zig") else void, |
| 73 | .plan9, .spirv, .wasm => void, | 73 | .elf => switch (os) { |
| 74 | .c, .hex, .raw => unreachable, | 74 | .freestanding, .other => void, |
| 75 | }; | 75 | else => @import("debug/SelfInfo/Elf.zig"), |
| | 76 | }, |
| | 77 | .macho => @import("debug/SelfInfo/MachO.zig"), |
| | 78 | .plan9, .spirv, .wasm => void, |
| | 79 | .c, .hex, .raw => unreachable, |
| | 80 | }; |
| | 81 | } |
| 76 | | 82 | |
| 77 | pub const SelfInfoError = error{ | 83 | pub const SelfInfoError = error{ |
| 78 | /// The required debug info is invalid or corrupted. | 84 | /// The required debug info is invalid or corrupted. |