[Lldb-commits] [lldb] r327587 - [DataFormatters] Implement summary for __NSDictionary0.
Davide Italiano via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 14 16:09:36 PDT 2018
Author: davide
Date: Wed Mar 14 16:09:36 2018
New Revision: 327587
URL: http://llvm.org/viewvc/llvm-project?rev=327587&view=rev
Log:
[DataFormatters] Implement summary for __NSDictionary0.
Before the patch:
(lldb) frame var emptyDictionary
(__NSDictionary0 *) emptyDictionary = 0x0000000100304420
After:
(lldb) frame var emptyDictionary
(__NSDictionary0 *) emptyDictionary = 0x0000000100304420 0 key/value pairs
There's nothing much else we can do, as this is always empty by
definition.
<rdar://problem/34806516>
Added:
lldb/trunk/lit/DataFormatters/
lldb/trunk/lit/DataFormatters/Inputs/
lldb/trunk/lit/DataFormatters/Inputs/NSDict.commands
lldb/trunk/lit/DataFormatters/Inputs/NSDict.m
lldb/trunk/lit/DataFormatters/TestEmptyDictionary.test
lldb/trunk/lit/DataFormatters/lit.local.cfg
Modified:
lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
Added: lldb/trunk/lit/DataFormatters/Inputs/NSDict.commands
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/DataFormatters/Inputs/NSDict.commands?rev=327587&view=auto
==============================================================================
--- lldb/trunk/lit/DataFormatters/Inputs/NSDict.commands (added)
+++ lldb/trunk/lit/DataFormatters/Inputs/NSDict.commands Wed Mar 14 16:09:36 2018
@@ -0,0 +1,3 @@
+breakpoint set --file NSDict.m --line 8
+run
+frame var
Added: lldb/trunk/lit/DataFormatters/Inputs/NSDict.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/DataFormatters/Inputs/NSDict.m?rev=327587&view=auto
==============================================================================
--- lldb/trunk/lit/DataFormatters/Inputs/NSDict.m (added)
+++ lldb/trunk/lit/DataFormatters/Inputs/NSDict.m Wed Mar 14 16:09:36 2018
@@ -0,0 +1,9 @@
+#include <Foundation/Foundation.h>
+
+int main(void)
+{
+ NSDictionary *emptyDictionary = [[NSDictionary alloc] init];
+ NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionary];
+ NSDictionary *dictionary = @{ @"key": @{} };
+ return 0;
+}
Added: lldb/trunk/lit/DataFormatters/TestEmptyDictionary.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/DataFormatters/TestEmptyDictionary.test?rev=327587&view=auto
==============================================================================
--- lldb/trunk/lit/DataFormatters/TestEmptyDictionary.test (added)
+++ lldb/trunk/lit/DataFormatters/TestEmptyDictionary.test Wed Mar 14 16:09:36 2018
@@ -0,0 +1,7 @@
+# Test that foundation NSDictionary0 is formatted correctly (the summary).
+# Foundation is only available on Darwin so just restrict the test to run there.
+# REQUIRES: darwin
+# RUN: %cc %p/Inputs/NSDict.m -framework Foundation -g -o %t && %lldb -b \
+# RUN: -s %p/Inputs/NSDict.commands -- %t 2>&1 | FileCheck %s
+
+# CHECK: (__NSDictionary0 *) emptyDictionary = {{.*}} 0 key/value pairs
Added: lldb/trunk/lit/DataFormatters/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/DataFormatters/lit.local.cfg?rev=327587&view=auto
==============================================================================
--- lldb/trunk/lit/DataFormatters/lit.local.cfg (added)
+++ lldb/trunk/lit/DataFormatters/lit.local.cfg Wed Mar 14 16:09:36 2018
@@ -0,0 +1 @@
+config.suffixes = ['.test']
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp?rev=327587&r1=327586&r2=327587&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp Wed Mar 14 16:09:36 2018
@@ -396,6 +396,7 @@ bool lldb_private::formatters::NSDiction
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
+ static const ConstString g_Dictionary0("__NSDictionary0");
if (class_name.IsEmpty())
return false;
@@ -423,6 +424,8 @@ bool lldb_private::formatters::NSDiction
return false;
} else if (class_name == g_Dictionary1) {
value = 1;
+ } else if (class_name == g_Dictionary0) {
+ value = 0;
}
else {
auto &map(NSDictionary_Additionals::GetAdditionalSummaries());
@@ -481,6 +484,7 @@ lldb_private::formatters::NSDictionarySy
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_DictionaryImmutable("__NSDictionaryM_Immutable");
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
+ static const ConstString g_Dictionary0("__NSDictionary0");
if (class_name.IsEmpty())
return nullptr;
More information about the lldb-commits
mailing list