Re: Bug related to GCC_OPTIMIZATION_LEVEL
Re: Bug related to GCC_OPTIMIZATION_LEVEL
- Subject: Re: Bug related to GCC_OPTIMIZATION_LEVEL
- From: "email@hidden" <email@hidden>
- Date: Tue, 1 Jun 2010 14:34:14 +0100
On 1 Jun 2010, at 13:30, Jason Swain wrote:
> I have an XCode project that runs find in Debug configuration, but when I change to Release if fails with a bug that is hard to track down.
>
> Through trial and error I found that if I turn of all optimizations the code will run correctly, but with any optimization level set the code fails. Debugging is difficult with optimization turned on as the debugger has less information to go on.
>
> The bug presents itself as various Objective-c object variables being nil when they shouldn't be. I've added NSLogs() and they are all set correctly in a property setter in both Debug and Release, but when accessed later in the code they are nil in Release and correct in Debug. This is consistent and only happens in a few classes (with a common parent), so it is probably related to something in that class tree.
>
> This is a difficult one to track down as I can't change to Debug configuration to debug the problem, and in the Release configuration gdb doesn't give me enough information to see what the problem is.
>
> Does anyone have any suggestions on how I should attack this problem?
>
In your debug build configuration set your optimization level to whatever level is giving trouble in your release build.
The optimizations will likely make exact symbolic debugging a bit hit or miss but it should give you some feed back.
Set a breakpoint early on in the life cycle of a problem object and then watch one of the problem ivars.
(gdb) watch -location self->ivarname
This watch point will be triggered whenever the ivar changes and you can dig through the stack track for clues.
If the problem doesn't appear then it's likely that your build settings in the release build are at fault.
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com _______________________________________________
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