LLDB Quick Print Object

A bit woozy how to use LLDB to validate an object in a swift project. In this particular case, I am using NSJSONSerializer to serialize a small JSON chunk and I would like to check the value. In Xcode 5.1 it was very easy, just type "po json" at the lldb command line and I will get what I want. Now the po and print commands prevent me from printing mostly garbage. I even tried calling the property description because it works with some swift types, but it still doesn't work. As a last resort, I used an expression with a println expression and finally it works. Should there be an easier way? Here is the LLDB output:

(lldb) print json
(AnyObject?) $R4 = (instance_type = Builtin.RawPointer = 0x00007ff05c0c49d0 ->     0x0000000107ef32c8 (void *)0x0000000107ef32f0: __NSCFDictionary)
(lldb) po json
(instance_type = Builtin.RawPointer = 0x00007ff05c0c49d0 -> 0x0000000107ef32c8 (void  *)0x0000000107ef32f0: __NSCFDictionary)
 {
  instance_type = 0x00007ff05c0c49d0 -> 0x0000000107ef32c8 (void *)0x0000000107ef32f0:  __NSCFDictionary
}
(lldb) print json.description?
error: <EXPR>:1:1: error: 'Optional<AnyObject>' does not have a member named 'description'
json.description?
^    ~~~~~~~~~~~

(lldb) po json.description?
error: <EXPR>:1:1: error: 'Optional<AnyObject>' does not have a member named    'description'
json.description?
^    ~~~~~~~~~~~
(lldb) expression
Enter expressions, then terminate with an empty line to evaluate:
1 println(json)
2 
Optional({
    errors =     {
        "authorizations.provider_user_id" =         (
            "has already been taken"
        );
    };
})
(lldb) 

      

+3


source to share


1 answer


you may try

(lldb) expr -O -d run - json!



The fact that "po" does not exactly work exactly the same as in ObjC is a known limitation. Explicitly expanding optional and resolving dynamic type to expanded value should work

0


source







All Articles