Code Monkey home page Code Monkey logo

lldb-quicklook's Introduction

LLDB-QuickLook

LLDB-QuickLook Example 1

LLDB-QuickLook Example 2

LLDB-QuickLook is a debugger command to open images, views, and more using Quick Look. This command is great for inspecting any object that is not well represented by a string in the debugging console. The command is inspired by Xcode's new Quick Look feature, but is better in two ways:

1.) You can inspect any object accessible by an lldb expression, not just objects available in the Xcode GUI. 2.) Any type of object can be inspected by implementing a simple data provider protocol, not just UIImages.

The command is quite simple. It asks an object in your program for debug data, saves the data to a tmp file on your computer, and opens the file using Finder and Quick Look.

Getting Started

  1. Clone the repository.
  2. Copy the .lldbinit file to your home directory (or append the lines to your existing .lldbinit).
  3. Update the path to lldb_quick_look.py in the .lldbinit file to match the script's location on your machine.
  4. Add the DataProviders directory to your Xcode project. LLDB-QuickLook requires Xcode 5 or later.
  5. To use the full version of quick look, ensure that "Enable access for assistive devices" setting is checked in System Preferences.

Enable access for assistive devices

Using the Command

When your program is paused on a breakpoint in lldb, calling the command:

quicklook <object> or ql <object>

will ask the object for its quickLookDebugData and save that data to the object's quickLookFilename. The file will be saved under /tmp/<target> and opened using Finder + Quick Look. You can make any object into a Quick Look data provider by simply implementing the quickLookDebugData and quickLookFilename methods. Simple implementations of data providers for NSObject, UIImage, UIView, NSData, and NSString can be found in the DataProviders directory.

Examples

(lldb) quicklook self.imageView.image

(lldb) ql [[UIApplication sharedApplication] keyWindow]

(lldb) quicklook -f some_object.json -- [self jsonString]

(lldb) ql -l self.view

Some use cases

  • Debugging images not accessible from the Xcode GUI.
  • Debugging views that are not on screen or obscured by another view.
  • Saving images for screenshots or to watch a view change over time.
  • Opening text in a proper editor without having to copy/paste from the console.

Tip: type help quicklook from the lldb prompt to see the options for the command.

About

quicklook uses lldb's powerful (but poorly documented) python scripting bridge. I don't typically write in python, so apologies if I've mixed in some objective-c style conventions. If you have any ideas, comments, or feedback, I'm @ryanolsonk on twitter, and pull requests are welcome!

lldb-quicklook's People

Contributors

chaekit avatar gfontenot avatar ryanolsonk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.