builtin: support -d no_backtrace, to ease compiling V code on older distros easier

pull/6881/head
Delyan Angelov 2020-11-19 17:57:51 +02:00
parent f807fd973e
commit 48b117618d
1 changed files with 42 additions and 38 deletions

View File

@ -87,6 +87,9 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
C.tcc_backtrace("Backtrace")
return false
}
$if no_backtrace ? {
return false
} $else {
buffer := [100]byteptr{}
nr_ptrs := C.backtrace(voidptr(buffer), 100)
if nr_ptrs < 2 {
@ -130,6 +133,7 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
output = output.replace(' (discriminator', ': (d.')
eprintln('${output:-46s} | ${addr:14s} | $beforeaddr')
}
}
return true
}