views:

261

answers:

1

I was having some problems with memory (exc-bad-access) in Objective-C, XCode, for iPhone, so I searched a little bit and found about the (awesome) NSZombieEnabled. Everyone outhere is just explaining how cool this is ... but it doesn't work for me :/

I followed the following 'tutorial': http://www.cocoadev.com/index.pl?DebuggingAutorelease

  • I double clicked on the executable under the executable tab (left panel) and I added NSZombieEnabled=YES to the environmental variables
  • I also added a bunch of other options (like malloc history, some custom ~/.gdbinit that I found on the web, etc) but this didn't solve the problem

So basically when I launch (in debug mode) GDB sais

"Undefined command: "NSZombieEnabled". Try "help".

And it basically stops (in the status bar it says - error in GDB - terminating).

+2  A: 

The problem is most likely in your ~/.gdbinit file in that the error you have provided indicates that gdb was trying -- and failing -- to parse a command.

In .gdbinit, the command should look like:

set env NSZombieEnabled=YES

To help further, you'd need to drop your .gdbinit in the question. However, there is rarely a need to use a .gdbinit file (for all but advanced debugging). I'd suggest deleting it.

For autorelease debugging, use Instruments....

bbum
http://www.cocoadev.com/index.pl?NSZombieEnabledI got the .gdbinit from this site. As I said - the only thing that really triggers the gdb crash is setting NSZombieEnabled in the environment variables via xcode. If I remove the tick there everything works fine (except that I don't have NSZombieEnabled :)).I added this to my .gdbinit after it was already crashing.
Iskren Ivov Chernev
OK -- then how are you setting up environment variable in Xcode? You might be able to select the line in the environment variable editor and copy/paste.
bbum