I’ve always had major issues with cuda-gdb, and it never worked properly for me, actually, it never did anything useful for me at all, it seems to have far more bugs than my own code.
But, I hit an issue which I just could not find any way of resolving without a debugger, and since I can’t make VS compile anything cuda, (http://forums.nvidia.com/index.php?showtopic=175265) I had few options.
So here’s what I did, hopefully for the benefit of someone else out there.
My problem was that on every call to cudaMalloc() I did, cuda-gdb segfaulted. No error message, no nothing, just died on me.
I added “float a; cudaMalloc((void*)a, 1);” early in my main function. This caused an instant crash as soon as the debugger ran.
Then I commented out everything, not just the calling code from main(), everything.
Suddenly cuda-gdb works, on my single cudaMalloc. I then re-added section by section of code to the project by (re)moving comments, and slowly but surely figured out what caused the crashing.
In my case, it was the use of a “struct error”, and a “enum PositionState”. The error struct was meant to be used to trace the errors that cuda-gdb failed to do, so given a working cuda-gdb, it wasn’t a difficult choice to get rid off. The enum had to be replaced, which wasn’t to much hassle either with the help of ‘sed’. I wonder if these names somehow conflict with internal states in either nvcc, cudart, or cuda-gdb, and that’s what causing the problem. I have many other enums and structs, and I can use them just fine.
And lo and behold, cuda-gdb has now found a bug in my code. :D