Re: Expanding and debugging macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/27/2020 7:23 AM, Jeffrey Walton via Gcc-help wrote:
Hi Everyone,

I'm trying to debug a c function that is mostly a massive collection of macros.

I changed the makefile recipe to preprocess the source trying to
produce something I can step:

#blake2b: blake2b.c
# $(CC) blake2b.c -o $@ $(CFLAGS) $(POWER8_CFLAG) -DBLAKE2B_SELFTEST

blake2b: blake2b.c
$(CC) -E blake2b.c -o blake2b.E $(CFLAGS) $(POWER8_CFLAG)
-DBLAKE2B_SELFTEST
$(CC) -x c blake2b.E -o $@ $(CFLAGS) $(POWER8_CFLAG) -DBLAKE2B_SELFTEST

But GDB is not stepping it:

238 ROUND( 0 );
(gdb) s
239 ROUND( 1 );
(gdb) s
240 ROUND( 2 );
(gdb) q

I also switched to -save-temps with the same result - no stepping.

blake2b: blake2b.c
$(CC) -E blake2b.c -o blake2b.i $(CFLAGS) -save-temps
$(POWER8_CFLAG) -DBLAKE2B_SELFTEST
$(CC) blake2b.i -o $@ $(CFLAGS) $(POWER8_CFLAG) -DBLAKE2B_SELFTEST

Is there a way to achieve this using GCC without changing the source files?

Thanks in advance.


You can do step by step expansion of a macro using the Wave tool from the Wave library in Boost. It is excellent and works as a C++ standard compliant preprocessor. I have also found gcc's preprocessor to also be excellent and completely C++ standards compliant, so I would not be surprised if the step by step expansion if a macro using the Wave tool mimicked exactly the same step by step expansion of a macro in the gcc preprocessor.





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux