builtin: support `-d no_backtrace` on macos/bsd too
parent
3a0fa550b6
commit
b0167297e5
|
@ -23,30 +23,28 @@ fn builtin_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_backtrace_skipping_top_frames(xskipframes int) bool {
|
fn print_backtrace_skipping_top_frames(xskipframes int) bool {
|
||||||
|
$if no_backtrace ? {
|
||||||
|
return false
|
||||||
|
} $else {
|
||||||
skipframes := xskipframes + 2
|
skipframes := xskipframes + 2
|
||||||
$if macos {
|
$if macos || freebsd || openbsd || netbsd {
|
||||||
return print_backtrace_skipping_top_frames_mac(skipframes)
|
return print_backtrace_skipping_top_frames_bsd(skipframes)
|
||||||
}
|
} $else $if linux {
|
||||||
$if linux {
|
|
||||||
return print_backtrace_skipping_top_frames_linux(skipframes)
|
return print_backtrace_skipping_top_frames_linux(skipframes)
|
||||||
}
|
} $else {
|
||||||
$if freebsd {
|
|
||||||
return print_backtrace_skipping_top_frames_freebsd(skipframes)
|
|
||||||
}
|
|
||||||
$if netbsd {
|
|
||||||
return print_backtrace_skipping_top_frames_freebsd(skipframes)
|
|
||||||
}
|
|
||||||
$if openbsd {
|
|
||||||
return print_backtrace_skipping_top_frames_freebsd(skipframes)
|
|
||||||
}
|
|
||||||
println('print_backtrace_skipping_top_frames is not implemented. skipframes: $skipframes')
|
println('print_backtrace_skipping_top_frames is not implemented. skipframes: $skipframes')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the functions below are not called outside this file,
|
// the functions below are not called outside this file,
|
||||||
// so there is no need to have their twins in builtin_windows.v
|
// so there is no need to have their twins in builtin_windows.v
|
||||||
fn print_backtrace_skipping_top_frames_mac(skipframes int) bool {
|
fn print_backtrace_skipping_top_frames_bsd(skipframes int) bool {
|
||||||
$if macos {
|
$if no_backtrace ? {
|
||||||
|
return false
|
||||||
|
} $else {
|
||||||
|
$if macos || freebsd || openbsd || netbsd {
|
||||||
buffer := [100]voidptr{}
|
buffer := [100]voidptr{}
|
||||||
nr_ptrs := C.backtrace(&buffer[0], 100)
|
nr_ptrs := C.backtrace(&buffer[0], 100)
|
||||||
if nr_ptrs < 2 {
|
if nr_ptrs < 2 {
|
||||||
|
@ -57,18 +55,6 @@ fn print_backtrace_skipping_top_frames_mac(skipframes int) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_backtrace_skipping_top_frames_freebsd(skipframes int) bool {
|
|
||||||
$if freebsd {
|
|
||||||
buffer := [100]voidptr{}
|
|
||||||
nr_ptrs := C.backtrace(&buffer[0], 100)
|
|
||||||
if nr_ptrs < 2 {
|
|
||||||
eprintln('C.backtrace returned less than 2 frames')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
C.backtrace_symbols_fd(&buffer[skipframes], nr_ptrs - skipframes, 2)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C.tcc_backtrace(fmt &char) int
|
fn C.tcc_backtrace(fmt &char) int
|
||||||
|
|
Loading…
Reference in New Issue