Created
January 13, 2017 08:12
-
-
Save bricklife/1f6bff179cf5bda5b99638afc25b248a to your computer and use it in GitHub Desktop.
LLDB Plugin - json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import lldb | |
def process(debugger, command, result, internal_dict): | |
lldb.debugger.HandleCommand(""" | |
expr -l swift -- | |
func $process(object: AnyObject) { | |
func json(object: AnyObject) -> String { | |
if let data = try? NSJSONSerialization.dataWithJSONObject(object, options: .PrettyPrinted) { | |
return String(data: data, encoding: NSUTF8StringEncoding) ?? "" | |
} | |
else { | |
return String(object) | |
} | |
} | |
Swift.print(json(object)) | |
} | |
""".strip()) | |
lldb.debugger.HandleCommand('expr -l swift -- $process(' + command + ')') | |
def __lldb_init_module(debugger,internal_dict): | |
debugger.HandleCommand("command script add -f json.process json") | |
print "json command enabled." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment