1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: remove commented code; improve print_backtrace with tcc

This commit is contained in:
Delyan Angelov
2021-05-23 12:37:23 +03:00
parent a08cbd364a
commit a27e7f7675
3 changed files with 54 additions and 69 deletions

View File

@@ -23,15 +23,21 @@ fn on_panic(f fn(int)int) {
// print_backtrace shows a backtrace of the current call stack on stdout
pub fn print_backtrace() {
// at the time of backtrace_symbols_fd call, the C stack would look something like this:
// 1 frame for print_backtrace_skipping_top_frames
// 1 frame for print_backtrace itself
// ... print the rest of the backtrace frames ...
// At the time of backtrace_symbols_fd call, the C stack would look something like this:
// * print_backtrace_skipping_top_frames
// * print_backtrace itself
// * the rest of the backtrace frames
// => top 2 frames should be skipped, since they will not be informative to the developer
$if freestanding {
println(bare_backtrace())
} $else {
print_backtrace_skipping_top_frames(2)
$if !no_backtrace ? {
$if freestanding {
println(bare_backtrace())
} $else {
$if tinyc {
C.tcc_backtrace(c'Backtrace')
} $else {
print_backtrace_skipping_top_frames(2)
}
}
}
}