#How do I run a zig test in gdb?

1 messages · Page 1 of 1 (latest)

rare stump
#

idk if this is possible. Is it?

#

I think i'd need zig to write the test executable somewhere, if it does that

#

maybe that's what "install()" does

#

use

builder.addTestExe(_, _)

and call its

install()

#

wait, i can't find my executable

brave ginkgo
#

You can run zig test in gdb. I forgot how to pass arguments to executable with gdb, but with lldb it would be lldb zig -- test

rare stump
#

@brave ginkgo when i do that, the debugger doesn't know how to analyze the executable, so I can't break on lines in the source code

#

I think the debugger doesn't know how to analyze the executable, because "source list" results in no output.

brave ginkgo
#

Hmmm, maybe zig test forks the test code as seperate process. You can try to insert @breakpoint() in your test code and see if gdb catches it

#

can try enabling follow on fork mode

rare stump
#

\I get "error: the following test command crashed" when it reaches the @breakpoint()

#

i'll look into the follow on fork mode later

stray crown
#

you can do zig test file.zig --test-cmd gdb --test-cmd-bin or zig test file.zig --test-no-exec -femit-bin=file && gdb file

#

sometimes I just grab the test exe path from the error message and debug that directly

rare stump
#

thanks!

#

i'll try that in a bit

tropic juniper
hazy marsh
#

test.test_runner adds the --test-cmd to the command but its giving me a weird error

#

ig im doing it wrong, found it in the std and it seems to take a zig file that it executes rather than something like gdb, not sure how exactly its supposed to work