How do you get NVCC to include macro definition information?

This is a repost from a Stack Overflow question. No one knew the answer there.

Normally with gcc you can specify the level of debugging information with -g and if you use -g3 it will include preprocessor macro definitions in the executable which debuggers like gdb can read and allow you to use during debugging. I would like to do this with nvcc for debugging CUDA programs.

I am currently working by modifying the template program in the SDK so I’m using the default Makefile and included from the Makefile. In within the ‘ifeq ($(dbg), 1)’ block, I have tried the following:

    put -g3 under COMMONFLAGS

    put -g3 under NVCCFLAGS

    put -g3 under CXXFLAGS and CFLAGS

    put --compiler-options -g3 under NVCCFLAGS.

The first two give an unrecognized option error. The second two do not seem to do the trick because when I debug using cuda-gdb I don’t get the macro information.

The reason I would like to do this is because I would like to inspect some memory using the same macros the program itself uses to access that memory. For example,

#define ARROW(state, arrow) ((c_arrow_t *)(&((state)->arrows) + (arrow) * sizeof(c_arrow_t)))                                                                                                  

     #define STATE(nfa, state) ((c_state_t *)(&((nfa)->states) + (state) * sizeof(c_state_t)))

are some macros I use to access states and arrows of a non-deterministic finite state automaton.

Thank you for your help!