Access to symbol table values (after C Preprocessor) in AS6

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

tele_dan
Posts: 2
Joined: Thu Aug 09, 2012 9:33 pm

Access to symbol table values (after C Preprocessor) in AS6

Thu Aug 09, 2012 9:57 pm

Perhaps I am missing some quick AS6 setting, but, I cannot find symbol table final values after they have been digested by the C preprocessor.

For example:
#define BUF_SIZE (63)
#define JOE (7 * BUF_SIZE)
#define ALICE (JOE + 5*BUF_SIZE)

I would like to see the final value for ALICE to verify correctness.
Since my real defines are MANY levels deep and quite complicated,
this is needed to make sure all is well.

So, where are they hiding?

thanks,
Dan
CptTitanic
Posts: 871
Joined: Sat Oct 30, 2010 6:04 pm

Re: Access to symbol table values (after C Preprocessor) in

Thu Aug 09, 2012 10:38 pm

They are text macro expansions, the compiler never sees them as the preprocessor resolves/unfolds them, before passing it into a compiler pass and consequently won't ever be symbols.

Try instead
printf("%d\n", ALICE);

GNU/GCC has a -E option that just runs the preprocessor pass, review the output.
tele_dan
Posts: 2
Joined: Thu Aug 09, 2012 9:33 pm

Re: Access to symbol table values (after C Preprocessor) in

Fri Aug 10, 2012 6:03 am

Thanks Cpt for the Titanic dose of reality. I completely forgot that the CPP just did text substitutions, ad nauseum, until it was just a large string of text at the end going into the compiler.

So, with your suggestion, I added assignment statements, grep'ed the assembly listing for the assembly code and awk'ed my way to get the actual final compiled values to compare with the expected values.

That was better than comparing hundreds of blindingly similar values by hand.

thanks, again, Cpt,
Dan

btw, with the -E option, I confirmed the final expansion for one of the values is over 10130 characters long of all math, parens, and numbers. Lots of fun.

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 1 guest