[lldb/Dataformatter] Add support for CoreFoundation Dictionaries and Sets.
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 17 Apr 2020 19:43:41 +0000 (21:43 +0200)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Mon, 27 Apr 2020 20:10:11 +0000 (22:10 +0200)
commit8f5beb4c4b114f2cd827b10b5358f0d79d8bb691
tree3f37c1786f9e729e368fb0e9acc7947ac3dbe675
parentb4437992ecceb3a30429b4c4901e2eeecf8e683a
[lldb/Dataformatter] Add support for CoreFoundation Dictionaries and Sets.

This patch improves data formatting for CoreFoundation containers:
CFDictionary and CFSet.

These data formatters make the containers and their children appear in Xcode's
variables view (and on the command line) without having to expand the
data structure.

Previous implementation only supported showing the container's element count.

```
(lldb) frame var dict
(__NSCFDictionary *) dict = 0x00000001004062b0 2 key/value pairs

(lldb) frame var set
(__NSCFSet *) set = 0x0000000100406330 2 elements
```
Now the variable can be dereferenced to dispaly the container's children:

```
(lldb) frame var *dict
(__NSCFDictionary) *dict = {
  [0] = {
    key = 0x0000000100004050 @"123"
    value = 0x0000000100004090 @"456"
  }
  [1] = {
    key = 0x0000000100004030 @"abc"
    value = 0x0000000100004070 @"def"
  }
}

(lldb) frame var *set
(__NSCFSet) *set = {
  [0] = 0x0000000100004050 @"123"
  [1] = 0x0000000100004030 @"abc"
}
```

rdar://39882287

Differential Revision: https://reviews.llvm.org/D78396

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp [new file with mode: 0644]
lldb/source/Plugins/Language/ObjC/CFBasicHash.h [new file with mode: 0644]
lldb/source/Plugins/Language/ObjC/CMakeLists.txt
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.h
lldb/source/Plugins/Language/ObjC/NSSet.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m