vberlier/narwhal

How to use a GDB with Narwhal

eerimoq opened this issue · 3 comments

Hello!

I can't figure out how to use GDB to debug a test case that crashes. I can set a breakpoint at _narwhal_test_function_<mytestcase>, but GDB never halts there. I've tried set follow-fork-mode child and other alternatives I found searching the web, but nothings seems to work.

This is probably not a problem with Narwhal itself, but my poor GDB knowledge. Anyhow, it would probably help others as well if there is a short guide on how to use GDB with Narwhal.

I figured it out. set follow-fork-mode child must be run just before forking the test case that you want to debug.

In practice I find it easiest to comment out all test cases before the test case I want to debug, so I can run set follow-fork-mode child at the beginning of the program.

It would be nice to have a symbol to break on just before a specific test case fork, so I don't have to comment out tests.

Hmm it seems like gdb can only follow one process at a time and stops whenever the process exits. If we set follow-fork-mode to child, gdb can't go back to the main process and just stops at the end of the first test.

I think introducing a dummy symbol might be a bit confusing but one way around the problem would be to have a simple way to only run a single test, without having to comment out everything else.

TEST_ONLY(example) {}  // Only run this test

TEST(example, ONLY) {}  // Could also be special test modifier

I think it's a feature that would also be useful on its own so I'll try to implement something like this when I have the time.

Thanks, looks good :P