f



Old CodeWarrior debugger memory layout question

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
0
charleengary
12/6/2012 3:00:40 PM
comp.sys.mac.programmer.help 4653 articles. 2 followers. Post Follow

3 Replies
574 Views

Similar Articles

[PageSpeed] 33

In article <7970d589-b24d-4308-8077-67d50f648605@googlegroups.com>,
 charleengary@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.
0
David
12/6/2012 5:49:15 PM
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
0
charleengary
12/7/2012 1:40:51 PM
In article <c917408b-04df-45da-8513-c458cd82a105@googlegroups.com>,
 charleengary@gmail.com wrote:

> 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.

It always is!
0
David
12/7/2012 7:13:56 PM
Reply: