builtin: support '-d no_backtrace' directly in panic(), to ease creating .so files with tcc

pull/7342/head
Delyan Angelov 2020-12-15 06:35:14 +02:00
parent bfa8e4bf86
commit 0da1d757cb
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 32 additions and 22 deletions

View File

@ -54,7 +54,10 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
eprintln('=========================================')
$if exit_after_panic_message ? {
C.exit(1)
}
} $else {
$if no_backtrace ? {
C.exit(1)
} $else {
$if tinyc {
$if panics_break_into_debugger ? {
break_if_debugger_attached()
@ -69,6 +72,8 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
}
C.exit(1)
}
}
}
// panic prints a nice error message, then exits the process with exit code of 1.
// It also shows a backtrace on most platforms.
@ -76,7 +81,10 @@ pub fn panic(s string) {
eprintln('V panic: $s')
$if exit_after_panic_message ? {
C.exit(1)
}
} $else {
$if no_backtrace ? {
C.exit(1)
} $else {
$if tinyc {
$if panics_break_into_debugger ? {
break_if_debugger_attached()
@ -91,6 +99,8 @@ pub fn panic(s string) {
}
C.exit(1)
}
}
}
// eprintln prints a message with a line end, to stderr. Both stderr and stdout are flushed.
pub fn eprintln(s string) {