Wednesday, July 11, 2012

Power With LLDB Objective-C Debugger

I have come to realize there is a huge and powerful tool called the LLDB debugger which is used by Objective-C programmers now instead of gdb. In the past, I have used some of the commands of the gdb debugger, however this map at
http://lldb.llvm.org/lldb-gdb.html shows me a wonderful number of things at my disposal that I never knew existed in gdb.

The current command of interest is the replacement for gdb's info symbol command which shows "information for a raw address in the executable or any shared libraries"
(gdb) info symbol 0xa0b06174
That replacement in lldb is image lookup
(lldb) image lookup --address 0x1ec4
I highly recommend all Objective-C programmers skim http://lldb.llvm.org/lldb-gdb.html aka The LLDB Debugger command map and smile at all that you have available!


Update:

We ended up switching back to gdb. 


We were able to see the offending code once we switched back to gdb from lldb and applied what we could from http://coderslike.us/2009/05/05/finding-freeddeallocated-instances-of-objects/


The solution to the memory issue was:
  • create a UIColor
  • store that in a variable such as someUIColor
  • pull out from someUIColor.CGColor the CGColorRef and pass that on to whatever needs it

It seems that doing something like this is bad in ARC and one should use UIColor (which is an NSObject):

CGColorRef crashingColor = [[UIColor colorWithRed:1 green:1 blue:160.0/255.0 alpha:1] CGColor];