Post a Comment
Works fine on my FreeBSD box, and I would assume it works fine on NetBSD, especially considering its on the experimental list at http://valgrind.org/info/platforms.html
Unfortunately, at this point the netbsd port is still on hold.
Time is very scarce for me at this point to continue this and its unfair to claim that work is happening when it isnt.
The freebsd port is very old (2.X). Valgrind's internals have been greatly overhauled since then. The NetBSD port tracks the 3.x branch but is stagnanting. However for simple programs the netbsd port is in a usable state. The basic framework is in place but a lot of "wrappers" to syscalls need to be written due to the way Valgrind works..
This tool is amazing. Memory errors suck. I had a case where my program was segfaulting... I go to debug it and just compiling it with -O0 -g to get line numbers and symbols for debugging and the program stopped segfaulting. I tried compiling it the same and resorting to debugging via printf. Just adding a single printf statement and there is no more segfault.
So I knew I had a memory error but no way to debug it.
I actually hacked something up using macros and search/replace of my editor to print out a %P (or whatever prints a pointer address) in every single malloc and calloc. Then before free'ing the pointers I printed out their addresses. Each print statement had a unique number so I could tell where things were being double free'd or malloc'ed but not freed.
I eventually found the problem.
Anyway, it was a hack and I didn't like it. I removed all that debugging code and went on. The next time I had a memory error I looked around and found valgrind. It was so fast and I wished I knew about it the first time though.
It really is a great tool. It will find memory errors that only creep up in rare instances. I have ported programs from Solaris to Linux and Windows. The memory error may show up on one but not the others.
Anyway, as great as a tool that this is... when I start writing a C program, the second I type malloc or calloc, I just say "why bother" and use Java instead.
Yeah, I know there are weird extensions to GCC that allow for array bounds checking and you can use valgrind, but with Java you get that stuff out of the box, complete with a stack trace.
Anyway, I'm rambling and this post is getting long, so I'll just say MERRY CHRISTMAS EVERYBODY!
~Eric





