Path: chuka.playstation.co.uk!news From: Nick Slaven Newsgroups: scee.yaroze.programming.codewarrior Subject: Re: Debugger problem Date: Sun, 07 Jun 1998 19:56:31 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 52 Message-ID: <357AE25F.83EEAC60@compuserve.com> References: <6lemid$1293@chuka.playstation.co.uk> NNTP-Posting-Host: ld19-030.lon.compuserve.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Mark Wilson wrote: > > Another bug-ette has just reared its head, unless I've done something really > stupid... which has been known. > > A routine I was working on was playing up, so I stuck in a breakpoint. There > my troubles began. > > void GetCurrentPosition(Obj *obj) > { > > short i, d, deltax, deltay; > > int dinc1, dinc2, xinc1, xinc2, yinc1, yinc2; > > deltax = obj->tx - obj->sx; > deltay = obj->ty - obj->sy; > > Setting a breakpoint on the "deltay = " line I noticed that deltax was > coming out as 0, not -640. Stepping through the next line, I found that > deltay was being calculated OK. > > So I stuck in a printf before the calculation like > > printf("%d\t%d%t%d\n", obj->tx, obj->sx, obj-tx - obj->sx); > > which returned exactly the figures I'd expected, 0, 640 and -640. A printf > AFTER the calculation showed that deltax was in fact being set up correctly, > and was just not being displayed in the debugger. > > Any ideas? > > Mark I think this is a bug in the debugger, 'cos I've also had the same problem. I think that if the compiler optimises your local variables into registers then the debugger wont display them. If you open up the register window you will find that one of the registers will update with the values you'd expect. This can be overcome by using the keyword "volatile" as follows volatile short i,d,deltax,deltay; and the debugger will display the variables correctly. cheers Nick Slaven -- http://www.netyaroze-europe.com/~nslaven/