3 ms·
What does the comment about stack unwinding refer to? I've always found macros pretty horrid for debugging because you can't step through them properly. I just
by to3m 11y ago
What does the comment about stack unwinding refer to?
I've always found macros pretty horrid for debugging because you can't step through them properly. I just tried with gcc 6.0 and gdb 7.11 and it still seems to be unsupported, 20-odd years after the first time I rued the lack of this functionality. At this rate I strongly suspect this will never, ever work. (Another black mark against macros that expand to anything significant, in my view.)
- PeCaN 11y agoDWARF 3 and 4 can contain information about macros, and GDB can expand them (macro exp foo(bar,...)). Compile with the somewhat under-mentioned flags -gdwarf-4 -g3 to retain macro definitions. This lets you debug expansions easily, but doesn't map already-compiled macro expansions back to their macro definitions. If you want to step through execution of a function defined by a macro, preprocess with -E -P and compile that. For more advanced (and pleasant) macro debugging, you can do a little trick: 1. Create an e.g. include/dummy directory and create empty versions of whatever headers you don't want to expand. 2. Run your files through $CC -E -P -Iinclude/dummy 3. clang-format is your friend for making the output much nicer. 4. Compile with explicit -include of the real versions of files in include/dummy. 5. Debug normally. It takes a little bit of effort to get right, but after that you can just throw it in a Makefile and forget about it (e.g. https://github.com/alpha123/yu/blob/master/Makefile#L96-L126 https://github.com/alpha123/yu/blob/master/Makefile#L96-L126).