Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / January 2004



Tip: Looking for answers? Try searching our database.

Can't set breakpoints at certain lines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charles Thomas - 22 Jan 2004 20:31 GMT
I have noticed that there are certain lines in my code which are being
called yet do not have the little dashes next to them which enable me to
set breakpoints on that code.

For example:

  unsigned long     test_date = 0;
 
   //***** Search the read array for the oldest message
  for (i = 0; i < MAX_INPUT_MESSAGES; i++)
  {
     test_date = message_array[i].date_time;
     if (test_date < oldest_date)
     {
        oldest_date = message_array[i].date_time;
        index = i;
     }
  }

In this bit of code I cannot set breakpoints at lines 1 or 6.  Also
"test_date" doesn't show up as a variable in the debugger even if I
break at one of the other lines in the method.

I've turned inlining off in the C language menu.

I'm on Mac OSX.

Thanks for any help.

CT
Steve - 22 Jan 2004 21:18 GMT
On 22/1/04 8:31 pm, in article
cthomas-4BFEBC.14312722012004@teta.doit.wisc.edu, "Charles Thomas"
<cthomas@REMOVE_SPAM_BLOCK.facstaff.wisc.edu> wrote:

> I have noticed that there are certain lines in my code which are being
> called yet do not have the little dashes next to them which enable me to
[quoted text clipped - 26 lines]
>
> CT

Inlining may be turned off, but what about your optimization level (under
Code Gen/Global Optimization in the project's preferences).

I don't claim to know the details, but I suspect at the level you've got,
the compiler has optimized away some code, and perhaps used a register for
test_date.

Maybe.

Steve.
MW Ron - 22 Jan 2004 22:44 GMT
>I have noticed that there are certain lines in my code which are being
>called yet do not have the little dashes next to them which enable me to
[quoted text clipped - 22 lines]
>
>I'm on Mac OSX.

I'd have to know more, for example what are lines 1 and 6 in the above
example and optimizations  It may be your code is not used and just dead
stripped out  for example index  = i might or might not be stripped out.

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

Charles Thomas - 23 Jan 2004 17:26 GMT
> >For example:
> >
[quoted text clipped - 21 lines]
> I'd have to know more, for example what are lines 1 and 6 in the above
> example and optimizations.

I'm not sure what you mean, Ron.

Line 1:  unsigned long     test_date = 0;
Line 6:  test_date = message_array[i].date_time;

> It may be your code is not used and just dead
> stripped out  

Well, clearly it is being used since the variable is having a value
assigned to it, then is being tested against the value of oldest_date.

Perhaps I don't understand your definition of "not being used" in this
context.

CT
MW Ron - 23 Jan 2004 18:44 GMT
>> >For example:
>> >
[quoted text clipped - 26 lines]
>Line 1:  unsigned long     test_date = 0;
>Line 6:  test_date = message_array[i].date_time;

I didn't know if you counted comments or blank lines.  These lines have
breakpoints for me.

>> It may be your code is not used and just dead
>> stripped out  
>
>Well, clearly it is being used since the variable is having a value
>assigned to it, then is being tested against the value of oldest_date.

Not necessarily for example the compiler can see that your code does
nothing but increment from zero to some number and skip all of the loops
and just go to the last number.  

>Perhaps I don't understand your definition of "not being used" in this
>context.

it is optimized out and not used  or isn't used period.

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

Charles Thomas - 23 Jan 2004 19:28 GMT
>> >   unsigned long     test_date = 0;
>> >  
[quoted text clipped - 8 lines]
>> >      }
>> >   }

> >Well, clearly it is being used since the variable is having a value
> >assigned to it, then is being tested against the value of oldest_date.
>
> Not necessarily for example the compiler can see that your code does
> nothing but increment from zero to some number and skip all of the loops
> and just go to the last number.  

I guess I'm just not following you.  If the code is creating a variable
test_date and assigning the value of message_array[i].date_time to it,
then comparing that value to see if it's less than the value in the
variable oldest_date, how can it be considered "not used"?

Not only is it used, but the entire method fails if this comparison
isn't done.

CT
MW Ron - 23 Jan 2004 22:31 GMT
>>> >   unsigned long     test_date = 0;
>>> >  
[quoted text clipped - 20 lines]
>then comparing that value to see if it's less than the value in the
>variable oldest_date, how can it be considered "not used"?

I'm talking generic and you are talking specifics which is why you may
not be follwoing.

However the point is if this has optimizations on, no matter what,
processor scheduling, peephole etc then it may be optimized away, you
can't do debugging and see every line if optimizations are on.

>Not only is it used, but the entire method fails if this comparison
>isn't done.
OK suppose instead of

test_date = message_array[i].date_time;
 if (test_date < oldest_date)

you used

if (message_array[i].date_time < oldest_date)

I'm telling you that the compiler with optimizations on is smart enough
to figure that out and make the substitution thereby making the first
and sixth lines unused

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

Charles Thomas - 26 Jan 2004 17:25 GMT
> >isn't done.
>  OK suppose instead of
[quoted text clipped - 9 lines]
> to figure that out and make the substitution thereby making the first
> and sixth lines unused

Ah, I see your point now.  Thanks for clarifying.

The reason I often use the more verbose method is *specifically* to
debug those values while stepping through the code.  If message_array
isn't a variable local to the method in question there's no way to check
its value as you're stepping through the code (it doesn't show up in the
variable list of the debugger), so I create a local copy of it in the
method to check the value during debugging.

This used to be a good way to do this, but now with optimizations I've
been outsmarted by the compiler!

I guess I've not yet found all the places to turn off optimizations.

I'll keep looking.

CT
MW Ron - 27 Jan 2004 04:09 GMT
>> >isn't done.
>>  OK suppose instead of
[quoted text clipped - 25 lines]
>
>I'll keep looking.

declare the variable volatile  then it can't be optimized away.

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.