Skip to content

Instantly share code, notes, and snippets.

@nolili
Forked from jparishy/.lldbinit
Last active September 17, 2015 04:38

Revisions

  1. @jparishy jparishy created this gist Sep 19, 2013.
    4 changes: 4 additions & 0 deletions .lldbinit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    ...
    command script import ~/.lldb/print_json.py

    # Then restart Xcode
    3 changes: 3 additions & 0 deletions Example
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    (lldb) pj @{ @"Hello" : @"World!" }
    $1 = 0x13278bf0 {"Hello":"World!"}
    (lldb)
    12 changes: 12 additions & 0 deletions print_json.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/usr/bin/env python
    # Goes in ~/.lldb/print_json.py

    import lldb
    import commands

    def print_json(debugger, command, result, internal_dict):
    lldb.debugger.HandleCommand("po [[NSString alloc] initWithData:(id)[NSJSONSerialization dataWithJSONObject:(" + command + ") options:0 error:nil] encoding:4]")

    def __lldb_init_module(debugger, internal_dict):
    debugger.HandleCommand("command script add -f print_json.print_json pjson")
    print "print_json installed."