lldb tips

Commands can have three forms:
Discoverable form: expression –object-description — foo
Abbreviated from  : e -O — foo
Alias: po foo


b MyView.m: 4
breakpoint set –file MyView.m –line 4

b “-[MyViewA drawRect:]”
breakpoint set –name “-[MyViewA drawRect:]”

b drawRect:
breakpoint set –selector drawRect:

br co a / breakpoint command add  Breakpoint commands run each time a breakpoint is hit
> p rect expression rect
> bt thread backtrace
> c process continue

p id $myModel = self  expression id $myModel = self // Create a presistent variable of type id
b “-[MyModel dealloc]”
br m -c “self == $myModel” breakpoint modify –condition “self == $myModel”

Watch Points 4 on Intel, 2 on ARM
w s v self->_needsSynchronization
watchpoint set variable self->_needsSynchronization

Stepping can hit breakpoints
LLDB maintains a stack of things you are doing
When you step, LLDB puts it on the stack
If you hit a breakpoint LLDB remembers the stack
So, when hit continue, LLDB will get you back to where when you hit step

Stepping repeatedly over irrelevant code gets old quickly
th u 11
thread until 11 

Call the code using Clang
b “-[ModelDerived removeDuplicates]”
e -i false — [self removeDuplicates]
expression –ignore-breakpoints false — [self removeDuplicates]

Data Formatters
Xcode 5 can show memory summary in debug area, It has builtin DataFormatters for Foundation CoreFoundation and STL
LLDB pass SBValue to formatter

def MyAddress_Summary(value, unused):
    firstName = value.GetChildMemberWithName("_firstName")
    lastName = value.GetChildMemberWithName("_lastName")
    firstNameSummary = firstName.GetSummary()
    lastNameSummary = lastName.GetSummary()
    return firstNameSummary + " " + lastNameSummary

ty su a MyAddress -F MyAddress_Summary

Define Types in Console
typedef $NoOpaque {
int foo; int bar

Custom LLDB Commands

SB stands for Script Bridge
def MyCommand_Impl(debugger, user_input, result, unused)
co sc a foo -f foo

thread = debugger.GetSelectedTarget().GetProcess().GetSelectedThread()
for frame in thread.frames:
    if frame.function.name == "MyFunction":
        # update counters
    print >>result, "depth: " + str(depth)

~/.lldbinit loaded at debugger startup

Xcode 4 无法打开 Xcode 5 DP 打开过的工程文件 解决方法

试用Xcode 5 DP打开现有工程文件后再用Xcode4打开后 Xcode 4 会进入崩溃模式

如果在Xcode5-DP中打开过xib文件需要在侧栏中修改Interface Builder Document下的Open in为Xcode 4.6, 然后Clean,关掉工程,再到DerivedData中删掉对应的文件夹


另外还可以尝试删除 .xcodeproject中的.xcworkspace 与 xcuserdata

还有打开后4下断点失效的问题,可以试试设置link-time optimization为NO