3

I'm playing with gdb within xcode debugging an iphone app.

Supposedly, I should be able to use the following command:

info malloc <0xaddress>

see http://www.friday.com/bbum/2010/01/10/using-malloc-to-debug-memory-misuse-in-cocoa/ and strange GDB error unable to trace

I have env vars MallocStackLoggingNoCompact = 1 and NSZombieEnabled = YES set (via the executable in xcode).

However, I am getting this:

2010-10-03 21:29:01.366 memleaktest[10881:307] *** -[one release]: message sent to deallocated instance 0x1646b0
(gdb) info malloc 0x1646b0
Undefined info command: "malloc 0x1646b0".  Try "help info".

What am I missing to run this command? (xcode 3.2.4 and iphone SDK 4.1)

3 Answers 3

3

Turns out you can only info malloc whilst debugging in the simulator - not on device.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. In Xcode go to Run -> Enable Guard Malloc
  2. Set environment variable MallocStackLoggingNoCompact to YES (as you already did)

to make sure the logs are being written, in the debugger console you should see this message:

malloc: stack logs being written into /tmp/stack-logs.xxxx.MyApp.xxxxxx.index

Now you should be able to:

(gdb) info malloc 0x1646b0

3 Comments

Unfortunately this is still not working. A few things I've noticed: a) if I just type 'info' I don't see malloc as possible subcommand. b) I get memtest(2739) malloc: stack logs being written into /private/var/mobile/Applications/1F962F35-9C52-4490-9D22-F5D41DC6AB7C/tmp/stack-logs.2739.memtest.index memtest(2739) malloc: Please issue: cp /private/var/mobile/Applications/1F962F35-9C52-4490-9D22-F5D41DC6AB7C/tmp/stack-logs.2739.memtest.DUY4ZH.link /tmp/ which is a location on my iphone, not my mac
c) the original friday.com article mentions garbage collection I now realise, which is mac only - so does this even apply to the iphone?
OK. This stuff does work for iphone, but only using the simulator. Try and debug on device and you get the weirdness in my previous comments. I found though you did not need guard malloc on. Thanks for the help though.
0

Experience the same tough issue, any workable method found? Tough this crash only occurs in device not simulator.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.