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

LLDB

Khoa Pham
August 27, 2015

 LLDB

Tips on using LLDB

Khoa Pham

August 27, 2015
Tweet

More Decks by Khoa Pham

Other Decks in Programming

Transcript

  1. LLDB
    Khoa Pham - 2359 Media

    View full-size slide

  2. LLDB
    Home page http://lldb.llvm.org/
    LLDB is an open-source debugger that features
    a REPL, along with C++ and Python plugins

    View full-size slide

  3. Menu
    - Command
    - Use cases
    - Python
    - Chisel
    - Standalone

    View full-size slide

  4. Command - help
    Information on any command
    help print
    help thread continue
    help help

    View full-size slide

  5. Command - print
    Print value
    print a
    print self

    View full-size slide

  6. Command
    Prefix matching
    print, prin, pri, p
    expression, e
    Can’t use
    pr (print or process?)

    View full-size slide

  7. Command
    $ variable
    Anything starting with a dollar sign is in LLDB’
    s namespace and exists to help you
    print $0 + 7

    View full-size slide

  8. Command - expression
    Evaluate an expression (ObjC++ or Swift) in the
    current program context,
    Modify values in the program
    expression $0 = 10
    e $0 = 10

    View full-size slide

  9. Command - print
    'print' is an abbreviation for 'expression --'.
    Use -- to signify the end of the flags and the
    beginning of the input
    e --location -- -count

    View full-size slide

  10. Command - print object
    See the description method of an object
    e -O -- aString
    po aString

    View full-size slide

  11. Command - variable
    The variable must start with a dollar sign
    e NSInteger $b = 10;
    p $b + a

    View full-size slide

  12. Command - flow
    Continue
    process continue, continue, c
    Step over
    thread step-over, next, n

    View full-size slide

  13. Command - flow
    Step into
    thread step-in, step, s
    Step out
    thread step-out, finish

    View full-size slide

  14. Command - thread return
    Executes the return command, jumping out of
    the current stack frame
    thread return YES

    View full-size slide

  15. Breakpoint
    List breakpoints
    br li
    Create breakpoints
    br set -f ViewController.m 39

    View full-size slide

  16. Use cases
    Find targets of a button
    po [self.myButton allTargets]

    View full-size slide

  17. Use cases
    See the frame
    po self.view.frame
    e @import UIKit
    po self.view.frame

    View full-size slide

  18. Use cases
    Change background color without continue
    e self.view.backgroundColor = [UIColor greenColor]
    e (void)[CATransaction flush]

    View full-size slide

  19. Use cases
    Watch variable
    wivar self _number

    View full-size slide

  20. Python
    LLDB has full, built-in Python support. If you
    type script in LLDB, it will open a Python REPL

    View full-size slide

  21. .lldbinit
    Executed every time LLDB starts
    command script import /path/to/fblldb.py

    View full-size slide

  22. Chisel
    brew update
    brew install chisel
    # ~/.lldbinit
    command script import /path/to/fblldb.py

    View full-size slide

  23. Standalone
    Using LLDB as a Standalone Debugger

    View full-size slide

  24. References
    - Getting Started with LLDB
    - Dancing in the Debugger — A Waltz with LLDB
    - Video Tutorial: Using LLDB in iOS
    - Navigating and discovering an iOS codebase using lldb
    - chisel

    View full-size slide