From 0da1d757cb8efb21138e9bc643a4053d375e1d5f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 15 Dec 2020 06:35:14 +0200 Subject: [PATCH] builtin: support '-d no_backtrace' directly in panic(), to ease creating .so files with tcc --- vlib/builtin/builtin.v | 54 +++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/vlib/builtin/builtin.v b/vlib/builtin/builtin.v index 415226c866..0fa67e0f15 100644 --- a/vlib/builtin/builtin.v +++ b/vlib/builtin/builtin.v @@ -54,20 +54,25 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) { eprintln('=========================================') $if exit_after_panic_message ? { C.exit(1) - } - $if tinyc { - $if panics_break_into_debugger ? { - break_if_debugger_attached() + } $else { + $if no_backtrace ? { + C.exit(1) } $else { - C.tcc_backtrace('Backtrace') + $if tinyc { + $if panics_break_into_debugger ? { + break_if_debugger_attached() + } $else { + C.tcc_backtrace('Backtrace') + } + C.exit(1) + } + print_backtrace_skipping_top_frames(1) + $if panics_break_into_debugger ? { + break_if_debugger_attached() + } + C.exit(1) } - C.exit(1) } - print_backtrace_skipping_top_frames(1) - $if panics_break_into_debugger ? { - break_if_debugger_attached() - } - C.exit(1) } // panic prints a nice error message, then exits the process with exit code of 1. @@ -76,20 +81,25 @@ pub fn panic(s string) { eprintln('V panic: $s') $if exit_after_panic_message ? { C.exit(1) - } - $if tinyc { - $if panics_break_into_debugger ? { - break_if_debugger_attached() + } $else { + $if no_backtrace ? { + C.exit(1) } $else { - C.tcc_backtrace('Backtrace') + $if tinyc { + $if panics_break_into_debugger ? { + break_if_debugger_attached() + } $else { + C.tcc_backtrace('Backtrace') + } + C.exit(1) + } + print_backtrace_skipping_top_frames(1) + $if panics_break_into_debugger ? { + break_if_debugger_attached() + } + C.exit(1) } - C.exit(1) } - print_backtrace_skipping_top_frames(1) - $if panics_break_into_debugger ? { - break_if_debugger_attached() - } - C.exit(1) } // eprintln prints a message with a line end, to stderr. Both stderr and stdout are flushed.