Closed medvednikov closed 3 years ago
In this particular example, the exact line of code in main()
should be pointed out as well.
I think using -g
display the correct lines, doesn't it ?
I'm not sure that fixes the issue. This particular panic was with v self
, which, if I understand cmd/v/v.v
correctly, automatically adds -g
, and the above still does not contain line numbers.
@Gladear -g makes line numbers visible when debugging with valgrind/gdb etc. This is for getting line numbers in backtraces.
@Gladear is right: -g
includes V line number information, so that the panic backtrace will show them.
If you want to debug v itself, compile it with v -g self
(or with v -g -o v cmd/v
, after all V is a normal V program).
I'm not sure that fixes the issue. This particular panic was with
v self
, which, if I understandcmd/v/v.v
correctly, automatically adds-g
, and the above still does not contain line numbers.
The code for v self
is in cmd/tools/vself.v . It boils down to compiling to a temporary file v2 or v2.exe with whatever options the user has specified, then moving that temporary into v
. It does not add -g by itself.
You can try for yourself with this program:
// line 1
// line 2
// line 3
fn abc() {
panic('some message')
}
fn main() {
abc()
}
... which will produce this C code with -g
( shown through ./v -g -o - a.v |bat -lc
):
Right, addr2line is indeed used with -g, but only on Linux, that's why neither me nor the person who submitted this got the line numbers.
There's atos
on BSDs, it should be used.
Right now the developer only knows the line at which the panic happened. The backtrace is not helpful: