authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-14 18:45:41-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-14 18:45:41-04:00
log7c5ceb0c4cdf5fafadd92b13048bc9878554abc4
tree839d4723859bc20efe6f396c541184dc33dabf71
parent362c79140fc0638b0f85ed9b2a49f3fead14bb9b
signaturelock-open Commit is signed but in an unrecognized format.

standard library integrates with knowledge of stripped debug info


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
203203 get_target_triple(&g->triple_str, g->zig_target);
204204 g->pointer_size_bytes = target_arch_pointer_bit_width(g->zig_target->arch) / 8;
205205
206 if (!target_has_debug_info(g->zig_target)) {
207 g->strip_debug_symbols = true;
208 }
209
206210 return g;
207211}
208212
......@@ -248,6 +252,9 @@ void codegen_set_errmsg_color(CodeGen *g, ErrColor err_color) {
248252
249253void codegen_set_strip(CodeGen *g, bool strip) {
250254 g->strip_debug_symbols = strip;
255 if (!target_has_debug_info(g->zig_target)) {
256 g->strip_debug_symbols = true;
257 }
251258}
252259
253260void codegen_set_out_name(CodeGen *g, Buf *out_name) {
......@@ -7514,7 +7521,7 @@ static bool detect_single_threaded(CodeGen *g) {
75147521}
75157522
75167523static bool detect_err_ret_tracing(CodeGen *g) {
7517 return !target_is_wasm(g->zig_target) &&
7524 return !g->strip_debug_symbols &&
75187525 g->build_mode != BuildModeFastRelease &&
75197526 g->build_mode != BuildModeSmallRelease;
75207527}
src/target.cpp+4
......@@ -1585,3 +1585,7 @@ void target_libc_enum(size_t index, ZigTarget *out_target) {
15851585 out_target->vendor = ZigLLVM_UnknownVendor;
15861586 out_target->is_native = false;
15871587}
1588
1589bool 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);
177177bool target_is_wasm(const ZigTarget *target);
178178bool target_is_single_threaded(const ZigTarget *target);
179179bool target_supports_stack_probing(const ZigTarget *target);
180bool target_has_debug_info(const ZigTarget *target);
180181
181182uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch);
182183
std/debug.zig+7-4
......@@ -85,8 +85,8 @@ fn wantTtyColor() bool {
8585/// TODO multithreaded awareness
8686pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
8787 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;
9090 return;
9191 }
9292 const debug_info = getSelfDebugInfo() catch |err| {
......@@ -151,8 +151,8 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace
151151/// TODO multithreaded awareness
152152pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {
153153 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;
156156 return;
157157 }
158158 const debug_info = getSelfDebugInfo() catch |err| {
......@@ -223,6 +223,7 @@ pub fn writeStackTrace(
223223 debug_info: *DebugInfo,
224224 tty_color: bool,
225225) !void {
226 if (builtin.strip_debug_info) return error.MissingDebugInfo;
226227 var frame_index: usize = 0;
227228 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
228229
......@@ -783,6 +784,8 @@ pub const OpenSelfDebugInfoError = error{
783784};
784785
785786pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {
787 if (builtin.strip_debug_info)
788 return error.MissingDebugInfo;
786789 if (windows.is_the_target) {
787790 return openSelfDebugInfoWindows(allocator);
788791 }