Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Session 412 - Debugging with Xcode

wwdcman
August 20, 2012
110

Session 412 - Debugging with Xcode

wwdcman

August 20, 2012
Tweet

Transcript

  1. These are confidential sessions—please refrain from streaming, blogging, or taking

    pictures Session 412 Debugging in Xcode Ken Orr Xcode Debugger UI Manager
  2. Exception and Symbolic Breakpoints Type of Exception Breakpoint Allows you

    to stop on all exceptions, Objective-C exceptions, or C++ exceptions
  3. Exception and Symbolic Breakpoints When to Break Allows you to

    specify whether you want to break on catch or throw
  4. Exception and Symbolic Breakpoints Module Name Lets you restrict what

    libraries with the specified symbol name should result in a pause
  5. Editing Breakpoints Condition to Evaluate An expression to evaluate in

    order to determine if the breakpoint should be stopped at
  6. AppleScript Breakpoint Action tell application "Mail" set myMessage to make

    new outgoing message with properties {visible:false, subject:"Test Failed", content:"The test failed"} tell myMessage make new to recipient at end of to recipients with properties {name:"Ken Orr", address:"[email protected]"} myMessage send end tell end tell
  7. Viewing Your Variables Viewing Mode Auto - variables around the

    line of code you’re paused at Local - all variables in local scope All - all variables including globals and registers
  8. Viewing Your Variables Variable Kind Local Variable Argument Static Variable

    Global Variable Register Instance Variable Expression
  9. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; }
  10. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; }
  11. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; } return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]];
  12. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; } return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]];
  13. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; } [_textField setStringValue:[self currentProcessNameString]];
  14. Return Value When Stepping Out - (void)updateLabel { [_textField setStringValue:[self

    currentProcessNameString]]; } - (NSString *)currentProcessNameString { return [NSString stringWithFormat:@"Current process is %@", [[NSProcessInfo processInfo] processName]]; } [_textField setStringValue:[self currentProcessNameString]];
  15. A Bit About Variable Summaries title = (__NSCFString *) 0x1234

    @”WWDC12” [title description] Previously implemented with expressions:
  16. A Bit About Variable Summaries LLDB Block of memory representing

    __NSCFString Character Data LLDB looks inside the object and reads the memory of the specific data it wants
  17. Creating Custom Summaries import lldb def circle_summary(valueObject, dictionary): # grab

    the bounds of the SKTCircle. bounds = valueObject.GetChildMemberWithName('_bounds') size = bounds.GetChildMemberWithName('size') … return 'Major Radius = ' + majorRadiusAsString + ', Minor Radius = ' + minorRadiusAsString + ', Area = ' + areaAsString LLDB
  18. Creating Custom Summaries import lldb def circle_summary(valueObject, dictionary): SBValue #

    grab the bounds of the SKTCircle. bounds = valueObject.GetChildMemberWithName('_bounds') size = bounds.GetChildMemberWithName('size') … return 'Major Radius = ' + majorRadiusAsString + ', Minor Radius = ' + minorRadiusAsString + ', Area = ' + areaAsString LLDB
  19. Creating Custom Summaries import lldb def circle_summary(valueObject, dictionary): Don’t use

    this parameter # grab the bounds of the SKTCircle. bounds = valueObject.GetChildMemberWithName('_bounds') size = bounds.GetChildMemberWithName('size') … return 'Major Radius = ' + majorRadiusAsString + ', Minor Radius = ' + minorRadiusAsString + ', Area = ' + areaAsString LLDB
  20. Creating Custom Summaries import lldb def circle_summary(valueObject, dictionary): # grab

    the bounds of the SKTCircle. bounds = valueObject.GetChildMemberWithName('_bounds') size = bounds.GetChildMemberWithName('size') … return 'Major Radius = ' + majorRadiusAsString + ', Minor Radius = ' + minorRadiusAsString + ', Area = ' + areaAsString LLDB
  21. What Is an XPC Service Crashy Bits Privileged Bits Your

    App Process App Logic XPC Services (separate processes)
  22. More Information Michael Jurewitz Developer Tools Evangelist [email protected] Documentation LLDB

    Custom Summaries http://lldb.llvm.org/varformats.html Documentation LLDB Scripting http://lldb.llvm.org/scripting.html Apple Developer Forums http://devforums.apple.com
  23. Related Sessions Debugging with LLDB Presidio Friday 10:15AM Cocoa Interprocess

    Communication with XPC Russian Hill Thursday 4:30PM OpenGL ES Tools and Techniques Pacific Heights Wednesday 3:15PM Learning Instruments Presidio Wednesday 4:30PM
  24. Labs Xcode Lab Developer Tools Lab B Ongoing LLDB Lab

    Developer Tools Lab C Friday 11:30AM