| author | |
| committer | |
| log | 7c5ceb0c4cdf5fafadd92b13048bc9878554abc4 |
| tree | 839d4723859bc20efe6f396c541184dc33dabf71 |
| parent | 362c79140fc0638b0f85ed9b2a49f3fead14bb9b |
| signature |
4 files changed, 20 insertions(+), 5 deletions(-)
src/codegen.cpp+8-1| ... | ... | @@ -203,6 +203,10 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget |
| 203 | 203 | get_target_triple(&g->triple_str, g->zig_target); |
| 204 | 204 | g->pointer_size_bytes = target_arch_pointer_bit_width(g->zig_target->arch) / 8; |
| 205 | 205 | |
| 206 | if (!target_has_debug_info(g->zig_target)) { | |
| 207 | g->strip_debug_symbols = true; | |
| 208 | } | |
| 209 | ||
| 206 | 210 | return g; |
| 207 | 211 | } |
| 208 | 212 | |
| ... | ... | @@ -248,6 +252,9 @@ void codegen_set_errmsg_color(CodeGen *g, ErrColor err_color) { |
| 248 | 252 | |
| 249 | 253 | void codegen_set_strip(CodeGen *g, bool strip) { |
| 250 | 254 | g->strip_debug_symbols = strip; |
| 255 | if (!target_has_debug_info(g->zig_target)) { | |
| 256 | g->strip_debug_symbols = true; | |
| 257 | } | |
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | void codegen_set_out_name(CodeGen *g, Buf *out_name) { |
| ... | ... | @@ -7514,7 +7521,7 @@ static bool detect_single_threaded(CodeGen *g) { |
| 7514 | 7521 | } |
| 7515 | 7522 | |
| 7516 | 7523 | static bool detect_err_ret_tracing(CodeGen *g) { |
| 7517 | return !target_is_wasm(g->zig_target) && | |
| 7524 | return !g->strip_debug_symbols && | |
| 7518 | 7525 | g->build_mode != BuildModeFastRelease && |
| 7519 | 7526 | g->build_mode != BuildModeSmallRelease; |
| 7520 | 7527 | } |
src/target.cpp+4| ... | ... | @@ -1585,3 +1585,7 @@ void target_libc_enum(size_t index, ZigTarget *out_target) { |
| 1585 | 1585 | out_target->vendor = ZigLLVM_UnknownVendor; |
| 1586 | 1586 | out_target->is_native = false; |
| 1587 | 1587 | } |
| 1588 | ||
| 1589 | bool target_has_debug_info(const ZigTarget *target) { | |
| 1590 | return !target_is_wasm(target); | |
| 1591 | } |
src/target.hpp+1| ... | ... | @@ -177,6 +177,7 @@ bool target_is_musl(const ZigTarget *target); |
| 177 | 177 | bool target_is_wasm(const ZigTarget *target); |
| 178 | 178 | bool target_is_single_threaded(const ZigTarget *target); |
| 179 | 179 | bool target_supports_stack_probing(const ZigTarget *target); |
| 180 | bool target_has_debug_info(const ZigTarget *target); | |
| 180 | 181 | |
| 181 | 182 | uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch); |
| 182 | 183 |
std/debug.zig+7-4| ... | ... | @@ -85,8 +85,8 @@ fn wantTtyColor() bool { |
| 85 | 85 | /// TODO multithreaded awareness |
| 86 | 86 | pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 87 | 87 | const stderr = getStderrStream() catch return; |
| 88 | if (os.wasi.is_the_target) { | |
| 89 | stderr.print("Unable to dump stack trace: unimplemented on WASI\n") catch return; | |
| 88 | if (builtin.strip_debug_info) { | |
| 89 | stderr.print("Unable to dump stack trace: debug info stripped\n") catch return; | |
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | const debug_info = getSelfDebugInfo() catch |err| { |
| ... | ... | @@ -151,8 +151,8 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace |
| 151 | 151 | /// TODO multithreaded awareness |
| 152 | 152 | pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { |
| 153 | 153 | const stderr = getStderrStream() catch return; |
| 154 | if (os.wasi.is_the_target) { | |
| 155 | stderr.print("Unable to dump stack trace: unimplemented on WASI\n") catch return; | |
| 154 | if (builtin.strip_debug_info) { | |
| 155 | stderr.print("Unable to dump stack trace: debug info stripped\n") catch return; | |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | const debug_info = getSelfDebugInfo() catch |err| { |
| ... | ... | @@ -223,6 +223,7 @@ pub fn writeStackTrace( |
| 223 | 223 | debug_info: *DebugInfo, |
| 224 | 224 | tty_color: bool, |
| 225 | 225 | ) !void { |
| 226 | if (builtin.strip_debug_info) return error.MissingDebugInfo; | |
| 226 | 227 | var frame_index: usize = 0; |
| 227 | 228 | var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len); |
| 228 | 229 | |
| ... | ... | @@ -783,6 +784,8 @@ pub const OpenSelfDebugInfoError = error{ |
| 783 | 784 | }; |
| 784 | 785 | |
| 785 | 786 | pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo { |
| 787 | if (builtin.strip_debug_info) | |
| 788 | return error.MissingDebugInfo; | |
| 786 | 789 | if (windows.is_the_target) { |
| 787 | 790 | return openSelfDebugInfoWindows(allocator); |
| 788 | 791 | } |