Re: Debugger fails to see a NSString object that NSLog can see & print.
Re: Debugger fails to see a NSString object that NSLog can see & print.
- Subject: Re: Debugger fails to see a NSString object that NSLog can see & print.
- From: email@hidden
- Date: Wed, 10 Sep 2008 08:59:45 -0700 (PDT)
Per Fritz Anderson:
> A question I'd ask is whether you've turned on optimization. In
> optimized code, gcc is free to re-use storage for a variable after its
> last use in a function. So the address that had been the value of
> serverDataString gets overwritten with NULL, for another variable,
> once serverDataString is past its useful life. Turning optimization
> off, such as by using the Debug configuration, will prevent this.
>
> Am I on the right track?
Yes!
I had the Optimization to smallest code (apparently I changed the environment for ALL vs Release-Only).
I removed the Optimization and the debugger is behaving normally; once again.
Thanks.
Ric.
On 09/10/2008 08:43 Fritz Anderson wrote ..
>
> On 10 Sep 2008, at 9:59 AM, email@hidden wrote:
>
> > Environment: Xcode 3.1 (Core: #1100)
> >
> > Greetings:
> >
> > Scenario:
> > 1) I'm transmitting data (XML) to a server and got a response.
> > 2) The debugger can see the serverResponse as shown below.
> > 3) But I'm unable to view the actual server data received; although
> > NSLog does see it.
> >
> > Why?
> ...
> > Here's a snippet of the source code:
> > ..
> > // -----------------------
> > // 4) Get Synchronous Data:
> > serverData = [NSURLConnection sendSynchronousRequest:theRequest
> >
> > returningResponse:&serverResponse
> >
> > error:&myError];
> >
> > // -----------------------
> > // 5) Convert Synchronous Data into Human-Readable String (Unicode
> > 8) format:
> > NSMutableString *serverDataString = [[NSMutableString alloc]
> > initWithData:serverData encoding:NSUTF8StringEncoding];
>
> Apparently you have a breakpoint here, and you inspect some variables
> -- but it appears from your description, you do NOT inspect
> serverDataString. You seem to be saying that you "continue" through
> the NSLog (which prints the expected value), and you try to "po"
> serverDataString at some _later_ point. Am I reading you right?
>
> > NSLog(@"{PG_Transmission} serverDataString=
> > %@",serverDataString); // ok.
>
> > So the debugger retrieves a zero memory address for a NSString object
> > that NSLog can print/store. Why?
>
> A question I'd ask is whether you've turned on optimization. In
> optimized code, gcc is free to re-use storage for a variable after its
> last use in a function. So the address that had been the value of
> serverDataString gets overwritten with NULL, for another variable,
> once serverDataString is past its useful life. Turning optimization
> off, such as by using the Debug configuration, will prevent this.
>
> Am I on the right track?
>
> F
>
> --
> Fritz Anderson -- Xcode 3 Unleashed: Now Available -- http://x3u.manoverboard.org/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden