Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Old CodeWarrior debugger memory layout question

14 views
Skip to first unread message

charle...@gmail.com

unread,
Dec 6, 2012, 10:00:40 AM12/6/12
to
I'm working with an old copy of CodeWarrior (Pro v6) from circa 2000. In the process of debugging a crash, I'm seeing a change to a variable that is totally unrelated to the variable being changed by the current instruction.

I would like to know how the variables in my program are actually stored in memory. That is say I have the following variables declared:

short a;
long b;
short c;
long d;


When the compiler allocates storage for the variables does memory look like:
|aa|bbbb|cc|dddd|
or
|aa--|bbbb|cc--|dddd|
or
something else entirely?

Can I display a memory map of my data section in some way?


Gary

David Stone

unread,
Dec 6, 2012, 12:49:15 PM12/6/12
to
In article <7970d589-b24d-4308...@googlegroups.com>,
charle...@gmail.com wrote:

> I'm working with an old copy of CodeWarrior (Pro v6) from circa 2000. In the
> process of debugging a crash, I'm seeing a change to a variable that is
> totally unrelated to the variable being changed by the current instruction.

Had that happen to me using Symantec C. It turned out to be the result of
"register colouring" during code optimisation. That is, two variables
were sharing a register because the compiler thought they weren't being
used at the same time. Screwed up the initialisation, though! You could
check the code optimisation options to see if CW has anything like that.

> I would like to know how the variables in my program are actually stored in
> memory. That is say I have the following variables declared:
>
> short a;
> long b;
> short c;
> long d;
>
>
> When the compiler allocates storage for the variables does memory look like:
> |aa|bbbb|cc|dddd|
> or
> |aa--|bbbb|cc--|dddd|
> or
> something else entirely?

Are these local or global functions? Static? Part of a struct or array?

If they are stored in a data register during execution of the function,
then it would look something like your second option.

> Can I display a memory map of my data section in some way?

It's been a long time, so I'm a little fuzzy on details, but you should
at least be able to see the memory address for each variable along with
its value.

charle...@gmail.com

unread,
Dec 7, 2012, 8:40:51 AM12/7/12
to
David -

Thanks for your reply. Your suggestion regarding compiler optimization was exactly right.

Instead of using

short a;

I used

short a = 0;

and the unexpected changes to "a" disappeared. Of course, the actual bug I was chasing was something else entirely.

Gary

David Stone

unread,
Dec 7, 2012, 2:13:56 PM12/7/12
to
In article <c917408b-04df-45da...@googlegroups.com>,
It always is!
0 new messages