Saturday, March 5, 2011

How can I get GCC to be much more verbose?

I've got a very strange situation, in which my GCC compiler (v. 4.2.1 I think) is acting oddly: it is apparently computing the wrong offset for a particular field of a particular structure.

Now, I'm sure this is actually not the compiler's fault, but is my own; somehow, I have made some exceedingly subtle mistake in my header file declarations, and the compiler is simply doing what I told it to. Remember: the last explanation that you choose should be "it's a bug in the compiler". It's vastly more likely that you have just given it invalid code to compile.

But, GCC isn't telling me that my code is invalid; it is compiling my code into something that produces a strange result.

And my attempts to reduce this to a smaller standalone example have not produced a similar behavior.

So how can I get GCC to tell me more about what it's doing, and why? Ideally, I'd like to have some sort of tracing capability where I can get GCC to dump out the exact code that it's actually compiling (after all the various preprocessor includes and macro definitions have been performed, etc.), together with a listing that shows how it is translating that source code into object code.

Then maybe I could see what's wrong.

Is there a GCC feature that does this?

1 comment: