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 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 Slide

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

    View Slide

  4. Command

    View Slide

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

    View Slide

  6. Command - print
    Print value
    print a
    print self

    View Slide

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

    View Slide

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

    View Slide

  9. 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 Slide

  10. 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  20. Use cases
    Watch variable
    wivar self _number

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  24. Standalone
    Using LLDB as a Standalone Debugger

    View Slide

  25. 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 Slide