v panic debug information
parent
07ed320110
commit
5e57d099d7
|
@ -752,6 +752,16 @@ fn (p mut Parser) fn_call_args(f mut Fn) *Fn {
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
// add debug information to panic when -debug arg is passed
|
||||||
|
if p.v.pref.is_debug && f.name == 'panic' {
|
||||||
|
mod_name := p.mod.replace('_dot_', '.')
|
||||||
|
fn_name := p.cur_fn.name.replace('${p.mod}__', '')
|
||||||
|
file_path := p.file_path.replace('\\', '\\\\') // escape \
|
||||||
|
p.cgen.resetln(p.cgen.cur_line.replace(
|
||||||
|
'v_panic (',
|
||||||
|
'_panic_debug ($p.scanner.line_nr, tos2("$file_path"), tos2("$mod_name"), tos2("$fn_name"), '
|
||||||
|
))
|
||||||
|
}
|
||||||
// Receiver - first arg
|
// Receiver - first arg
|
||||||
for i, arg in f.args {
|
for i, arg in f.args {
|
||||||
// println('$i) arg=$arg.name')
|
// println('$i) arg=$arg.name')
|
||||||
|
|
|
@ -26,6 +26,19 @@ pub fn print_backtrace() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replaces panic when -debug arg is passed
|
||||||
|
fn _panic_debug(line_no int, file, mod, fn_name, s string) {
|
||||||
|
println('================ V panic ================')
|
||||||
|
println(' module: $mod')
|
||||||
|
println(' function: ${fn_name}()')
|
||||||
|
println(' file: $file')
|
||||||
|
println(' line: ' + line_no.str())
|
||||||
|
println(' message: $s')
|
||||||
|
println('=========================================')
|
||||||
|
print_backtrace()
|
||||||
|
C.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn panic(s string) {
|
pub fn panic(s string) {
|
||||||
println('V panic: $s')
|
println('V panic: $s')
|
||||||
print_backtrace()
|
print_backtrace()
|
||||||
|
|
Loading…
Reference in New Issue