Tarang- Unless optimization is completely off, you simply cannot expect any local variable to be stay consistent inside a function. I.e. if you hold your cursor over a local variable you might see undefined results. The suggestion for Zulfiqar is to turn off all optimization when debugging. If he cannot do that, then (temporarily) make as many variables global (outside the function) as possible. That allows correct values to be observed at all times during single-step or breakpoint. -Jeff -------- Original Message -------- Subject: Re: Re: [code-comp] Max Number Of Arguments passed to function is t maximum 4? Date: 6 Jun 2004 03:56:17 -0000 From: "tArAng" <> Reply-To: "tArAng" <> To: Hi, No.. total number of arguments that u can pass to a function is not 4 for sure.. I had similar kind of problem with my system... the thing is the arguments are being passed thru regsiters and if all registers are used up then thru stack... The reason I see for changing values ( when u pass them to function) is because after you pass the arguments.. the registers are used by the processor to perform different tasks so the register no longer represents the variable.. ( wht i mean to say is regsiter is not fixed address of the variable) value of variable is placed on to stack .. and later on accessed back when needed.. all this is internally taken care of by compiler .. provided u hav proper stack allocation .. .. I would definately recommend you to go thru part 8.4 Run time Environment ( of TMS320C6000 Optimizing Compiler Users Guide (SPRU187K) http://focus.ti.com/lit/ug/spru187k/spru187k.pdf hope this helps.. Best Regards, Tarang Dadia Graduate Student Wireless Networking Lab University of Texas - Arlington On Sat, 05 Jun 2004 Andrew Nesterov wrote : >It seem as if the erroneous function call differs from the >function declaration. There are three places to check to >be coherent: the function declaration (in an include file), >the function definition (check the paramemters of the >implementation) and the function call. >The stack size wouldn't affect on a call with a resonable >number of arguments, since they are passed in the registers. >Regards, >Andrew >> Date: Thu, 3 Jun 2004 20:45:45 -0700 (PDT) >> From: Zulfiqar Khan <> >> Subject: Max Number Of Arguments passed to function is t maximum 4? >> >> Hello >> Can any one help me in solving the following problem : >> >> If numbe of aguments passed to a funcrion exceeds from >> 4 the function gives irrtaing behaviour. I mean if fo >> example i passed the argumnt 315 to the function the >> function converts it to 0 & then to 235, i.e. no >> contol on the value. >> >> I have increased the stack size but it does not solve >> my problem >> >> Looking for the favourarable reply >> >> Zulfiqar |
|
[Fwd: Re: Re: Max Number Of Arguments passed to function is t maximum 4?]
Graduate Student Wireless Networking Lab University of Texas at Arlington. |
Tarang- Yes I think you are mostly right; your observations match mine. My preference is not to guess. CCS is complicated enough; I'm not trying to learn everything it -- or the emulator -- does. And TI will change it again in v3.x anyway. Think of some of the things Jagadeesh has put into TI's optimization: even if you KNOW which register to watch, what happens if optimized code uses the pipeline to store the reg transiently? If that's in one line of code, the emulator won't even stop before your result has vanished. In highly optimized code, you would have to always single-step through assembly language to really understand what is happening -- which, I think safe to say, defeats the purpose of debugging C code in the first place. My method is brute force, which I find helps a lot with CCS. Anything I want to see, I either: 1a) put in global var if I still want optimization enabled, then watch/cursor on global var. Yes there is a "Heisenberg Uncertainty Principle" effect in doing this, but still it can be very useful 1b) similar to 1a, but store *copy* of local var to global var 2) turn off *all* optimization And sometimes use #ifdef _DEBUG_MODE_ switch or similar to turn this on/off easily. -Jeff tArAng wrote: > > > Hi Jeff, > > On Mon, 07 Jun 2004 Jeff Brower wrote : > >Tarang- > >Unless optimization is completely off, you simply cannot expect any local variable to > >be stay consistent inside a function. I.e. if you hold your cursor over a local > >variable you might see undefined results. > > Do you mean to say that whenever optimization is ON, the variables generally do not reflect the true value ( i.e when we place a cursor on it). Then is it true even if we watch those variables in watch window? > > When I was stuck up in this kind of situation I did not have optimization turned ON then too the variables(arguments of functions to be more specific) used to change the values even if I didnt perform any operation on them. Now wht I mean by "variables used to change values " is that .. I used to WATCH those variables in watch window... and over there as I use to single step these variables chaged the values.. and I kind of attributed this change to this theory... ( i may be completely wrong .. pl correct me ) > > As far as I have understood, watch window just pulls up the values corresponding to the address instead of the name of the variable. Say for example If I pass a argument to a function and then WATCH it, all I would be able to see is the value of the register which was used to catch the argument. ( I came to this conclusion since I tired doing &<variable name> and watch window said cannot make pointer to register). And so as and when this register is used by processor for some other operation its value will change and same will be reflected back to WATCH window. This has happened to me even if optimization is OFF. This is my part of story .. .. kindly correct me if I am wrong. > > sorry for so much verbosity ... but hope u understand the necessity. > > >The suggestion for Zulfiqar is to turn off all optimization when debugging. If he > >cannot do that, then (temporarily) make as many variables global (outside the > >function) as possible. That allows correct values to be observed at all times during > >single-step or breakpoint. > >-Jeff > > Making all variable global seems to b nice workarnd but then wont his problem still persist whenever he uses those variables back in the function? > > Thanx a lot, > > Tarang Dadia > Graduate Student > Wireless Networking Lab > University of Texas - Arlington > > >-------- Original Message -------- > >Subject: Re: Re: [code-comp] Max Number Of Arguments passed to function is t maximum > >4? > >Date: 6 Jun 2004 03:56:17 -0000 > > From: "tArAng" <> > >Reply-To: "tArAng" <> > >To: > >Hi, > >No.. total number of arguments that u can pass to a function is not 4 for sure.. I > >had similar kind of problem with my system... the thing is the arguments are being > >passed thru regsiters and if all registers are used up then thru stack... > >The reason I see for changing values ( when u pass them to function) is because after > >you pass the arguments.. the registers are used by the processor to perform different > >tasks so the register no longer represents the variable.. ( wht i mean to say is > >regsiter is not fixed address of the variable) value of variable is placed on to > >stack .. and later on accessed back when needed.. all this is internally taken care > >of by compiler .. provided u hav proper stack allocation .. .. > >I would definately recommend you to go thru part 8.4 Run time Environment ( of > >TMS320C6000 Optimizing Compiler Users Guide (SPRU187K) > >http://focus.ti.com/lit/ug/spru187k/spru187k.pdf > >hope this helps.. > >Best Regards, > >Tarang Dadia > >Graduate Student > >Wireless Networking Lab > >University of Texas - Arlington > >On Sat, 05 Jun 2004 Andrew Nesterov wrote : > >>It seem as if the erroneous function call differs from the > >>function declaration. There are three places to check to > >>be coherent: the function declaration (in an include file), > >>the function definition (check the paramemters of the > >>implementation) and the function call. > >>The stack size wouldn't affect on a call with a resonable > >>number of arguments, since they are passed in the registers. > >>Regards, > >>Andrew > >>> Date: Thu, 3 Jun 2004 20:45:45 -0700 (PDT) > >>> From: Zulfiqar Khan <> > >>> Subject: Max Number Of Arguments passed to function is t maximum 4? > >>> > >>> Hello > >>> Can any one help me in solving the following problem : > >>> > >>> If numbe of aguments passed to a funcrion exceeds from > >>> 4 the function gives irrtaing behaviour. I mean if fo > >>> example i passed the argumnt 315 to the function the > >>> function converts it to 0 & then to 235, i.e. no > >>> contol on the value. > >>> > >>> I have increased the stack size but it does not solve > >>> my problem > >>> > >>> Looking for the favourarable reply > >>> > >>> Zulfiqar |