aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/data-formatter
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/data-formatter')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/.categories1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py72
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm29
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py58
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp26
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py285
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp174
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py329
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp46
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py265
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp121
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py80
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/main.cpp18
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py65
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py67
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp27
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py122
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp59
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py464
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m694
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py107
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m99
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py90
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m42
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py252
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py23
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py32
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp66
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py170
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp53
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile19
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py175
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py348
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp65
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py40
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp21
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py66
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp42
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py186
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py54
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp30
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp43
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py298
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp77
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py298
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp77
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py69
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py69
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py86
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py75
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp84
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py58
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp69
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py180
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp35
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py62
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py188
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/main.cpp34
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile14
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py322
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp55
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py66
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py58
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp63
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/Makefile15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py207
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/main.cpp31
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py205
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp86
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py96
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp29
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py36
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp35
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py75
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp25
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py82
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py60
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp20
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py67
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m35
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py69
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m30
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py74
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m34
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py52
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm23
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/Makefile7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py57
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp19
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py41
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/main.cpp21
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/Makefile4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m19
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp40
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py133
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp30
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py75
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py21
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp62
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py74
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m25
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/Makefile4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp14
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py59
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp20
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/Makefile11
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py74
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp41
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py56
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py73
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp17
181 files changed, 10556 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/.categories b/packages/Python/lldbsuite/test/functionalities/data-formatter/.categories
new file mode 100644
index 000000000000..fe1da0247c62
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/.categories
@@ -0,0 +1 @@
+dataformatters
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/Makefile
new file mode 100644
index 000000000000..261658b10ae8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJCXX_SOURCES := main.mm
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py
new file mode 100644
index 000000000000..94cdfdfeb343
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py
@@ -0,0 +1,72 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterBoolRefPtr(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_boolrefptr_with_run_command(self):
+ """Test the formatters we use for BOOL& and BOOL* in Objective-C."""
+ self.build()
+ self.boolrefptr_data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.mm', '// Set break point at this line.')
+
+ def boolrefptr_data_formatter_commands(self):
+ """Test the formatters we use for BOOL& and BOOL* in Objective-C."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we use the right summary for BOOL&
+ self.expect('frame variable yes_ref',
+ substrs = ['YES'])
+ self.expect('frame variable no_ref',
+ substrs = ['NO'])
+
+
+ # Now check that we use the right summary for BOOL*
+ self.expect('frame variable yes_ptr',
+ substrs = ['YES'])
+ self.expect('frame variable no_ptr',
+ substrs = ['NO'])
+
+
+ # Now check that we use the right summary for BOOL
+ self.expect('frame variable yes',
+ substrs = ['YES'])
+ self.expect('frame variable no',
+ substrs = ['NO'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm
new file mode 100644
index 000000000000..a2461fd9da91
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm
@@ -0,0 +1,29 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ BOOL yes = YES;
+ BOOL no = NO;
+
+ BOOL &yes_ref = yes;
+ BOOL &no_ref = no;
+
+ BOOL* yes_ptr = &yes;
+ BOOL* no_ptr = &no;
+
+ [pool drain];// Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/Makefile
new file mode 100644
index 000000000000..9b06ad7d705a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Accelerate \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py
new file mode 100644
index 000000000000..7cd2a49b4717
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py
@@ -0,0 +1,58 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class CompactVectorsFormattingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('frame variable',
+ substrs = ['(vFloat) valueFL = (1.25, 0, 0.25, 0)',
+ '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)',
+ '(int32_t [4]) valueI32 = (1, 0, 4, 0)',
+ '(vDouble) valueDL = (1.25, 2.25)',
+ '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)',
+ '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)',
+ '(vUInt32) valueU32 = (1, 2, 3, 4)',
+ "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)",
+ '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)',
+ '(vSInt32) valueS32 = (4, 3, 2, 1)',
+ '(vBool32) valueBool32 = (0, 1, 0, 1)'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp
new file mode 100644
index 000000000000..bbbd823ec313
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp
@@ -0,0 +1,26 @@
+ //===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <Accelerate/Accelerate.h>
+
+int main()
+{
+ vFloat valueFL = {1.25,0,0.25,0};
+ vDouble valueDL = {1.25,2.25};
+ int16_t valueI16[8] = {1,0,4,0,0,1,0,4};
+ int32_t valueI32[4] = {1,0,4,0};
+ vUInt8 valueU8 = {1,0,4,0,0,1,0,4};
+ vUInt16 valueU16 = {1,0,4,0,0,1,0,4};
+ vUInt32 valueU32 = {1,2,3,4};
+ vSInt8 valueS8 = {1,0,4,0,0,1,0,4};
+ vSInt16 valueS16 = {1,0,4,0,0,1,0,4};
+ vSInt32 valueS32 = {4,3,2,1};
+ vBool32 valueBool32 = {false,true,false,true};
+ return 0; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
new file mode 100644
index 000000000000..8166d1540ca3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -0,0 +1,285 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class AdvDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add --summary-string \"pippo\" \"i_am_cool\"")
+
+ self.runCmd("type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"")
+
+ self.expect("frame variable cool_boy",
+ substrs = ['pippo'])
+
+ self.expect("frame variable cooler_boy",
+ substrs = ['pluto'])
+
+ self.runCmd("type summary delete i_am_cool")
+
+ self.expect("frame variable cool_boy",
+ substrs = ['pluto'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]")
+
+ self.expect("frame variable int_array",
+ substrs = ['1,2,3,4,5'])
+
+ # this will fail if we don't do [] as regex correctly
+ self.runCmd('type summary add --summary-string "${var[].integer}" "i_am_cool[]')
+
+ self.expect("frame variable cool_array",
+ substrs = ['1,1,1,1,6'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"${var[1-0]%x}\" \"int\"")
+
+ self.expect("frame variable iAmInt",
+ substrs = ['01'])
+
+ self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" \"int\"")
+
+ self.expect("frame variable iAmInt",
+ substrs = ['01'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" int")
+ self.runCmd("type summary add --summary-string \"${var[0-31]%x}\" float")
+
+ self.expect("frame variable *pointer",
+ substrs = ['0x',
+ '2'])
+
+ # check fix for <rdar://problem/11338654> LLDB crashes when using a "type summary" that uses bitfields with no format
+ self.runCmd("type summary add --summary-string \"${var[0-1]}\" int")
+ self.expect("frame variable iAmInt",
+ substrs = ['9 1'])
+
+ self.expect("frame variable cool_array[3].floating",
+ substrs = ['0x'])
+
+ self.runCmd("type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"")
+
+ self.expect("frame variable pointer",
+ substrs = ['low bits are',
+ 'tgt is 6'])
+
+ self.expect("frame variable int_array --summary-string \"${*var[0-1]}\"",
+ substrs = ['3'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd('type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"')
+
+ self.expect("frame variable int_array",
+ substrs = ['1,2'])
+
+ self.runCmd('type summary add --summary-string \"${var[0-1]}\" "int []"')
+
+ self.expect("frame variable int_array",
+ substrs = ['1,2'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add -c -x \"i_am_cool \[[0-9]\]\"")
+ self.runCmd("type summary add -c i_am_cool")
+
+ self.expect("frame variable cool_array",
+ substrs = ['[0]',
+ '[1]',
+ '[2]',
+ '[3]',
+ '[4]',
+ 'integer',
+ 'character',
+ 'floating'])
+
+ self.runCmd("type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers")
+
+ self.expect("frame variable wrapper",
+ substrs = ['int = 4',
+ 'float = 1.1'])
+
+ self.runCmd("type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p")
+
+ self.expect("frame variable wrapper",
+ substrs = ['low bits = 1'])
+
+ self.expect("frame variable *wrap_pointer",
+ substrs = ['low bits = 1'])
+
+ self.runCmd("type summary clear")
+
+ self.expect("frame variable int_array --summary-string \"${var[0][0-2]%hex}\"",
+ substrs = ['0x',
+ '7'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"")
+
+ self.expect("frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"",
+ substrs = ['1 are low bits of integer 9.',
+ 'If I pretend it is an array I get [9,'])
+
+ # if the summary has an error, we still display the value
+ self.expect("frame variable couple --summary-string \"${*var.sp.foo[0-2]\"",
+ substrs = ['(Couple) couple = {','x = 0x','y = 0x','z = 0x','s = 0x'])
+
+
+ self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple")
+
+ self.expect("frame variable sparray",
+ substrs = ['[0x0000000f,0x0000000c,0x00000009]'])
+
+ # check that we can format a variable in a summary even if a format is defined for its datatype
+ self.runCmd("type format add -f hex int")
+ self.runCmd("type summary add --summary-string \"x=${var.x%d}\" Simple")
+
+ self.expect("frame variable a_simple_object",
+ substrs = ['x=3'])
+
+ self.expect("frame variable a_simple_object", matching=False,
+ substrs = ['0x0'])
+
+ # now check that the default is applied if we do not hand out a format
+ self.runCmd("type summary add --summary-string \"x=${var.x}\" Simple")
+
+ self.expect("frame variable a_simple_object", matching=False,
+ substrs = ['x=3'])
+
+ self.expect("frame variable a_simple_object", matching=True,
+ substrs = ['x=0x00000003'])
+
+ # check that we can correctly cap the number of children shown
+ self.runCmd("settings set target.max-children-count 5")
+
+ self.expect('frame variable a_long_guy', matching=True,
+ substrs = ['a_1',
+ 'b_1',
+ 'c_1',
+ 'd_1',
+ 'e_1',
+ '...'])
+
+ # check that no further stuff is printed (not ALL values are checked!)
+ self.expect('frame variable a_long_guy', matching=False,
+ substrs = ['f_1',
+ 'g_1',
+ 'h_1',
+ 'i_1',
+ 'j_1',
+ 'q_1',
+ 'a_2',
+ 'f_2',
+ 't_2',
+ 'w_2'])
+
+ self.runCmd("settings set target.max-children-count 1")
+ self.expect('frame variable a_long_guy', matching=True,
+ substrs = ['a_1',
+ '...'])
+ self.expect('frame variable a_long_guy', matching=False,
+ substrs = ['b_1',
+ 'c_1',
+ 'd_1',
+ 'e_1'])
+ self.expect('frame variable a_long_guy', matching=False,
+ substrs = ['f_1',
+ 'g_1',
+ 'h_1',
+ 'i_1',
+ 'j_1',
+ 'q_1',
+ 'a_2',
+ 'f_2',
+ 't_2',
+ 'w_2'])
+
+ self.runCmd("settings set target.max-children-count 30")
+ self.expect('frame variable a_long_guy', matching=True,
+ substrs = ['a_1',
+ 'b_1',
+ 'c_1',
+ 'd_1',
+ 'e_1',
+ 'z_1',
+ 'a_2',
+ 'b_2',
+ 'c_2',
+ 'd_2',
+ '...'])
+ self.expect('frame variable a_long_guy', matching=False,
+ substrs = ['e_2',
+ 'n_2',
+ 'r_2',
+ 'i_2',
+ 'k_2',
+ 'o_2'])
+
+ # override the cap
+ self.expect('frame variable a_long_guy --show-all-children', matching=True,
+ substrs = ['a_1',
+ 'b_1',
+ 'c_1',
+ 'd_1',
+ 'e_1',
+ 'z_1',
+ 'a_2',
+ 'b_2',
+ 'c_2',
+ 'd_2'])
+ self.expect('frame variable a_long_guy --show-all-children', matching=True,
+ substrs = ['e_2',
+ 'n_2',
+ 'r_2',
+ 'i_2',
+ 'k_2',
+ 'o_2'])
+ self.expect('frame variable a_long_guy --show-all-children', matching=False,
+ substrs = ['...'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp
new file mode 100644
index 000000000000..2462e28db127
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -0,0 +1,174 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct i_am_cool
+{
+ int integer;
+ float floating;
+ char character;
+ i_am_cool(int I, float F, char C) :
+ integer(I), floating(F), character(C) {}
+ i_am_cool() : integer(1), floating(2), character('3') {}
+
+};
+
+struct i_am_cooler
+{
+ i_am_cool first_cool;
+ i_am_cool second_cool;
+ float floating;
+
+ i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
+ first_cool(I1,F1,C1),
+ second_cool(I2,F2,C2),
+ floating((F1 + F2)/2) {}
+};
+
+struct IWrapPointers
+{
+ int* int_pointer;
+ float* float_pointer;
+ IWrapPointers() : int_pointer(new int(4)), float_pointer(new float(1.111)) {}
+};
+
+struct Simple
+{
+ int x;
+ float y;
+ char z;
+ Simple(int X, float Y, char Z) :
+ x(X),
+ y(Y),
+ z(Z)
+ {}
+};
+
+struct SimpleWithPointers
+{
+ int *x;
+ float *y;
+ char *z;
+ SimpleWithPointers(int X, float Y, char Z) :
+ x(new int (X)),
+ y(new float (Y)),
+ z(new char[2])
+ {
+ z[0] = Z;
+ z[1] = '\0';
+ }
+};
+
+struct Couple
+{
+ SimpleWithPointers sp;
+ Simple* s;
+ Couple(int X, float Y, char Z) : sp(X,Y,Z),
+ s(new Simple(X,Y,Z)) {}
+};
+
+struct VeryLong
+{
+ int a_1;
+ int b_1;
+ int c_1;
+ int d_1;
+ int e_1;
+ int f_1;
+ int g_1;
+ int h_1;
+ int i_1;
+ int j_1;
+ int k_1;
+ int l_1;
+ int m_1;
+ int n_1;
+ int o_1;
+ int p_1;
+ int q_1;
+ int r_1;
+ int s_1;
+ int t_1;
+ int u_1;
+ int v_1;
+ int w_1;
+ int x_1;
+ int y_1;
+ int z_1;
+
+ int a_2;
+ int b_2;
+ int c_2;
+ int d_2;
+ int e_2;
+ int f_2;
+ int g_2;
+ int h_2;
+ int i_2;
+ int j_2;
+ int k_2;
+ int l_2;
+ int m_2;
+ int n_2;
+ int o_2;
+ int p_2;
+ int q_2;
+ int r_2;
+ int s_2;
+ int t_2;
+ int u_2;
+ int v_2;
+ int w_2;
+ int x_2;
+ int y_2;
+ int z_2;
+};
+
+int main (int argc, const char * argv[])
+{
+
+ int iAmInt = 9;
+
+ i_am_cool cool_boy(1,0.5,3);
+ i_am_cooler cooler_boy(1,2,0.1,0.2,'A','B');
+
+ i_am_cool *cool_pointer = new i_am_cool(3,-3.141592,'E');
+
+ i_am_cool cool_array[5];
+
+ cool_array[3].floating = 5.25;
+ cool_array[4].integer = 6;
+ cool_array[2].character = 'Q';
+
+ int int_array[] = {1,2,3,4,5};
+
+ IWrapPointers wrapper;
+
+ *int_array = -1;
+
+ int* pointer = &cool_array[4].integer;
+
+ IWrapPointers *wrap_pointer = &wrapper;
+
+ Couple couple(9,9.99,'X');
+
+ SimpleWithPointers sparray[] =
+ {SimpleWithPointers(-1,-2,'3'),
+ SimpleWithPointers(-4,-5,'6'),
+ SimpleWithPointers(-7,-8,'9')};
+
+ Simple a_simple_object(3,0.14,'E');
+
+ VeryLong a_long_guy;
+
+ return 0; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
new file mode 100644
index 000000000000..db426cac6e59
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
@@ -0,0 +1,329 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class CategoriesDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case (most of these categories do not
+ # exist anymore, but we just make sure we delete all of them)
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type category delete Category1', check=False)
+ self.runCmd('type category delete Category2', check=False)
+ self.runCmd('type category delete NewCategory', check=False)
+ self.runCmd("type category delete CircleCategory", check=False)
+ self.runCmd("type category delete RectangleStarCategory", check=False)
+ self.runCmd("type category delete BaseCategory", check=False)
+
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Add a summary to a new category and check that it works
+ self.runCmd("type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory")
+
+ self.expect("frame variable r1 r2 r3", matching=False,
+ substrs = ['r1 = ARectangle',
+ 'r2 = ARectangle',
+ 'r3 = ARectangle'])
+
+ self.runCmd("type category enable NewCategory")
+
+ self.expect("frame variable r1 r2 r3", matching=True,
+ substrs = ['r1 = ARectangle',
+ 'r2 = ARectangle',
+ 'r3 = ARectangle'])
+
+ # Disable the category and check that the old stuff is there
+ self.runCmd("type category disable NewCategory")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = {',
+ 'r2 = {',
+ 'r3 = {'])
+
+ # Re-enable the category and check that it works
+ self.runCmd("type category enable NewCategory")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = ARectangle',
+ 'r2 = ARectangle',
+ 'r3 = ARectangle'])
+
+ # Delete the category and the old stuff should be there
+ self.runCmd("type category delete NewCategory")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = {',
+ 'r2 = {',
+ 'r3 = {'])
+
+ # Add summaries to two different categories and check that we can switch
+ self.runCmd("type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1")
+ self.runCmd("type summary add --python-script \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2")
+
+ # check that enable A B is the same as enable B enable A
+ self.runCmd("type category enable Category1 Category2")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ self.runCmd("type category disable Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Area = ',
+ 'r2 = Area = ',
+ 'r3 = Area = '])
+
+ # switch again
+
+ self.runCmd("type category enable Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ # Re-enable the category and show that the preference is persisted
+ self.runCmd("type category disable Category2")
+ self.runCmd("type category enable Category2")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Area = ',
+ 'r2 = Area = ',
+ 'r3 = Area = '])
+
+ # Now delete the favorite summary
+ self.runCmd("type summary delete Rectangle -w Category2")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ # Delete the summary from the default category (that does not have it)
+ self.runCmd("type summary delete Rectangle", check=False)
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ # Now add another summary to another category and switch back and forth
+ self.runCmd("type category delete Category1 Category2")
+
+ self.runCmd("type summary add Rectangle -w Category1 --summary-string \"Category1\"")
+ self.runCmd("type summary add Rectangle -w Category2 --summary-string \"Category2\"")
+
+ self.runCmd("type category enable Category2")
+ self.runCmd("type category enable Category1")
+
+ self.runCmd("type summary list -w Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Category1',
+ 'r2 = Category1',
+ 'r3 = Category1'])
+
+ self.runCmd("type category disable Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Category2',
+ 'r2 = Category2',
+ 'r3 = Category2'])
+
+ # Check that re-enabling an enabled category works
+ self.runCmd("type category enable Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Category1',
+ 'r2 = Category1',
+ 'r3 = Category1'])
+
+ self.runCmd("type category delete Category1")
+ self.runCmd("type category delete Category2")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = {',
+ 'r2 = {',
+ 'r3 = {'])
+
+ # Check that multiple summaries can go into one category
+ self.runCmd("type summary add -w Category1 --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle")
+ self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" Circle")
+
+ self.runCmd("type category enable Category1")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = Radius = ',
+ 'c2 = Radius = ',
+ 'c3 = Radius = '])
+
+ self.runCmd("type summary delete Circle -w Category1")
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = {',
+ 'c2 = {',
+ 'c3 = {'])
+
+ # Add a regex based summary to a category
+ self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" -x Circle")
+
+ self.expect("frame variable r1 r2 r3",
+ substrs = ['r1 = Width = ',
+ 'r2 = Width = ',
+ 'r3 = Width = '])
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = Radius = ',
+ 'c2 = Radius = ',
+ 'c3 = Radius = '])
+
+ # Delete it
+ self.runCmd("type summary delete Circle -w Category1")
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = {',
+ 'c2 = {',
+ 'c3 = {'])
+
+ # Change a summary inside a category and check that the change is reflected
+ self.runCmd("type summary add Circle -w Category1 --summary-string \"summary1\"")
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = summary1',
+ 'c2 = summary1',
+ 'c3 = summary1'])
+
+ self.runCmd("type summary add Circle -w Category1 --summary-string \"summary2\"")
+
+ self.expect("frame variable c1 c2 c3",
+ substrs = ['c1 = summary2',
+ 'c2 = summary2',
+ 'c3 = summary2'])
+
+ # Check that our order of priority works. Start by clearing categories
+ self.runCmd("type category delete Category1")
+
+ self.runCmd("type summary add Shape -w BaseCategory --summary-string \"AShape\"")
+ self.runCmd("type category enable BaseCategory")
+
+ self.expect("print (Shape*)&c1",
+ substrs = ['AShape'])
+ self.expect("print (Shape*)&r1",
+ substrs = ['AShape'])
+ self.expect("print (Shape*)c_ptr",
+ substrs = ['AShape'])
+ self.expect("print (Shape*)r_ptr",
+ substrs = ['AShape'])
+
+ self.runCmd("type summary add Circle -w CircleCategory --summary-string \"ACircle\"")
+ self.runCmd("type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"")
+ self.runCmd("type category enable CircleCategory")
+
+ self.expect("frame variable c1",
+ substrs = ['ACircle'])
+ self.expect("frame variable c_ptr",
+ substrs = ['ACircle'])
+
+ self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"")
+ self.runCmd("type category enable RectangleStarCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'ARectangleStar'])
+
+ self.runCmd("type category enable RectangleCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ 'ACircle',
+ 'ARectangle'])
+
+ # Check that abruptly deleting an enabled category does not crash us
+ self.runCmd("type category delete RectangleCategory")
+
+ self.expect("frame variable c1 r1 c_ptr r_ptr",
+ substrs = ['ACircle',
+ '(Rectangle) r1 = ', 'w = 5', 'h = 6',
+ 'ACircle',
+ 'ARectangleStar'])
+
+ # check that list commands work
+ self.expect("type category list",
+ substrs = ['RectangleStarCategory (enabled)'])
+
+ self.expect("type summary list",
+ substrs = ['ARectangleStar'])
+
+ # Disable a category and check that it fallsback
+ self.runCmd("type category disable CircleCategory")
+
+ # check that list commands work
+ self.expect("type category list",
+ substrs = ['CircleCategory (disabled'])
+
+ self.expect("frame variable c1 r_ptr",
+ substrs = ['AShape',
+ 'ARectangleStar'])
+
+ # check that filters work into categories
+ self.runCmd("type filter add Rectangle --child w --category RectangleCategory")
+ self.runCmd("type category enable RectangleCategory")
+ self.runCmd("type summary add Rectangle --category RectangleCategory --summary-string \" \" -e")
+ self.expect('frame variable r2',
+ substrs = ['w = 9'])
+ self.runCmd("type summary add Rectangle --summary-string \" \" -e")
+ self.expect('frame variable r2', matching=False,
+ substrs = ['h = 16'])
+
+ # Now delete all categories
+ self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory")
+
+ # check that a deleted category with filter does not blow us up
+ self.expect('frame variable r2',
+ substrs = ['w = 9',
+ 'h = 16'])
+
+ # and also validate that one can print formatters for a language
+ self.expect('type summary list -l c++', substrs=['vector', 'map', 'list', 'string'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp
new file mode 100644
index 000000000000..b51dd45a7f60
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp
@@ -0,0 +1,46 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct Shape
+{
+ bool dummy;
+ Shape() : dummy(true) {}
+};
+
+struct Rectangle : public Shape {
+ int w;
+ int h;
+ Rectangle(int W = 3, int H = 5) : w(W), h(H) {}
+};
+
+struct Circle : public Shape {
+ int r;
+ Circle(int R = 6) : r(R) {}
+};
+
+int main (int argc, const char * argv[])
+{
+ Rectangle r1(5,6);
+ Rectangle r2(9,16);
+ Rectangle r3(4,4);
+
+ Circle c1(5);
+ Circle c2(6);
+ Circle c3(7);
+
+ Circle *c_ptr = new Circle(8);
+ Rectangle *r_ptr = new Rectangle(9,7);
+
+ return 0; // Set break point at this line.
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
new file mode 100644
index 000000000000..2ca737156a1a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -0,0 +1,265 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class CppDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable",
+ substrs = ['(Speed) SPILookHex = 5.55' # Speed by default is 5.55.
+ ]);
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type format add -C yes -f x Speed BitField")
+ self.runCmd("type format add -C no -f c RealNumber")
+ self.runCmd("type format add -C no -f x Type2")
+ self.runCmd("type format add -C yes -f c Type1")
+
+ # The type format list should show our custom formats.
+ self.expect("type format list",
+ substrs = ['RealNumber',
+ 'Speed',
+ 'BitField',
+ 'Type1',
+ 'Type2'])
+
+ self.expect("frame variable",
+ patterns = ['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now.
+ ]);
+
+ # gcc4.2 on Mac OS X skips typedef chains in the DWARF output
+ if self.getCompiler() in ['clang', 'llvm-gcc']:
+ self.expect("frame variable",
+ patterns = ['\(SignalMask\) SMILookHex = 0x[0-9a-f]+' # SignalMask should look hex-ish now.
+ ]);
+ self.expect("frame variable", matching=False,
+ patterns = ['\(Type4\) T4ILookChar = 0x[0-9a-f]+' # Type4 should NOT look hex-ish now.
+ ]);
+
+ # Now let's delete the 'Speed' custom format.
+ self.runCmd("type format delete Speed")
+
+ # The type format list should not show 'Speed' at this point.
+ self.expect("type format list", matching=False,
+ substrs = ['Speed'])
+
+ # Delete type format for 'Speed', we should expect an error message.
+ self.expect("type format delete Speed", error=True,
+ substrs = ['no custom formatter for Speed'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = "Hello world!"'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = "Hello world!"'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = "Hello world!'])
+
+ # check that rdar://problem/10011145 (Standard summary format for char[] doesn't work as the result of "expr".) is solved
+ self.expect("p strarr",
+ substrs = ['arr = "Hello world!'])
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = "Hello world!"'])
+
+ self.expect("p strptr",
+ substrs = ['ptr = "Hello world!"'])
+
+ self.expect("p (char*)\"1234567890123456789012345678901234567890123456789012345678901234ABC\"",
+ substrs = ['(char *) $', ' = ptr = ', ' "1234567890123456789012345678901234567890123456789012345678901234ABC"'])
+
+ self.runCmd("type summary add -c Point")
+
+ self.expect("frame variable iAmSomewhere",
+ substrs = ['x = 4',
+ 'y = 6'])
+
+ self.expect("type summary list",
+ substrs = ['Point',
+ 'one-line'])
+
+ self.runCmd("type summary add --summary-string \"y=${var.y%x}\" Point")
+
+ self.expect("frame variable iAmSomewhere",
+ substrs = ['y=0x'])
+
+ self.runCmd("type summary add --summary-string \"y=${var.y},x=${var.x}\" Point")
+
+ self.expect("frame variable iAmSomewhere",
+ substrs = ['y=6',
+ 'x=4'])
+
+ self.runCmd("type summary add --summary-string \"hello\" Point -e")
+
+ self.expect("type summary list",
+ substrs = ['Point',
+ 'show children'])
+
+ self.expect("frame variable iAmSomewhere",
+ substrs = ['hello',
+ 'x = 4',
+ '}'])
+
+ self.runCmd("type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts")
+
+ self.expect("frame variable cool_pointer->floating",
+ substrs = ['Sign: true',
+ 'Exponent: 0x',
+ '80'])
+
+ self.runCmd("type summary add --summary-string \"a test\" i_am_cool")
+
+ self.expect("frame variable cool_pointer",
+ substrs = ['a test'])
+
+ self.runCmd("type summary add --summary-string \"a test\" i_am_cool --skip-pointers")
+
+ self.expect("frame variable cool_pointer",
+ substrs = ['a test'],
+ matching = False)
+
+ self.runCmd("type summary add --summary-string \"${var[1-3]}\" \"int [5]\"")
+
+ self.expect("frame variable int_array",
+ substrs = ['2',
+ '3',
+ '4'])
+
+ self.runCmd("type summary clear")
+
+ self.runCmd("type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"")
+ self.runCmd("type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"")
+
+ self.expect("frame variable cool_array",
+ substrs = ['1,1,6'])
+
+ self.expect("frame variable cool_pointer",
+ substrs = ['3,0,0'])
+
+ # test special symbols for formatting variables into summaries
+ self.runCmd("type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool")
+ self.runCmd("type summary delete \"i_am_cool [5]\"")
+
+ # this test might fail if the compiler tries to store
+ # these values into registers.. hopefully this is not
+ # going to be the case
+ self.expect("frame variable cool_array",
+ substrs = ['[0] = cool object @ 0x',
+ '[1] = cool object @ 0x',
+ '[2] = cool object @ 0x',
+ '[3] = cool object @ 0x',
+ '[4] = cool object @ 0x'])
+
+ # test getting similar output by exploiting ${var} = 'type @ location' for aggregates
+ self.runCmd("type summary add --summary-string \"${var}\" i_am_cool")
+
+ # this test might fail if the compiler tries to store
+ # these values into registers.. hopefully this is not
+ # going to be the case
+ self.expect("frame variable cool_array",
+ substrs = ['[0] = i_am_cool @ 0x',
+ '[1] = i_am_cool @ 0x',
+ '[2] = i_am_cool @ 0x',
+ '[3] = i_am_cool @ 0x',
+ '[4] = i_am_cool @ 0x'])
+
+
+ # test getting same output by exploiting %T and %L together for aggregates
+ self.runCmd("type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool")
+
+ # this test might fail if the compiler tries to store
+ # these values into registers.. hopefully this is not
+ # going to be the case
+ self.expect("frame variable cool_array",
+ substrs = ['[0] = i_am_cool @ 0x',
+ '[1] = i_am_cool @ 0x',
+ '[2] = i_am_cool @ 0x',
+ '[3] = i_am_cool @ 0x',
+ '[4] = i_am_cool @ 0x'])
+
+ self.runCmd("type summary add --summary-string \"goofy\" i_am_cool")
+ self.runCmd("type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler")
+
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ # check that unwanted type specifiers are removed
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add --summary-string \"goofy\" \"class i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add --summary-string \"goofy\" \"enum i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add --summary-string \"goofy\" \"struct i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ # many spaces, but we still do the right thing
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add --summary-string \"goofy\" \"union i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ # but that not *every* specifier is removed
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add --summary-string \"goofy\" \"wrong i_am_cool\"")
+ self.expect("frame variable the_coolest_guy", matching=False,
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ # check that formats are not sticking since that is the behavior we want
+ self.expect("frame variable iAmInt --format hex", substrs = ['(int) iAmInt = 0x00000001'])
+ self.expect("frame variable iAmInt", matching=False, substrs = ['(int) iAmInt = 0x00000001'])
+ self.expect("frame variable iAmInt", substrs = ['(int) iAmInt = 1'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp
new file mode 100644
index 000000000000..5bcfbfd4d46e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp
@@ -0,0 +1,121 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+typedef float RealNumber; // should show as char
+typedef RealNumber Temperature; // should show as float
+typedef RealNumber Speed; // should show as hex
+
+typedef int Counter; // should show as int
+typedef int BitField; // should show as hex
+
+typedef BitField SignalMask; // should show as hex
+typedef BitField Modifiers; // should show as hex
+
+typedef Counter Accumulator; // should show as int
+
+typedef int Type1; // should show as char
+typedef Type1 Type2; // should show as hex
+typedef Type2 Type3; // should show as char
+typedef Type3 Type4; // should show as char
+
+typedef int ChildType; // should show as int
+typedef int AnotherChildType; // should show as int
+
+struct Point {
+ int x;
+ int y;
+ Point(int X = 3, int Y = 2) : x(X), y(Y) {}
+};
+
+typedef float ShowMyGuts;
+
+struct i_am_cool
+{
+ int integer;
+ ShowMyGuts floating;
+ char character;
+ i_am_cool(int I, ShowMyGuts F, char C) :
+ integer(I), floating(F), character(C) {}
+ i_am_cool() : integer(1), floating(2), character('3') {}
+
+};
+
+struct i_am_cooler
+{
+ i_am_cool first_cool;
+ i_am_cool second_cool;
+ ShowMyGuts floating;
+
+ i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
+ first_cool(I1,F1,C1),
+ second_cool(I2,F2,C2),
+ floating((F1 + F2)/2) {}
+};
+
+struct IUseCharStar
+{
+ const char* pointer;
+ IUseCharStar() : pointer("Hello world") {}
+};
+
+int main (int argc, const char * argv[])
+{
+
+ int iAmInt = 1;
+ const float& IAmFloat = float(2.45);
+
+ RealNumber RNILookChar = 3.14;
+ Temperature TMILookFloat = 4.97;
+ Speed SPILookHex = 5.55;
+
+ Counter CTILookInt = 6;
+ BitField BFILookHex = 7;
+ SignalMask SMILookHex = 8;
+ Modifiers MFILookHex = 9;
+
+ Accumulator* ACILookInt = new Accumulator(10);
+
+ const Type1& T1ILookChar = 11;
+ Type2 T2ILookHex = 12;
+ Type3 T3ILookChar = 13;
+ Type4 T4ILookChar = 14;
+
+ AnotherChildType AHILookInt = 15;
+
+ Speed* SPPtrILookHex = new Speed(16);
+
+ Point iAmSomewhere(4,6);
+
+ i_am_cool *cool_pointer = (i_am_cool*)malloc(sizeof(i_am_cool)*3);
+ cool_pointer[0] = i_am_cool(3,-3.141592,'E');
+ cool_pointer[1] = i_am_cool(0,-3.141592,'E');
+ cool_pointer[2] = i_am_cool(0,-3.141592,'E');
+
+ i_am_cool cool_array[5];
+
+ cool_array[3].floating = 5.25;
+ cool_array[4].integer = 6;
+ cool_array[2].character = 'Q';
+
+ int int_array[] = {1,2,3,4,5};
+
+ IUseCharStar iEncapsulateCharStar;
+
+ char strarr[32] = "Hello world!";
+ char* strptr = "Hello world!";
+
+ i_am_cooler the_coolest_guy(1,2,3.14,6.28,'E','G');
+
+ return 0; // Set break point at this line.
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
new file mode 100644
index 000000000000..0f254a67d5a6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py
@@ -0,0 +1,80 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterDisablingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Check that we can properly disable all data formatter categories."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type category enable *', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ #self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False)
+
+ self.expect('type category list', substrs = ['system','enabled',])
+
+ self.expect("frame variable numbers",
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', substrs = ['hello world'])
+
+ # now disable them all and check that nothing is formatted
+ self.runCmd('type category disable *')
+
+ self.expect("frame variable numbers", matching=False,
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', matching=False, substrs = ['hello world'])
+
+ self.expect('type category list', substrs = ['system','disabled',])
+
+ # now enable and check that we are back to normal
+ self.runCmd("type category enable *")
+
+ self.expect('type category list', substrs = ['system','enabled'])
+
+ self.expect("frame variable numbers",
+ substrs = ['[0] = 1', '[3] = 1234'])
+
+ self.expect('frame variable string1', substrs = ['hello world'])
+
+ self.expect('type category list', substrs = ['system','enabled'])
+
+ # last check - our cleanup will re-enable everything
+ self.runCmd('type category disable *')
+ self.expect('type category list', substrs = ['system','disabled'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
new file mode 100644
index 000000000000..9374642fb0d2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/main.cpp
@@ -0,0 +1,18 @@
+#include <vector>
+
+int main()
+{
+
+ const char* string1 = "hello world";
+
+ std::vector<int> numbers;
+ numbers.push_back(1);
+ numbers.push_back(12);
+ numbers.push_back(123);
+ numbers.push_back(1234);
+ numbers.push_back(12345);
+ numbers.push_back(123456);
+ numbers.push_back(1234567); // Set break point at this line.
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py
new file mode 100644
index 000000000000..1659ade74a06
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py
@@ -0,0 +1,65 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class EnumFormatTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable",
+ substrs = ['(Foo) f = Case45',
+ '(int) x = 1',
+ '(int) y = 45',
+ '(int) z = 43'
+ ]);
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type format add --type Foo int")
+
+ # The type format list should show our custom formats.
+ self.expect("type format list -w default",
+ substrs = ['int: as type Foo'])
+
+ self.expect("frame variable",
+ substrs = ['(Foo) f = Case45',
+ '(int) x = Case1',
+ '(int) y = Case45',
+ '(int) z = 43'
+ ]);
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/main.cpp
new file mode 100644
index 000000000000..6a8074ff9fbe
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/main.cpp
@@ -0,0 +1,13 @@
+enum Foo {
+ Case1 = 1,
+ Case2 = 2,
+ Case45 = 45
+};
+
+int main() {
+ Foo f = Case45;
+ int x = 1;
+ int y = 45;
+ int z = 43;
+ return 1; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
new file mode 100644
index 000000000000..df3bef091c89
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
@@ -0,0 +1,67 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class GlobalsDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add --summary-string \"JustATest\" Point")
+
+ # Simply check we can get at global variables
+ self.expect("target variable g_point",
+ substrs = ['JustATest'])
+
+ self.expect("target variable g_point_pointer",
+ substrs = ['(Point *) g_point_pointer ='])
+
+ # Print some information about the variables
+ # (we ignore the actual values)
+ self.runCmd("type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point")
+
+ self.expect("target variable g_point",
+ substrs = ['x=',
+ 'y='])
+
+ self.expect("target variable g_point_pointer",
+ substrs = ['(Point *) g_point_pointer ='])
+
+ # Test Python code on resulting SBValue
+ self.runCmd("type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point")
+
+ self.expect("target variable g_point",
+ substrs = ['x='])
+
+ self.expect("target variable g_point_pointer",
+ substrs = ['(Point *) g_point_pointer ='])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp
new file mode 100644
index 000000000000..521f7a6931e9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp
@@ -0,0 +1,27 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct Point {
+ int x;
+ int y;
+ Point(int X = 3, int Y = 2) : x(X), y(Y) {}
+};
+
+Point g_point(3,4);
+Point* g_point_pointer = new Point(7,5);
+
+int main (int argc, const char * argv[])
+{
+ return 0; // Set break point at this line.
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py
new file mode 100644
index 000000000000..94df520d29b3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py
@@ -0,0 +1,122 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class NamedSummariesDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt")
+ self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First")
+ self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second")
+ self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third")
+
+ self.expect("frame variable first",
+ substrs = ['First: x=12'])
+
+ self.expect("frame variable first --summary AllUseIt",
+ substrs = ['AllUseIt: x=12'])
+
+ # We *DO NOT* remember the summary choice anymore
+ self.expect("frame variable first", matching=False,
+ substrs = ['AllUseIt: x=12'])
+ self.expect("frame variable first",
+ substrs = ['First: x=12'])
+
+ self.runCmd("thread step-over") # 2
+
+ self.expect("frame variable first",
+ substrs = ['First: x=12'])
+
+ self.expect("frame variable first --summary AllUseIt",
+ substrs = ['AllUseIt: x=12',
+ 'y=34'])
+
+ self.expect("frame variable second --summary AllUseIt",
+ substrs = ['AllUseIt: x=65',
+ 'y=43.25'])
+
+ self.expect("frame variable third --summary AllUseIt",
+ substrs = ['AllUseIt: x=96',
+ 'z=',
+ 'E'])
+
+ self.runCmd("thread step-over") # 3
+
+ self.expect("frame variable second",
+ substrs = ['Second: x=65',
+ 'y=0x'])
+
+ # <rdar://problem/11576143> decided that invalid summaries will raise an error
+ # instead of just defaulting to the base summary
+ self.expect("frame variable second --summary NoSuchSummary",error=True,
+ substrs = ['must specify a valid named summary'])
+
+ self.runCmd("thread step-over")
+
+ self.runCmd("type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends")
+
+ self.expect("frame variable first",
+ substrs = ['FirstAndFriends: x=12',
+ 'y=34'])
+
+ self.runCmd("type summary delete First")
+
+ self.expect("frame variable first --summary FirstAndFriends",
+ substrs = ['FirstAndFriends: x=12',
+ 'y=34'])
+
+ self.expect("frame variable first", matching=True,
+ substrs = ['x = 12',
+ 'y = 34'])
+
+ self.runCmd("type summary delete FirstAndFriends")
+ self.expect("type summary delete NoSuchSummary", error=True)
+ self.runCmd("type summary delete AllUseIt")
+
+ self.expect("frame variable first", matching=False,
+ substrs = ['FirstAndFriends'])
+
+ self.runCmd("thread step-over") # 4
+
+ self.expect("frame variable first",matching=False,
+ substrs = ['FirstAndFriends: x=12',
+ 'y=34'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp
new file mode 100644
index 000000000000..fdec5fecd3a2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp
@@ -0,0 +1,59 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct First
+{
+ int x;
+ int y;
+ float dummy;
+ First(int X, int Y) :
+ x(X),
+ y(Y),
+ dummy(3.14)
+ {}
+};
+
+struct Second
+{
+ int x;
+ float y;
+ Second(int X, float Y) :
+ x(X),
+ y(Y)
+ {}
+};
+
+struct Third
+{
+ int x;
+ char z;
+ Third(int X, char Z) :
+ x(X),
+ z(Z)
+ {}
+};
+
+int main (int argc, const char * argv[])
+{
+ First first(12,34);
+ Second second(65,43.25);
+ Third *third = new Third(96,'E');
+
+ first.dummy = 1; // Set break point at this line.
+ first.dummy = 2;
+ first.dummy = 3;
+ first.dummy = 4;
+ first.dummy = 5;
+
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories
new file mode 100644
index 000000000000..6326dbcec91b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/.categories
@@ -0,0 +1 @@
+dataformatters,objc
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile
new file mode 100644
index 000000000000..9f7fb1ca6231
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
new file mode 100644
index 000000000000..e12ddca2eea7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
@@ -0,0 +1,464 @@
+# encoding: utf-8
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class ObjCDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_plain_objc_with_run_command(self):
+ """Test basic ObjC formatting behavior."""
+ self.build()
+ self.plain_data_formatter_commands()
+
+ def appkit_tester_impl(self,commands):
+ self.build()
+ self.appkit_common_data_formatters_command()
+ commands()
+
+ @skipUnlessDarwin
+ def test_nsnumber_with_run_command(self):
+ """Test formatters for NSNumber."""
+ self.appkit_tester_impl(self.nsnumber_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_nscontainers_with_run_command(self):
+ """Test formatters for NS container classes."""
+ self.appkit_tester_impl(self.nscontainers_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_nsdata_with_run_command(self):
+ """Test formatters for NSData."""
+ self.appkit_tester_impl(self.nsdata_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_nsurl_with_run_command(self):
+ """Test formatters for NSURL."""
+ self.appkit_tester_impl(self.nsurl_data_formatter_commands)
+
+
+ @skipUnlessDarwin
+ def test_nserror_with_run_command(self):
+ """Test formatters for NSError."""
+ self.appkit_tester_impl(self.nserror_data_formatter_commands)
+
+
+ @skipUnlessDarwin
+ def test_nsbundle_with_run_command(self):
+ """Test formatters for NSBundle."""
+ self.appkit_tester_impl(self.nsbundle_data_formatter_commands)
+
+
+ @skipUnlessDarwin
+ def test_nsexception_with_run_command(self):
+ """Test formatters for NSException."""
+ self.appkit_tester_impl(self.nsexception_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_nsmisc_with_run_command(self):
+ """Test formatters for misc NS classes."""
+ self.appkit_tester_impl(self.nsmisc_data_formatter_commands)
+
+
+ @skipUnlessDarwin
+ def test_nsdate_with_run_command(self):
+ """Test formatters for NSDate."""
+ self.appkit_tester_impl(self.nsdate_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_coreframeworks_and_run_command(self):
+ """Test formatters for Core OSX frameworks."""
+ self.build()
+ self.cf_data_formatter_commands()
+
+ @skipUnlessDarwin
+ def test_kvo_with_run_command(self):
+ """Test the behavior of formatters when KVO is in use."""
+ self.build()
+ self.kvo_data_formatter_commands()
+
+ @skipUnlessDarwin
+ def test_expr_with_run_command(self):
+ """Test common cases of expression parser <--> formatters interaction."""
+ self.build()
+ self.expr_objc_data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ def plain_data_formatter_commands(self):
+ """Test basic ObjC formatting behavior."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add --summary-string \"${var%@}\" MyClass")
+
+ self.expect("frame variable object2",
+ substrs = ['MyOtherClass']);
+
+ self.expect("frame variable *object2",
+ substrs = ['MyOtherClass']);
+
+ # Now let's delete the 'MyClass' custom summary.
+ self.runCmd("type summary delete MyClass")
+
+ # The type format list should not show 'MyClass' at this point.
+ self.expect("type summary list", matching=False,
+ substrs = ['MyClass'])
+
+ self.runCmd("type summary add --summary-string \"a test\" MyClass")
+
+ self.expect("frame variable *object2",
+ substrs = ['*object2 =',
+ 'MyClass = a test',
+ 'backup = ']);
+
+ self.expect("frame variable object2", matching=False,
+ substrs = ['a test']);
+
+ self.expect("frame variable object",
+ substrs = ['a test']);
+
+ self.expect("frame variable *object",
+ substrs = ['a test']);
+
+ self.expect('frame variable myclass',
+ substrs = ['(Class) myclass = NSValue'])
+ self.expect('frame variable myclass2',
+ substrs = ['(Class) myclass2 = ','NS','String'])
+ self.expect('frame variable myclass3',
+ substrs = ['(Class) myclass3 = Molecule'])
+ self.expect('frame variable myclass4',
+ substrs = ['(Class) myclass4 = NSMutableArray'])
+ self.expect('frame variable myclass5',
+ substrs = ['(Class) myclass5 = nil'])
+
+ def appkit_common_data_formatters_command(self):
+ """Test formatters for AppKit classes."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ def nsnumber_data_formatter_commands(self):
+ # Now enable AppKit and check we are displaying Cocoa classes correctly
+ self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num8_Y num8_N num9',
+ substrs = ['(NSNumber *) num1 = ',' (int)5',
+ '(NSNumber *) num2 = ',' (float)3.1',
+ '(NSNumber *) num3 = ',' (double)3.14',
+ '(NSNumber *) num4 = ',' (long)-2',
+ '(NSNumber *) num5 = ',' (char)65',
+ '(NSNumber *) num6 = ',' (long)255',
+ '(NSNumber *) num7 = ','2000000',
+ '(NSNumber *) num8_Y = ',' @"1"',
+ '(NSNumber *) num8_N = ',' @"0"',
+ '(NSNumber *) num9 = ',' (short)-31616'])
+
+ self.expect('frame variable decimal_one',
+ substrs = ['(NSDecimalNumber *) decimal_one = 0x','1'])
+
+ self.expect('frame variable num_at1 num_at2 num_at3 num_at4',
+ substrs = ['(NSNumber *) num_at1 = ',' (int)12',
+ '(NSNumber *) num_at2 = ',' (int)-12',
+ '(NSNumber *) num_at3 = ',' (double)12.5',
+ '(NSNumber *) num_at4 = ',' (double)-12.5'])
+
+ def nscontainers_data_formatter_commands(self):
+ self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref',
+ substrs = ['(NSArray *) newArray = ','@"50 elements"',
+ '(NSDictionary *) newDictionary = ',' 12 key/value pairs',
+ '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs',
+ '(CFDictionaryRef) cfdict_ref = ','3 key/value pairs',
+ '(CFMutableDictionaryRef) mutable_dict_ref = ','12 key/value pairs',
+ '(CFArrayRef) cfarray_ref = ','@"3 elements"',
+ '(CFMutableArrayRef) mutable_array_ref = ','@"11 elements"'])
+
+ self.expect('frame variable nscounted_set',
+ substrs = ['(NSCountedSet *) nscounted_set = ','5 elements'])
+
+ self.expect('frame variable iset1 iset2 imset',
+ substrs = ['4 indexes','512 indexes','10 indexes'])
+
+ self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref',
+ substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"',
+ '(CFBagRef) cfbag_ref = ','@"15 values"',
+ '(CFBinaryHeapRef) binheap_ref = ','@"21 items"'])
+
+ self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"'])
+
+ def nsdata_data_formatter_commands(self):
+ self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref',
+ substrs = ['(NSData *) immutableData = ',' 4 bytes',
+ '(NSData *) mutableData = ',' 14 bytes',
+ '(CFDataRef) data_ref = ','@"5 bytes"',
+ '(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"',
+ '(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"'])
+
+ def nsurl_data_formatter_commands(self):
+ self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref',
+ substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar',
+ 'cfchildurl_ref = ','@"page.html -- http://www.foo.bar',
+ '(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"'])
+
+ self.expect('frame variable nsurl nsurl2 nsurl3',
+ substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar',
+ '(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar',
+ '(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"'])
+
+ def nserror_data_formatter_commands(self):
+ self.expect('frame variable nserror',
+ substrs = ['domain: @"Foobar" - code: 12'])
+
+ self.expect('frame variable nserror->_userInfo',
+ substrs = ['2 key/value pairs'])
+
+ self.expect('frame variable nserror->_userInfo --ptr-depth 1 -d run-target',
+ substrs = ['@"a"','@"b"',"1","2"])
+
+ def nsbundle_data_formatter_commands(self):
+ self.expect('frame variable bundle_string bundle_url main_bundle',
+ substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"',
+ '(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Cocoa.framework"',
+ '(NSBundle *) main_bundle = ','data-formatter-objc'])
+
+ def nsexception_data_formatter_commands(self):
+ self.expect('frame variable except0 except1 except2 except3',
+ substrs = ['(NSException *) except0 = ','name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
+ '(NSException *) except1 = ','name:@"TheGuyWhoHasNoName~1" reason:@"cuz it\'s funny"',
+ '(NSException *) except2 = ','name:@"TheGuyWhoHasNoName`2" reason:@"cuz it\'s funny"',
+ '(NSException *) except3 = ','name:@"TheGuyWhoHasNoName/3" reason:@"cuz it\'s funny"'])
+
+ def nsmisc_data_formatter_commands(self):
+ self.expect('frame variable localhost',
+ substrs = ['<NSHost ','> localhost ((','"127.0.0.1"'])
+
+ if self.getArchitecture() in ['i386', 'x86_64']:
+ self.expect('frame variable my_task',
+ substrs = ['<NS','Task: 0x'])
+
+ self.expect('frame variable range_value',
+ substrs = ['NSRange: {4, 4}'])
+
+ self.expect('frame variable port',
+ substrs = ['(NSMachPort *) port = ',' mach port: '])
+
+ def nsdate_data_formatter_commands(self):
+ self.expect('frame variable date1 date2',
+ patterns = ['(1985-04-10|1985-04-11)','(2011-01-01|2010-12-31)'])
+
+ # this test might fail if we hit the breakpoint late on December 31st of some given year
+ # and midnight comes between hitting the breakpoint and running this line of code
+ # hopefully the output will be revealing enough in that case :-)
+ now_year = str(datetime.datetime.now().year)
+
+ self.expect('frame variable date3 date4',
+ substrs = [now_year,'1970'])
+
+ self.expect('frame variable date1_abs date2_abs',
+ substrs = ['1985-04','2011-01'])
+
+ self.expect('frame variable date3_abs date4_abs',
+ substrs = [now_year,'1970'])
+
+ self.expect('frame variable cupertino home europe',
+ substrs = ['@"America/Los_Angeles"',
+ '@"Europe/Rome"',
+ '@"Europe/Paris"'])
+
+ self.expect('frame variable cupertino_ns home_ns europe_ns',
+ substrs = ['@"America/Los_Angeles"',
+ '@"Europe/Rome"',
+ '@"Europe/Paris"'])
+
+ self.expect('frame variable mut_bv',
+ substrs = ['(CFMutableBitVectorRef) mut_bv = ', '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00'])
+
+
+ def expr_objc_data_formatter_commands(self):
+ """Test common cases of expression parser <--> formatters interaction."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # check that the formatters are able to deal safely and correctly
+ # with ValueObjects that the expression parser returns
+ self.expect('expression ((id)@"Hello for long enough to avoid short string types")', matching=False,
+ substrs = ['Hello for long enough to avoid short string types'])
+
+ self.expect('expression -d run -- ((id)@"Hello for long enough to avoid short string types")',
+ substrs = ['Hello for long enough to avoid short string types'])
+
+ self.expect('expr -d run -- label1',
+ substrs = ['Process Name'])
+
+ self.expect('expr -d run -- @"Hello for long enough to avoid short string types"',
+ substrs = ['Hello for long enough to avoid short string types'])
+
+ self.expect('expr -d run --object-description -- @"Hello for long enough to avoid short string types"',
+ substrs = ['Hello for long enough to avoid short string types'])
+ self.expect('expr -d run --object-description -- @"Hello"', matching=False,
+ substrs = ['@"Hello" Hello'])
+
+
+ def cf_data_formatter_commands(self):
+ """Test formatters for Core OSX frameworks."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd('log timers disable', check=False)
+
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # check formatters for common Objective-C types
+ expect_strings = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
+ '(CFRange) cf_range = location=4 length=4',
+ '(NSPoint) ns_point = (x = 4, y = 4)',
+ '(NSRange) ns_range = location=4, length=4',
+ '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))',
+ '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...',
+ '(NSSize) ns_size = (width = 5, height = 7)',
+ '(CGSize) cg_size = (width = 1, height = 6)',
+ '(CGPoint) cg_point = (x = 2, y = 7)',
+ '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))',
+ '(Rect) rect = (t=4, l=8, b=4, r=7)',
+ '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)',
+ '(Point) point = (v=7, h=12)',
+ '(Point *) point_ptr = (v=7, h=12)',
+ 'name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
+ '1985',
+ 'foo_selector_impl'];
+
+ if self.getArchitecture() in ['i386', 'x86_64']:
+ expect_strings.append('(HIPoint) hi_point = (x=7, y=12)')
+ expect_strings.append('(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)')
+ expect_strings.append('(RGBColor) rgb_color = red=3 green=56 blue=35')
+ expect_strings.append('(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35')
+
+ self.expect("frame variable",
+ substrs = expect_strings)
+
+
+ def kvo_data_formatter_commands(self):
+ """Test the behavior of formatters when KVO is in use."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # as long as KVO is implemented by subclassing, this test should succeed
+ # we should be able to dynamically figure out that the KVO implementor class
+ # is a subclass of Molecule, and use the appropriate summary for it
+ self.runCmd("type summary add -s JustAMoleculeHere Molecule")
+ self.expect('frame variable molecule', substrs = ['JustAMoleculeHere'])
+ self.runCmd("next")
+ self.expect("thread list",
+ substrs = ['stopped',
+ 'step over'])
+ self.expect('frame variable molecule', substrs = ['JustAMoleculeHere'])
+
+ self.runCmd("next")
+ # check that NSMutableDictionary's formatter is not confused when dealing with a KVO'd dictionary
+ self.expect('frame variable newMutableDictionary', substrs = ['(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs'])
+
+ lldbutil.run_break_set_by_regexp (self, 'setAtoms')
+
+ self.runCmd("continue")
+ self.expect("frame variable _cmd",substrs = ['setAtoms:'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
new file mode 100644
index 000000000000..6eb7e021f70b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -0,0 +1,694 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+#if defined(__APPLE__)
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#define IOS
+#endif
+#endif
+
+#if defined(IOS)
+#import <Foundation/NSGeometry.h>
+#else
+#import <Carbon/Carbon.h>
+#endif
+
+@interface MyClass : NSObject
+{
+ int i;
+ char c;
+ float f;
+}
+
+- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z;
+- (int)doIncrementByInt: (int)x;
+
+@end
+
+@interface MyOtherClass : MyClass
+{
+ int i2;
+ MyClass *backup;
+}
+- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q;
+
+@end
+
+@implementation MyClass
+
+- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z
+{
+ self = [super init];
+ if (self) {
+ self->i = x;
+ self->f = y;
+ self->c = z;
+ }
+ return self;
+}
+
+- (int)doIncrementByInt: (int)x
+{
+ self->i += x;
+ return self->i;
+}
+
+@end
+
+@implementation MyOtherClass
+
+- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q
+{
+ self = [super initWithInt:x andFloat:y andChar:z];
+ if (self) {
+ self->i2 = q;
+ self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z];
+ }
+ return self;
+}
+
+@end
+
+@interface Atom : NSObject {
+ float mass;
+}
+-(void)setMass:(float)newMass;
+-(float)mass;
+@end
+
+@interface Molecule : NSObject {
+ NSArray *atoms;
+}
+-(void)setAtoms:(NSArray *)newAtoms;
+-(NSArray *)atoms;
+@end
+
+@implementation Atom
+
+-(void)setMass:(float)newMass
+{
+ mass = newMass;
+}
+-(float)mass
+{
+ return mass;
+}
+
+@end
+
+@implementation Molecule
+
+-(void)setAtoms:(NSArray *)newAtoms
+{
+ atoms = newAtoms;
+}
+-(NSArray *)atoms
+{
+ return atoms;
+}
+@end
+
+@interface My_KVO_Observer : NSObject
+-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change
+ context:(void *)context;
+- (id) init;
+- (void) dealloc;
+@end
+
+@implementation My_KVO_Observer
+-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change
+ context:(void *)context {
+ // we do not really care about KVO'ing - do nothing
+ return;
+}
+- (id) init
+{
+ self = [super init];
+ return self;
+}
+
+- (void) dealloc
+{
+ [super dealloc];
+}
+@end
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar: 'E'];
+
+ [object doIncrementByInt:3];
+
+ MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 andFloat:6.28 andChar: 'G' andOtherInt:-1];
+
+ [object2 doIncrementByInt:3];
+
+ NSNumber* num1 = [NSNumber numberWithInt:5];
+ NSNumber* num2 = [NSNumber numberWithFloat:3.14];
+ NSNumber* num3 = [NSNumber numberWithDouble:3.14];
+ NSNumber* num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE];
+ NSNumber* num5 = [NSNumber numberWithChar:'A'];
+ NSNumber* num6 = [NSNumber numberWithUnsignedLongLong:0xFF];
+ NSNumber* num7 = [NSNumber numberWithLong:0x1E8480];
+ NSNumber* num8_Y = [NSNumber numberWithBool:YES];
+ NSNumber* num8_N = [NSNumber numberWithBool:NO];
+ NSNumber* num9 = [NSNumber numberWithShort:0x1E8480];
+ NSNumber* num_at1 = @12;
+ NSNumber* num_at2 = @-12;
+ NSNumber* num_at3 = @12.5;
+ NSNumber* num_at4 = @-12.5;
+
+ NSDecimalNumber* decimal_one = [NSDecimalNumber one];
+
+ NSString *str0 = [num6 stringValue];
+
+ NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
+
+ NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
+
+ NSString *str3 = @"A string made with the at sign is here";
+
+ NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
+
+ NSRect ns_rect_4str = {{1,1},{5,5}};
+
+ NSString* str5 = NSStringFromRect(ns_rect_4str);
+
+ NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
+
+ const unichar myCharacters[] = {0x03C3,'x','x'};
+ NSString *str7 = [NSString stringWithCharacters: myCharacters
+ length: sizeof myCharacters / sizeof *myCharacters];
+
+ NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
+
+ const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
+ 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
+ ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
+ 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
+ NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
+ length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
+
+ const unichar myNextCharacters[] = {0x03C3, 0x0000};
+
+ NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
+
+ NSString *str11 = NSStringFromClass([str10 class]);
+
+ NSString *label1 = @"Process Name: ";
+ NSString *label2 = @"Process Id: ";
+ NSString *processName = [[NSProcessInfo processInfo] processName];
+ NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
+ NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+
+ NSString *strA1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
+
+ NSString *strA2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
+
+ NSString *strA3 = @"A string made with the at sign is here";
+
+ NSString *strA4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
+
+ NSString* strA5 = NSStringFromRect(ns_rect_4str);
+
+ NSString* strA6 = [@"/usr/doc/README.1ST" pathExtension];
+
+ NSString *strA7 = [NSString stringWithCharacters: myCharacters
+ length: sizeof myCharacters / sizeof *myCharacters];
+
+ NSString* strA8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
+
+ NSString *strA9 = [NSString stringWithCharacters: myOtherCharacters
+ length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
+
+ NSString *strA10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
+
+ NSString *strA11 = NSStringFromClass([str10 class]);
+
+ NSString *strA12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+
+ NSString *strB1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
+
+ NSString *strB2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
+
+ NSString *strB3 = @"A string made with the at sign is here";
+
+ NSString *strB4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
+
+ NSString* strB5 = NSStringFromRect(ns_rect_4str);
+
+ NSString* strB6 = [@"/usr/doc/README.1ST" pathExtension];
+
+ NSString *strB7 = [NSString stringWithCharacters: myCharacters
+ length: sizeof myCharacters / sizeof *myCharacters];
+
+ NSString* strB8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
+
+ NSString *strB9 = [NSString stringWithCharacters: myOtherCharacters
+ length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
+
+ NSString *strB10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
+
+ NSString *strB11 = NSStringFromClass([str10 class]);
+
+ NSString *strB12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+
+ NSString *strC11 = NSStringFromClass([str10 class]);
+
+ NSString *strC12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+
+ NSString *strC1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
+
+ NSString *strC2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
+
+ NSString *strC3 = @"A string made with the at sign is here";
+
+ NSString *strC4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
+
+ NSString* strC5 = NSStringFromRect(ns_rect_4str);
+
+ NSString* strC6 = [@"/usr/doc/README.1ST" pathExtension];
+
+ NSString *strC7 = [NSString stringWithCharacters: myCharacters
+ length: sizeof myCharacters / sizeof *myCharacters];
+
+ NSString* strC8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
+
+ NSString *strC9 = [NSString stringWithCharacters: myOtherCharacters
+ length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
+
+ NSString *strC10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
+
+ NSString *strD11 = NSStringFromClass([str10 class]);
+
+ NSString *strD12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+
+ NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9];
+ NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5];
+ NSString *japanese = @"色は匂へど散りぬるを";
+ NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.";
+ NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
+ NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
+
+ void* data_set[3] = {str1,str2,str3};
+
+ NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
+
+ NSArray* newArray = [[NSMutableArray alloc] init];
+ [newArray addObject:str1];
+ [newArray addObject:str2];
+ [newArray addObject:str3];
+ [newArray addObject:str4];
+ [newArray addObject:str5];
+ [newArray addObject:str6];
+ [newArray addObject:str7];
+ [newArray addObject:str8];
+ [newArray addObject:str9];
+ [newArray addObject:str10];
+ [newArray addObject:str11];
+ [newArray addObject:str12];
+ [newArray addObject:strA1];
+ [newArray addObject:strA2];
+ [newArray addObject:strA3];
+ [newArray addObject:strA4];
+ [newArray addObject:strA5];
+ [newArray addObject:strA6];
+ [newArray addObject:strA7];
+ [newArray addObject:strA8];
+ [newArray addObject:strA9];
+ [newArray addObject:strA10];
+ [newArray addObject:strA11];
+ [newArray addObject:strA12];
+ [newArray addObject:strB1];
+ [newArray addObject:strB2];
+ [newArray addObject:strB3];
+ [newArray addObject:strB4];
+ [newArray addObject:strB5];
+ [newArray addObject:strB6];
+ [newArray addObject:strB7];
+ [newArray addObject:strB8];
+ [newArray addObject:strB9];
+ [newArray addObject:strB10];
+ [newArray addObject:strB11];
+ [newArray addObject:strB12];
+ [newArray addObject:strC1];
+ [newArray addObject:strC2];
+ [newArray addObject:strC3];
+ [newArray addObject:strC4];
+ [newArray addObject:strC5];
+ [newArray addObject:strC6];
+ [newArray addObject:strC7];
+ [newArray addObject:strC8];
+ [newArray addObject:strC9];
+ [newArray addObject:strC10];
+ [newArray addObject:strC11];
+ [newArray addObject:strC12];
+ [newArray addObject:strD11];
+ [newArray addObject:strD12];
+
+ NSDictionary* newDictionary = [[NSDictionary alloc] initWithObjects:newArray forKeys:newArray];
+ NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar0"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar1"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar2"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar3"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar4"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar5"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar6"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar7"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar8"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar9"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar10"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar11"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar12"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar13"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar14"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar15"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar16"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar17"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar18"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar19"];
+ [newMutableDictionary setObject:@"foo" forKey:@"bar20"];
+
+ NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];
+ [attrString isEqual:nil];
+ NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];
+ [mutableAttrString isEqual:nil];
+
+ NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
+ [mutableString insertString:@"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear " atIndex:0];
+
+ NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
+
+ [mutableGetConst length];
+
+ NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:4];
+ NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6];
+
+ [mutableData appendBytes:"MOREDATA" length:8];
+
+ [immutableData length];
+ [mutableData length];
+
+ NSSet* nsset = [[NSSet alloc] initWithObjects:str1,str2,str3,nil];
+ NSSet *nsmutableset = [[NSMutableSet alloc] initWithObjects:str1,str2,str3,nil];
+ [nsmutableset addObject:str4];
+
+ CFDataRef data_ref = CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5);
+
+ CFMutableDataRef mutable_data_ref = CFDataCreateMutable(kCFAllocatorDefault, 8);
+ CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5);
+
+ CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
+ CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
+
+ CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
+
+
+ CFSetRef set_ref = CFSetCreate(NULL, data_set, 3, NULL);
+
+ CFMutableSetRef mutable_set_ref = CFSetCreateMutable(NULL, 5, NULL);
+
+ CFSetAddValue(mutable_set_ref, str1);
+ CFSetAddValue(mutable_set_ref, str2);
+ CFSetAddValue(mutable_set_ref, str3);
+ CFSetAddValue(mutable_set_ref, str4);
+ CFSetAddValue(mutable_set_ref, str5);
+ CFSetAddValue(mutable_set_ref, str6);
+ CFSetAddValue(mutable_set_ref, str7);
+ CFSetAddValue(mutable_set_ref, str8);
+ CFSetAddValue(mutable_set_ref, str9);
+ CFSetAddValue(mutable_set_ref, str10);
+ CFSetAddValue(mutable_set_ref, str11);
+ CFSetAddValue(mutable_set_ref, str12);
+
+
+ CFDictionaryRef cfdict_ref = CFDictionaryCreate(NULL, data_set, data_set, 3, NULL, NULL);
+ CFMutableDictionaryRef mutable_dict_ref = CFDictionaryCreateMutable(NULL, 16, NULL, NULL);
+
+ CFDictionarySetValue(mutable_dict_ref, str1, str1);
+ CFDictionarySetValue(mutable_dict_ref, str2, str2);
+ CFDictionarySetValue(mutable_dict_ref, str3, str3);
+ CFDictionarySetValue(mutable_dict_ref, str4, str1);
+ CFDictionarySetValue(mutable_dict_ref, str5, str2);
+ CFDictionarySetValue(mutable_dict_ref, str6, str3);
+ CFDictionarySetValue(mutable_dict_ref, str7, str1);
+ CFDictionarySetValue(mutable_dict_ref, str8, str2);
+ CFDictionarySetValue(mutable_dict_ref, str9, str3);
+ CFDictionarySetValue(mutable_dict_ref, str10, str1);
+ CFDictionarySetValue(mutable_dict_ref, str11, str2);
+ CFDictionarySetValue(mutable_dict_ref, str12, str3);
+
+ CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL);
+ CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL);
+
+ CFArraySetValueAtIndex(mutable_array_ref, 0, str1);
+ CFArraySetValueAtIndex(mutable_array_ref, 1, str2);
+ CFArraySetValueAtIndex(mutable_array_ref, 2, str3);
+ CFArraySetValueAtIndex(mutable_array_ref, 3, str4);
+ CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!!
+ CFArraySetValueAtIndex(mutable_array_ref, 4, str6);
+ CFArraySetValueAtIndex(mutable_array_ref, 5, str7);
+ CFArraySetValueAtIndex(mutable_array_ref, 6, str8);
+ CFArraySetValueAtIndex(mutable_array_ref, 7, str9);
+ CFArraySetValueAtIndex(mutable_array_ref, 8, str10);
+ CFArraySetValueAtIndex(mutable_array_ref, 9, str11);
+ CFArraySetValueAtIndex(mutable_array_ref, 10, str12);
+
+ CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL);
+
+ CFBagSetValue(mutable_bag_ref, strB10);
+ CFBagSetValue(mutable_bag_ref, str1);
+ CFBagSetValue(mutable_bag_ref, str2);
+ CFBagSetValue(mutable_bag_ref, str3);
+ CFBagSetValue(mutable_bag_ref, str4);
+ CFBagSetValue(mutable_bag_ref, str5);
+ CFBagSetValue(mutable_bag_ref, str6);
+ CFBagSetValue(mutable_bag_ref, str7);
+ CFBagSetValue(mutable_bag_ref, str8);
+ CFBagSetValue(mutable_bag_ref, str9);
+ CFBagSetValue(mutable_bag_ref, str10);
+ CFBagSetValue(mutable_bag_ref, str11);
+ CFBagSetValue(mutable_bag_ref, str12);
+ CFBagSetValue(mutable_bag_ref, strA1);
+ CFBagSetValue(mutable_bag_ref, strA2);
+ CFBagSetValue(mutable_bag_ref, strA3);
+
+ CFBagRef cfbag_ref = CFBagCreateCopy(NULL, mutable_bag_ref);
+
+ CFBagSetValue(mutable_bag_ref, strB8);
+ CFBagSetValue(mutable_bag_ref, strC4);
+
+
+ CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);
+ CFBinaryHeapAddValue(binheap_ref, str1);
+ CFBinaryHeapAddValue(binheap_ref, str2);
+ CFBinaryHeapAddValue(binheap_ref, str3);
+ CFBinaryHeapAddValue(binheap_ref, str4);
+ CFBinaryHeapAddValue(binheap_ref, str5);
+ CFBinaryHeapAddValue(binheap_ref, str6);
+ CFBinaryHeapAddValue(binheap_ref, str7);
+ CFBinaryHeapAddValue(binheap_ref, str8);
+ CFBinaryHeapAddValue(binheap_ref, str9);
+ CFBinaryHeapAddValue(binheap_ref, str10);
+ CFBinaryHeapAddValue(binheap_ref, str11);
+ CFBinaryHeapAddValue(binheap_ref, str12);
+ CFBinaryHeapAddValue(binheap_ref, strA1);
+ CFBinaryHeapAddValue(binheap_ref, strB1);
+ CFBinaryHeapAddValue(binheap_ref, strC1);
+ CFBinaryHeapAddValue(binheap_ref, strA11);
+ CFBinaryHeapAddValue(binheap_ref, strB11);
+ CFBinaryHeapAddValue(binheap_ref, strC11);
+ CFBinaryHeapAddValue(binheap_ref, strB12);
+ CFBinaryHeapAddValue(binheap_ref, strC12);
+ CFBinaryHeapAddValue(binheap_ref, strA12);
+
+ CFURLRef cfurl_ref = CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL);
+ CFURLRef cfchildurl_ref = CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref);
+ CFURLRef cfgchildurl_ref = CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref);
+
+ NSDictionary *error_userInfo = @{@"a": @1, @"b" : @2};
+ NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar" code:12 userInfo:error_userInfo];
+
+ NSBundle* bundle_string = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/Accelerate.framework"];
+ NSBundle* bundle_url = [[NSBundle alloc] initWithURL:[[NSURL alloc] initWithString:@"file://localhost/System/Library/Frameworks/Cocoa.framework"]];
+
+ NSBundle* main_bundle = [NSBundle mainBundle];
+
+ NSArray* bundles = [NSBundle allBundles];
+
+ NSURL *nsurl0;
+
+ for (NSBundle* bundle in bundles)
+ {
+ nsurl0 = [bundle bundleURL];
+ }
+
+ NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"cuz it's funny" userInfo:nil];
+ NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"cuz it's funny" userInfo:nil];
+ NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil];
+ NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil];
+
+ NSMachPort *port = [NSMachPort port];
+
+ NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];
+ NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
+ NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
+
+ NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm April 10, 1985"];
+ NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"];
+ NSDate *date3 = [NSDate date];
+ NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
+
+ CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1);
+ CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2);
+ CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3);
+ CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4);
+
+ NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5];
+
+ [nscounted_set addObject:str0];
+ [nscounted_set addObject:str1];
+ [nscounted_set addObject:str0];
+ [nscounted_set addObject:str0];
+ [nscounted_set addObject:@"foo1"];
+ [nscounted_set addObject:@"foo2"];
+ [nscounted_set addObject:@"foo3"];
+
+ NSIndexSet *iset1 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)];
+ NSIndexSet *iset2 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)];
+
+ NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init];
+ [imset addIndex:1936];
+ [imset addIndex:7];
+ [imset addIndex:9];
+ [imset addIndex:11];
+ [imset addIndex:24];
+ [imset addIndex:41];
+ [imset addIndex:58];
+ [imset addIndex:61];
+ [imset addIndex:62];
+ [imset addIndex:63];
+
+ CFTimeZoneRef cupertino = CFTimeZoneCreateWithName (
+ NULL,
+ CFSTR("PST"),
+ YES);
+ CFTimeZoneRef home = CFTimeZoneCreateWithName (
+ NULL,
+ CFSTR("Europe/Rome"),
+ YES);
+ CFTimeZoneRef europe = CFTimeZoneCreateWithName (
+ NULL,
+ CFSTR("CET"),
+ YES);
+
+ NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"];
+ NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"];
+ NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"];
+
+ NSHost *localhost = [NSHost hostWithAddress:@"127.0.0.1"];
+
+#ifndef IOS
+ NSTask *my_task = [[NSTask alloc] init];
+#endif
+
+
+ CFGregorianUnits cf_greg_units = {1,3,5,12,5,7};
+ CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL);
+ CFRange cf_range = {4,4};
+ NSPoint ns_point = {4,4};
+ NSRange ns_range = {4,4};
+
+ NSValue *range_value = [NSValue valueWithRange:ns_range];
+
+ NSRect ns_rect = {{1,1},{5,5}};
+ NSRect* ns_rect_ptr = &ns_rect;
+ NSRectArray ns_rect_arr = &ns_rect;
+ NSSize ns_size = {5,7};
+ NSSize* ns_size_ptr = &ns_size;
+
+ CGSize cg_size = {1,6};
+ CGPoint cg_point = {2,7};
+ CGRect cg_rect = {{1,2}, {7,7}};
+
+#ifndef IOS
+ RGBColor rgb_color = {3,56,35};
+ RGBColor* rgb_color_ptr = &rgb_color;
+#endif
+
+ Rect rect = {4,8,4,7};
+ Rect* rect_ptr = &rect;
+
+ Point point = {7,12};
+ Point* point_ptr = &point;
+
+#ifndef IOS
+ HIPoint hi_point = {7,12};
+ HIRect hi_rect = {{3,5},{4,6}};
+#endif
+
+ SEL foo_selector = @selector(foo_selector_impl);
+
+ CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64);
+ CFBitVectorSetCount(mut_bv, 50);
+ CFBitVectorSetBitAtIndex(mut_bv, 0, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 1, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 2, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 5, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 6, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 8, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 10, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 11, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 16, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 17, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 19, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 20, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 22, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 24, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 28, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 29, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 31, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 34, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 35, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 37, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 39, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 40, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 41, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 43, 1);
+ CFBitVectorSetBitAtIndex(mut_bv, 47, 1);
+
+ Molecule *molecule = [Molecule new];
+
+ Class myclass = NSClassFromString(@"NSValue");
+ Class myclass2 = [str0 class];
+ Class myclass3 = [molecule class];
+ Class myclass4 = NSClassFromString(@"NSMutableArray");
+ Class myclass5 = [nil class];
+
+ NSArray *components = @[@"usr", @"blah", @"stuff"];
+ NSString *path = [NSString pathWithComponents: components];
+
+ [molecule addObserver:[My_KVO_Observer new] forKeyPath:@"atoms" options:0 context:NULL]; // Set break point at this line.
+ [newMutableDictionary addObserver:[My_KVO_Observer new] forKeyPath:@"weirdKeyToKVO" options:NSKeyValueObservingOptionNew context:NULL];
+
+ [molecule setAtoms:nil];
+ [molecule setAtoms:[NSMutableArray new]];
+
+ [pool drain];
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile
new file mode 100644
index 000000000000..0d94c2247f14
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
new file mode 100644
index 000000000000..e11c45e9038e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
@@ -0,0 +1,107 @@
+# encoding: utf-8
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class NSStringDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def appkit_tester_impl(self,commands):
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+ commands()
+
+ @skipUnlessDarwin
+ def test_nsstring_with_run_command(self):
+ """Test formatters for NSString."""
+ self.appkit_tester_impl(self.nsstring_data_formatter_commands)
+
+ @skipUnlessDarwin
+ def test_rdar11106605_with_run_command(self):
+ """Check that Unicode characters come out of CFString summary correctly."""
+ self.appkit_tester_impl(self.rdar11106605_commands)
+
+ @skipUnlessDarwin
+ def test_nsstring_withNULS_with_run_command(self):
+ """Test formatters for NSString."""
+ self.appkit_tester_impl(self.nsstring_withNULs_commands)
+
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// break here')
+
+ def rdar11106605_commands(self):
+ """Check that Unicode characters come out of CFString summary correctly."""
+ self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.'])
+ self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?'])
+ self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt'])
+ self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを'])
+ self.expect('frame variable hebrew', substrs = ['לילה טוב'])
+
+ def nsstring_data_formatter_commands(self):
+ self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
+ substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
+ # '(NSString *) str0 = ',' @"255"',
+ '(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
+ '(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"',
+ '(NSString *) str3 = ',' @"A string made with the at sign is here"',
+ '(NSString *) str4 = ',' @"This is string number 4 right here"',
+ '(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"',
+ '(NSString *) str6 = ',' @"1ST"',
+ '(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
+ '(NSString *) str9 = ',' @"a very much boring task to write a string this way!!',
+ '(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"',
+ '(NSString *) str11 = ',' @"__NSCFString"',
+ '(NSString *) label1 = ',' @"Process Name: "',
+ '(NSString *) label2 = ',' @"Process Id: "',
+ '(NSString *) str12 = ',' @"Process Name: a.out Process Id:'])
+ self.expect('frame variable attrString mutableAttrString mutableGetConst',
+ substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
+ '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"',
+ '(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"'])
+
+ self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff'])
+ self.expect('frame variable path',substrs = ['usr/blah/stuff'])
+
+ def nsstring_withNULs_commands(self):
+ """Check that the NSString formatter supports embedded NULs in the text"""
+ self.expect('po strwithNULs', substrs=['a very much boring task to write'])
+ self.expect('expr [strwithNULs length]', substrs=['54'])
+ self.expect('frame variable strwithNULs', substrs=['@"a very much boring task to write\\0a string this way!!'])
+ self.expect('po strwithNULs2', substrs=['a very much boring task to write'])
+ self.expect('expr [strwithNULs2 length]', substrs=['52'])
+ self.expect('frame variable strwithNULs2', substrs=['@"a very much boring task to write\\0a string this way!!'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
new file mode 100644
index 000000000000..7b8c3785a18c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
@@ -0,0 +1,99 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+#if defined(__APPLE__)
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#define IOS
+#endif
+#endif
+
+#if defined(IOS)
+#import <Foundation/NSGeometry.h>
+#else
+#import <Carbon/Carbon.h>
+#endif
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue];
+ NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
+ NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
+ NSString *str3 = @"A string made with the at sign is here";
+ NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
+ NSRect ns_rect_4str = {{1,1},{5,5}};
+ NSString* str5 = NSStringFromRect(ns_rect_4str);
+ NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
+ const unichar myCharacters[] = {0x03C3,'x','x'};
+ NSString *str7 = [NSString stringWithCharacters: myCharacters
+ length: sizeof myCharacters / sizeof *myCharacters];
+ NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
+ const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
+ 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
+ ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
+ 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
+ NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
+ length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
+ const unichar myNextCharacters[] = {0x03C3, 0x0000};
+ NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
+ NSString *str11 = NSStringFromClass([str10 class]);
+ NSString *label1 = @"Process Name: ";
+ NSString *label2 = @"Process Id: ";
+ NSString *processName = [[NSProcessInfo processInfo] processName];
+ NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
+ NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
+ NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9];
+ NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5];
+ NSString *japanese = @"色は匂へど散りぬるを";
+ NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.";
+ NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
+ NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
+ void* data_set[3] = {str1,str2,str3};
+ NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
+
+ NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
+ [attrString isEqual:nil];
+ NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
+ [mutableAttrString isEqual:nil];
+
+ NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
+ [mutableString insertString:@"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear " atIndex:0];
+
+ NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
+
+ [mutableGetConst length];
+ CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
+ CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
+ CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
+
+ NSArray *components = @[@"usr", @"blah", @"stuff"];
+ NSString *path = [NSString pathWithComponents: components];
+
+ const unichar someOfTheseAreNUL[] = {'a',' ', 'v','e','r','y',' ',
+ 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
+ ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
+ 't','h','i','s',' ','w','a','y','!','!', 0x03C3, 0};
+ NSString *strwithNULs = [NSString stringWithCharacters: someOfTheseAreNUL
+ length: sizeof someOfTheseAreNUL / sizeof *someOfTheseAreNUL];
+
+ const unichar someOfTheseAreNUL2[] = {'a',' ', 'v','e','r','y',' ',
+ 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
+ ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
+ 't','h','i','s',' ','w','a','y','!','!'};
+ NSString *strwithNULs2 = [NSString stringWithCharacters: someOfTheseAreNUL2
+ length: sizeof someOfTheseAreNUL2 / sizeof *someOfTheseAreNUL2];
+
+ [pool drain]; // break here
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/Makefile
new file mode 100644
index 000000000000..9f7fb1ca6231
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py
new file mode 100644
index 000000000000..1281f17ab58a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py
@@ -0,0 +1,90 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterOneIsSingularTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessDarwin
+ def test_one_is_singular_with_run_command(self):
+ """Test that 1 item is not as reported as 1 items."""
+ self.build()
+ self.oneness_data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ def oneness_data_formatter_commands(self):
+ """Test that 1 item is not as reported as 1 items."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we are displaying Cocoa classes correctly
+ self.expect('frame variable key',
+ substrs = ['@"1 element"'])
+ self.expect('frame variable key', matching=False,
+ substrs = ['1 elements'])
+ self.expect('frame variable value',
+ substrs = ['@"1 element"'])
+ self.expect('frame variable value', matching=False,
+ substrs = ['1 elements'])
+ self.expect('frame variable dict',
+ substrs = ['1 key/value pair'])
+ self.expect('frame variable dict', matching=False,
+ substrs = ['1 key/value pairs'])
+ self.expect('frame variable mutable_bag_ref',
+ substrs = ['@"1 value"'])
+ self.expect('frame variable mutable_bag_ref', matching=False,
+ substrs = ['1 values'])
+ self.expect('frame variable nscounted_set',
+ substrs = ['1 element'])
+ self.expect('frame variable nscounted_set', matching=False,
+ substrs = ['1 elements'])
+ self.expect('frame variable imset',
+ substrs = ['1 index'])
+ self.expect('frame variable imset', matching=False,
+ substrs = ['1 indexes'])
+ self.expect('frame variable binheap_ref',
+ substrs = ['@"1 item"'])
+ self.expect('frame variable binheap_ref', matching=False,
+ substrs = ['1 items'])
+ self.expect('frame variable nsset',
+ substrs = ['1 element'])
+ self.expect('frame variable nsset', matching=False,
+ substrs = ['1 elements'])
+ self.expect('frame variable immutableData',
+ substrs = ['1 byte'])
+ self.expect('frame variable immutableData', matching=False,
+ substrs = ['1 bytes'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m
new file mode 100644
index 000000000000..7204d3c7b202
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m
@@ -0,0 +1,42 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+
+ NSArray* key = [NSArray arrayWithObjects:@"foo",nil];
+ NSArray* value = [NSArray arrayWithObjects:@"key",nil];
+ NSDictionary *dict = [NSDictionary dictionaryWithObjects:value forKeys:key];
+
+ CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL);
+ CFBagSetValue(mutable_bag_ref, CFSTR("Hello world"));
+
+ NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5];
+ [nscounted_set addObject:@"foo"];
+
+ NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init];
+ [imset addIndex:4];
+
+ CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);
+ CFBinaryHeapAddValue(binheap_ref, CFSTR("Hello world"));
+
+ NSSet* nsset = [[NSSet alloc] initWithObjects:@"foo",nil];
+
+ NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:1];
+
+
+ [pool drain];// Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py
new file mode 100644
index 000000000000..86cd3c427288
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py
@@ -0,0 +1,57 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class PtrToArrayDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_with_run_command(self):
+ """Test that LLDB handles the clang typeclass Paren correctly."""
+ self.build()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that LLDB handles the clang typeclass Paren correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format delete hex', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('p *(int (*)[3])foo',
+ substrs = ['(int [3]) $','[0] = 1','[1] = 2','[2] = 3'])
+
+ self.expect('p *(int (*)[3])foo', matching=False,
+ substrs = ['01 00 00 00 02 00 00 00 03 00 00 00'])
+ self.expect('p *(int (*)[3])foo', matching=False,
+ substrs = ['0x000000030000000200000001'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp
new file mode 100644
index 000000000000..15fa5614d7fd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+bool bar(int const *foo) {
+ return foo != 0; // Set break point at this line.
+}
+
+int main() {
+ int foo[] = {1,2,3};
+ return bar(foo);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
new file mode 100644
index 000000000000..d202ff5d64e1
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -0,0 +1,252 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class PythonSynthDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser
+ def test_with_run_command(self):
+ """Test data formatter commands."""
+ self.build()
+ self.data_formatter_commands()
+
+ def test_rdar10960550_with_run_command(self):
+ """Test data formatter commands."""
+ self.build()
+ self.rdar10960550_formatter_commands()
+
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+ self.line2 = line_number('main.cpp', '// Set cast break point at this line.')
+ self.line3 = line_number('main.cpp', '// Set second cast break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test using Python synthetic children provider."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # print the f00_1 variable without a synth
+ self.expect("frame variable f00_1",
+ substrs = ['a = 0',
+ 'b = 1',
+ 'r = 33']);
+
+ # now set up the synth
+ self.runCmd("script from fooSynthProvider import *")
+ self.runCmd("type synth add -l fooSynthProvider foo")
+
+ # check that we get the two real vars and the fake_a variables
+ self.expect("frame variable f00_1",
+ substrs = ['r = 33',
+ 'fake_a = 16777216',
+ 'a = 0']);
+
+ # check that we do not get the extra vars
+ self.expect("frame variable f00_1", matching=False,
+ substrs = ['b = 1']);
+
+ # check access to members by name
+ self.expect('frame variable f00_1.fake_a',
+ substrs = ['16777216'])
+
+ # check access to members by index
+ self.expect('frame variable f00_1[1]',
+ substrs = ['16777216'])
+
+ # put synthetic children in summary in several combinations
+ self.runCmd("type summary add --summary-string \"fake_a=${svar.fake_a}\" foo")
+ self.expect('frame variable f00_1',
+ substrs = ['fake_a=16777216'])
+ self.runCmd("type summary add --summary-string \"fake_a=${svar[1]}\" foo")
+ self.expect('frame variable f00_1',
+ substrs = ['fake_a=16777216'])
+
+ # clear the summary
+ self.runCmd("type summary delete foo")
+
+ # check that the caching does not span beyond the stopoint
+ self.runCmd("n")
+
+ self.expect("frame variable f00_1",
+ substrs = ['r = 33',
+ 'fake_a = 16777216',
+ 'a = 1']);
+
+ # check that altering the object also alters fake_a
+ self.runCmd("expr f00_1.a = 280")
+ self.expect("frame variable f00_1",
+ substrs = ['r = 33',
+ 'fake_a = 16777217',
+ 'a = 280']);
+
+ # check that expanding a pointer does the right thing
+ self.expect("frame variable --ptr-depth 1 f00_ptr",
+ substrs = ['r = 45',
+ 'fake_a = 218103808',
+ 'a = 12'])
+
+ # now add a filter.. it should fail
+ self.expect("type filter add foo --child b --child j", error=True,
+ substrs = ['cannot add'])
+
+ # we get the synth again..
+ self.expect('frame variable f00_1', matching=False,
+ substrs = ['b = 1',
+ 'j = 17'])
+ self.expect("frame variable --ptr-depth 1 f00_ptr",
+ substrs = ['r = 45',
+ 'fake_a = 218103808',
+ 'a = 12'])
+
+ # now delete the synth and add the filter
+ self.runCmd("type synth delete foo")
+ self.runCmd("type filter add foo --child b --child j")
+
+ self.expect('frame variable f00_1',
+ substrs = ['b = 1',
+ 'j = 17'])
+ self.expect("frame variable --ptr-depth 1 f00_ptr", matching=False,
+ substrs = ['r = 45',
+ 'fake_a = 218103808',
+ 'a = 12'])
+
+ # now add the synth and it should fail
+ self.expect("type synth add -l fooSynthProvider foo", error=True,
+ substrs = ['cannot add'])
+
+ # check the listing
+ self.expect('type synth list', matching=False,
+ substrs = ['foo',
+ 'Python class fooSynthProvider'])
+ self.expect('type filter list',
+ substrs = ['foo',
+ '.b',
+ '.j'])
+
+ # delete the filter, add the synth
+ self.runCmd("type filter delete foo")
+ self.runCmd("type synth add -l fooSynthProvider foo")
+
+ self.expect('frame variable f00_1', matching=False,
+ substrs = ['b = 1',
+ 'j = 17'])
+ self.expect("frame variable --ptr-depth 1 f00_ptr",
+ substrs = ['r = 45',
+ 'fake_a = 218103808',
+ 'a = 12'])
+
+ # check the listing
+ self.expect('type synth list',
+ substrs = ['foo',
+ 'Python class fooSynthProvider'])
+ self.expect('type filter list', matching=False,
+ substrs = ['foo',
+ '.b',
+ '.j'])
+
+ # delete the synth and check that we get good output
+ self.runCmd("type synth delete foo")
+
+ self.expect("frame variable f00_1",
+ substrs = ['a = 280',
+ 'b = 1',
+ 'j = 17']);
+
+ self.expect("frame variable f00_1", matching=False,
+ substrs = ['fake_a = '])
+
+ def rdar10960550_formatter_commands(self):
+ """Test that synthetic children persist stoppoints."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ # The second breakpoint is on a multi-line expression, so the comment can't be on the right line...
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("command script import ./ftsp.py --allow-reload")
+ self.runCmd("type synth add -l ftsp.ftsp wrapint")
+
+ # we need to check that the VO is properly updated so that the same synthetic children are reused
+ # but their values change correctly across stop-points - in order to do this, self.runCmd("next")
+ # does not work because it forces a wipe of the stack frame - this is why we are using this more contrived
+ # mechanism to achieve our goal of preserving test_cast as a VO
+ test_cast = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('test_cast')
+
+ str_cast = str(test_cast)
+
+ if self.TraceOn():
+ print(str_cast)
+
+ self.assertTrue(str_cast.find('A') != -1, 'could not find A in output')
+ self.assertTrue(str_cast.find('B') != -1, 'could not find B in output')
+ self.assertTrue(str_cast.find('C') != -1, 'could not find C in output')
+ self.assertTrue(str_cast.find('D') != -1, 'could not find D in output')
+ self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0')
+
+ self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver()
+
+ str_cast = str(test_cast)
+
+ if self.TraceOn():
+ print(str_cast)
+
+ # we detect that all the values of the child objects have changed - but the counter-generated item
+ # is still fixed at 0 because it is cached - this would fail if update(self): in ftsp returned False
+ # or if synthetic children were not being preserved
+ self.assertTrue(str_cast.find('Q') != -1, 'could not find Q in output')
+ self.assertTrue(str_cast.find('X') != -1, 'could not find X in output')
+ self.assertTrue(str_cast.find('T') != -1, 'could not find T in output')
+ self.assertTrue(str_cast.find('F') != -1, 'could not find F in output')
+ self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0')
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
new file mode 100644
index 000000000000..0dc2c233e2a6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py
@@ -0,0 +1,23 @@
+import lldb
+class fooSynthProvider:
+ def __init__(self, valobj, dict):
+ self.valobj = valobj;
+ self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt)
+ def num_children(self):
+ return 3;
+ def get_child_at_index(self, index):
+ if index == 0:
+ child = self.valobj.GetChildMemberWithName('a');
+ if index == 1:
+ child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type);
+ if index == 2:
+ child = self.valobj.GetChildMemberWithName('r');
+ return child;
+ def get_child_index(self, name):
+ if name == 'a':
+ return 0;
+ if name == 'fake_a':
+ return 1;
+ return 2;
+ def update(self):
+ return True \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py
new file mode 100644
index 000000000000..d162b00db329
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py
@@ -0,0 +1,32 @@
+import lldb
+
+counter = 0
+
+class ftsp:
+ def __init__(self, valobj, dict):
+ self.valobj = valobj;
+ def num_children(self):
+ if self.char.IsValid():
+ return 5;
+ return 0;
+ def get_child_index(self,name):
+ return 0;
+ def get_child_at_index(self,index):
+ if index == 0:
+ return self.x.Cast(self.char)
+ if index == 4:
+ return self.valobj.CreateValueFromExpression(str(index),'(char)('+str(self.count)+')')
+ return self.x.CreateChildAtOffset(str(index),
+ index,
+ self.char);
+ def update(self):
+ self.x = self.valobj.GetChildMemberWithName('x');
+ self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)
+ global counter
+ self.count = counter
+ counter = counter + 1
+ return True # important: if we return False here, or fail to return, the test will fail
+
+def __lldb_init_module(debugger, dict):
+ global counter
+ counter = 0 \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
new file mode 100644
index 000000000000..48b29dcfd6e4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
@@ -0,0 +1,66 @@
+struct foo
+{
+ int a;
+ int b;
+ int c;
+ int d;
+ int e;
+ int f;
+ int g;
+ int h;
+ int i;
+ int j;
+ int k;
+ int l;
+ int m;
+ int n;
+ int o;
+ int p;
+ int q;
+ int r;
+
+ foo(int X) :
+ a(X),
+ b(X+1),
+ c(X+3),
+ d(X+5),
+ e(X+7),
+ f(X+9),
+ g(X+11),
+ h(X+13),
+ i(X+15),
+ j(X+17),
+ k(X+19),
+ l(X+21),
+ m(X+23),
+ n(X+25),
+ o(X+27),
+ p(X+29),
+ q(X+31),
+ r(X+33) {}
+};
+
+struct wrapint
+{
+ int x;
+ wrapint(int X) : x(X) {}
+};
+
+int main()
+{
+ foo f00_1(0);
+ foo *f00_ptr = new foo(12);
+
+ f00_1.a++; // Set break point at this line.
+
+ wrapint test_cast('A' +
+ 256*'B' +
+ 256*256*'C'+
+ 256*256*256*'D');
+ // Set cast break point at this line.
+ test_cast.x = 'Q' +
+ 256*'X' +
+ 256*256*'T'+
+ 256*256*256*'F';
+ return 0; // Set second cast break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py
new file mode 100644
index 000000000000..324b372cb11e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py
@@ -0,0 +1,170 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class ScriptDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_with_run_command(self):
+ """Test data formatter commands."""
+ self.build()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Set the script here to ease the formatting
+ script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');'
+
+ self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script)
+
+ self.expect("frame variable one",
+ substrs = ['Hello from Python',
+ '1 time!'])
+
+ self.expect("frame variable two",
+ substrs = ['Hello from Python',
+ '4 times!'])
+
+ self.runCmd("n"); # skip ahead to make values change
+
+ self.expect("frame variable three",
+ substrs = ['Hello from Python, 10 times!',
+ 'Hello from Python, 4 times!'])
+
+ self.runCmd("n"); # skip ahead to make values change
+
+ self.expect("frame variable two",
+ substrs = ['Hello from Python',
+ '1 time!'])
+
+ script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'int says \' + a_val; return str;'
+
+ # Check that changes in the script are immediately reflected
+ self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script)
+
+ self.expect("frame variable two",
+ substrs = ['int says 1'])
+
+ self.expect("frame variable twoptr",
+ substrs = ['int says 1'])
+
+ # Change the summary
+ self.runCmd("type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool")
+
+ self.expect("frame variable two",
+ substrs = ['int says 1',
+ 'and float says 2.71'])
+ # Try it for pointers
+ self.expect("frame variable twoptr",
+ substrs = ['int says 1',
+ 'and float says 2.71'])
+
+ # Force a failure for pointers
+ self.runCmd("type summary add i_am_cool -p --python-script \"%s\"" % script)
+
+ self.expect("frame variable twoptr", matching=False,
+ substrs = ['and float says 2.71'])
+
+ script = 'return \'Python summary\'';
+
+ self.runCmd("type summary add --name test_summary --python-script \"%s\"" % script)
+
+ # attach the Python named summary to someone
+ self.expect("frame variable one --summary test_summary",
+ substrs = ['Python summary'])
+
+ # should not bind to the type
+ self.expect("frame variable two", matching=False,
+ substrs = ['Python summary'])
+
+ # and should not stick to the variable
+ self.expect("frame variable one",matching=False,
+ substrs = ['Python summary'])
+
+ self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"")
+
+ # should be temporary only
+ self.expect("frame variable one",matching=False,
+ substrs = ['Python summary'])
+
+ # use the type summary
+ self.expect("frame variable two",
+ substrs = ['Text summary'])
+
+ self.runCmd("n"); # skip ahead to make values change
+
+ # both should use the type summary now
+ self.expect("frame variable one",
+ substrs = ['Text summary'])
+
+ self.expect("frame variable two",
+ substrs = ['Text summary'])
+
+ # disable type summary for pointers, and make a Python regex summary
+ self.runCmd("type summary add i_am_cool -p --summary-string \"Text summary\"")
+ self.runCmd("type summary add -x cool --python-script \"%s\"" % script)
+
+ # variables should stick to the type summary
+ self.expect("frame variable one",
+ substrs = ['Text summary'])
+
+ self.expect("frame variable two",
+ substrs = ['Text summary'])
+
+ # array and pointer should match the Python one
+ self.expect("frame variable twoptr",
+ substrs = ['Python summary'])
+
+ self.expect("frame variable array",
+ substrs = ['Python summary'])
+
+ # return pointers to the type summary
+ self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"")
+
+ self.expect("frame variable one",
+ substrs = ['Text summary'])
+
+ self.expect("frame variable two",
+ substrs = ['Text summary'])
+
+ self.expect("frame variable twoptr",
+ substrs = ['Text summary'])
+
+ self.expect("frame variable array",
+ substrs = ['Python summary'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp
new file mode 100644
index 000000000000..aaccb6329acf
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp
@@ -0,0 +1,53 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct i_am_cool
+{
+ int integer;
+ float floating;
+ char character;
+ i_am_cool(int I, float F, char C) :
+ integer(I), floating(F), character(C) {}
+ i_am_cool() : integer(1), floating(2), character('3') {}
+
+};
+
+struct i_am_cooler
+{
+ i_am_cool first_cool;
+ i_am_cool second_cool;
+ float floating;
+
+ i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
+ first_cool(I1,F1,C1),
+ second_cool(I2,F2,C2),
+ floating((F1 + F2)/2) {}
+};
+
+int main (int argc, const char * argv[])
+{
+ i_am_cool one(1,3.14,'E');
+ i_am_cool two(4,2.71,'G');
+
+ i_am_cool* twoptr = &two;
+
+ i_am_cool array[5];
+
+ i_am_cooler three(10,4,1985,1/1/2011,'B','E'); // Set break point at this line.
+
+ two.integer = 1;
+
+ int dummy = 1;
+
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
new file mode 100644
index 000000000000..b438bbb970f6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
@@ -0,0 +1,19 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
+
+CXXFLAGS += -O0
+
+ifeq (,$(findstring gcc,$(CC)))
+CXXFLAGS += -stdlib=libstdc++
+LDFLAGS += -stdlib=libstdc++
+endif
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
new file mode 100644
index 000000000000..38e700812d05
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
@@ -0,0 +1,175 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SkipSummaryDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureFreeBSD("llvm.org/pr20548") # fails to build on lab.llvm.org buildbot
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Test data formatter commands."""
+ self.build()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ #import lldbsuite.test.lldbutil as lldbutil
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Setup the summaries for this scenario
+ #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string")
+ self.runCmd("type summary add --summary-string \"Level 1\" \"DeepData_1\"")
+ self.runCmd("type summary add --summary-string \"Level 2\" \"DeepData_2\" -e")
+ self.runCmd("type summary add --summary-string \"Level 3\" \"DeepData_3\"")
+ self.runCmd("type summary add --summary-string \"Level 4\" \"DeepData_4\"")
+ self.runCmd("type summary add --summary-string \"Level 5\" \"DeepData_5\"")
+
+ # Default case, just print out summaries
+ self.expect('frame variable',
+ substrs = ['(DeepData_1) data1 = Level 1',
+ '(DeepData_2) data2 = Level 2 {',
+ 'm_child1 = Level 3',
+ 'm_child2 = Level 3',
+ 'm_child3 = Level 3',
+ 'm_child4 = Level 3',
+ '}'])
+
+ # Skip the default (should be 1) levels of summaries
+ self.expect('frame variable --no-summary-depth',
+ substrs = ['(DeepData_1) data1 = {',
+ 'm_child1 = 0x',
+ '}',
+ '(DeepData_2) data2 = {',
+ 'm_child1 = Level 3',
+ 'm_child2 = Level 3',
+ 'm_child3 = Level 3',
+ 'm_child4 = Level 3',
+ '}'])
+
+ # Now skip 2 levels of summaries
+ self.expect('frame variable --no-summary-depth=2',
+ substrs = ['(DeepData_1) data1 = {',
+ 'm_child1 = 0x',
+ '}',
+ '(DeepData_2) data2 = {',
+ 'm_child1 = {',
+ 'm_child1 = 0x',
+ 'Level 4',
+ 'm_child2 = {',
+ 'm_child3 = {',
+ '}'])
+
+ # Check that no "Level 3" comes out
+ self.expect('frame variable data1.m_child1 --no-summary-depth=2', matching=False,
+ substrs = ['Level 3'])
+
+ # Now expand a pointer with 2 level of skipped summaries
+ self.expect('frame variable data1.m_child1 --no-summary-depth=2',
+ substrs = ['(DeepData_2 *) data1.m_child1 = 0x'])
+
+ # Deref and expand said pointer
+ self.expect('frame variable *data1.m_child1 --no-summary-depth=2',
+ substrs = ['(DeepData_2) *data1.m_child1 = {',
+ 'm_child2 = {',
+ 'm_child1 = 0x',
+ 'Level 4',
+ '}'])
+
+ # Expand an expression, skipping 2 layers of summaries
+ self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=2',
+ substrs = ['(DeepData_3) data1.m_child1->m_child2 = {',
+ 'm_child2 = {',
+ 'm_child1 = Level 5',
+ 'm_child2 = Level 5',
+ 'm_child3 = Level 5',
+ '}'])
+
+ # Expand same expression, skipping only 1 layer of summaries
+ self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=1',
+ substrs = ['(DeepData_3) data1.m_child1->m_child2 = {',
+ 'm_child1 = 0x',
+ 'Level 4',
+ 'm_child2 = Level 4',
+ '}'])
+
+ # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666).
+ # Skip the following tests if the condition is met.
+ if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'):
+ import re
+ gcc_version_output = system([[lldbutil.which(self.getCompiler()), "-v"]])[1]
+ #print("my output:", gcc_version_output)
+ for line in gcc_version_output.split(os.linesep):
+ m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)
+ #print("line:", line)
+ if m:
+ gcc_build = int(m.group(1))
+ #print("gcc build:", gcc_build)
+ if gcc_build >= 5666:
+ # rdar://problem/9804600"
+ self.skipTest("rdar://problem/9804600 wrong namespace for std::string in debug info")
+
+ # Expand same expression, skipping 3 layers of summaries
+ self.expect('frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3',
+ substrs = ['(DeepData_3) data1.m_child1->m_child2 = {',
+ 'm_some_text = "Just a test"',
+ 'm_child2 = {',
+ 'm_some_text = "Just a test"'])
+
+ # Expand within a standard string (might depend on the implementation of the C++ stdlib you use)
+ self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2',
+ substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {',
+ 'm_some_text = {',
+ '_M_dataplus = (_M_p = "Just a test")'])
+
+ # Repeat the above, but only skip 1 level of summaries
+ self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1',
+ substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {',
+ 'm_some_text = "Just a test"',
+ '}'])
+
+ # Change summary and expand, first without --no-summary-depth then with --no-summary-depth
+ self.runCmd("type summary add --summary-string \"${var.m_some_text}\" DeepData_5")
+
+ self.expect('fr var data2.m_child4.m_child2.m_child2',
+ substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"'])
+
+ self.expect('fr var data2.m_child4.m_child2.m_child2 --no-summary-depth',
+ substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = {',
+ 'm_some_text = "Just a test"',
+ '}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp
new file mode 100644
index 000000000000..82ffb2c20d47
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp
@@ -0,0 +1,57 @@
+#include <string>
+
+struct DeepData_5
+{
+ std::string m_some_text;
+ DeepData_5() :
+ m_some_text("Just a test") {}
+};
+
+struct DeepData_4
+{
+ DeepData_5 m_child1;
+ DeepData_5 m_child2;
+ DeepData_5 m_child3;
+};
+
+struct DeepData_3
+{
+ DeepData_4& m_child1;
+ DeepData_4 m_child2;
+
+ DeepData_3() : m_child1(* (new DeepData_4())), m_child2(DeepData_4()) {}
+};
+
+struct DeepData_2
+{
+ DeepData_3 m_child1;
+ DeepData_3 m_child2;
+ DeepData_3 m_child3;
+ DeepData_3 m_child4;
+};
+
+struct DeepData_1
+{
+ DeepData_2 *m_child1;
+
+ DeepData_1() :
+ m_child1(new DeepData_2())
+ {}
+};
+
+/*
+ type summary add -f "${var._M_dataplus._M_p}" std::string
+ type summary add -f "Level 1" "DeepData_1"
+ type summary add -f "Level 2" "DeepData_2" -e
+ type summary add -f "Level 3" "DeepData_3"
+ type summary add -f "Level 4" "DeepData_4"
+ type summary add -f "Level 5" "DeepData_5"
+ */
+
+int main()
+{
+ DeepData_1 data1;
+ DeepData_2 data2;
+
+ return 0; // Set break point at this line.
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
new file mode 100644
index 000000000000..ca8858dbad9b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
@@ -0,0 +1,348 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SmartArrayDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Test data formatter commands."""
+ self.build()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+# check that we are not looping here
+ self.runCmd("type summary add --summary-string \"${var%V}\" SomeData")
+
+ self.expect("frame variable data",
+ substrs = ['SomeData @ 0x'])
+# ${var%s}
+ self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\"")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strarr",
+ substrs = ['arr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strarr",
+ substrs = ['arr = \"',
+ 'Nested Hello world!'])
+
+# ${var%c}
+ self.runCmd("type summary add --summary-string \"ptr = ${var%c}\" \"char *\"")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strarr",
+ substrs = ['arr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strarr",
+ substrs = ['arr = \"',
+ 'Nested Hello world!'])
+
+# ${var%char[]}
+ self.runCmd("type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strarr",
+ substrs = ['arr = ',
+ 'Nested Hello world!'])
+
+ self.expect("p strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strarr",
+ substrs = ['arr = ',
+ 'Nested Hello world!'])
+
+ self.runCmd("type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+# ${var%a}
+ self.runCmd("type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"")
+
+ self.expect("frame variable strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strarr",
+ substrs = ['arr = ',
+ 'Nested Hello world!'])
+
+ self.expect("p strarr",
+ substrs = ['arr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strarr",
+ substrs = ['arr = ',
+ 'Nested Hello world!'])
+
+ self.runCmd("type summary add --summary-string \"ptr = ${var%a}\" \"char *\"")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strptr",
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strptr",
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.runCmd("type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"")
+
+# I do not know the size of the data, but you are asking for a full array slice..
+# use the ${var%char[]} to obtain a string as result
+ self.expect("frame variable strptr", matching=False,
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("frame variable other.strptr", matching=False,
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+ self.expect("p strptr", matching=False,
+ substrs = ['ptr = \"',
+ 'Hello world!'])
+
+ self.expect("p other.strptr", matching=False,
+ substrs = ['ptr = \"',
+ 'Nested Hello world!'])
+
+# You asked an array-style printout...
+ self.runCmd("type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"")
+
+ self.expect("frame variable strptr",
+ substrs = ['ptr = ',
+ '[{H},{e}]'])
+
+ self.expect("frame variable other.strptr",
+ substrs = ['ptr = ',
+ '[{N},{e}]'])
+
+ self.expect("p strptr",
+ substrs = ['ptr = ',
+ '[{H},{e}]'])
+
+ self.expect("p other.strptr",
+ substrs = ['ptr = ',
+ '[{N},{e}]'])
+
+# using [] is required here
+ self.runCmd("type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"")
+
+ self.expect("frame variable intarr",matching=False,
+ substrs = ['0x00000001,0x00000001,0x00000002,0x00000003,0x00000005'])
+
+ self.expect("frame variable other.intarr", matching=False,
+ substrs = ['0x00000009,0x00000008,0x00000007,0x00000006,0x00000005'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"")
+
+ self.expect("frame variable intarr",
+ substrs = ['intarr = arr =',
+ '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005'])
+
+ self.expect("frame variable other.intarr",
+ substrs = ['intarr = arr =',
+ '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005'])
+
+# printing each array item as an array
+ self.runCmd("type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"")
+
+ self.expect("frame variable intarr",
+ substrs = ['intarr = arr =',
+ '{0x00000001},{0x00000001},{0x00000002},{0x00000003},{0x00000005}'])
+
+ self.expect("frame variable other.intarr",
+ substrs = ['intarr = arr = ',
+ '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}'])
+
+# printing full array as an array
+ self.runCmd("type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"")
+
+ self.expect("frame variable intarr",
+ substrs = ['intarr = arr =',
+ '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005'])
+
+ self.expect("frame variable other.intarr",
+ substrs = ['intarr = arr =',
+ '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005'])
+
+# printing each array item as an array
+ self.runCmd("type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"")
+
+ self.expect("frame variable flarr",
+ substrs = ['flarr = arr =',
+ '{78.5},{77.25},{78},{76.125},{76.75},{76.875},{77}'])
+
+ self.expect("frame variable other.flarr",
+ substrs = ['flarr = arr = ',
+ '{25.5},{25.25},{25.125},{26.75},{27.375},{27.5},{26.125}'])
+
+# printing full array as an array
+ self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"")
+
+ self.expect("frame variable flarr",
+ substrs = ['flarr = arr =',
+ '78.5,77.25,78,76.125,76.75,76.875,77'])
+
+ self.expect("frame variable other.flarr",
+ substrs = ['flarr = arr =',
+ '25.5,25.25,25.125,26.75,27.375,27.5,26.125'])
+
+# using array smart summary strings for pointers should make no sense
+ self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"")
+ self.runCmd("type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"")
+
+ self.expect("frame variable flptr", matching=False,
+ substrs = ['78.5,77.25,78,76.125,76.75,76.875,77'])
+
+ self.expect("frame variable intptr", matching=False,
+ substrs = ['1,1,2,3,5'])
+
+# use y and Y
+ self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"")
+ self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"")
+
+ self.expect("frame variable flarr",
+ substrs = ['flarr = arr =',
+ '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42'])
+
+ self.expect("frame variable other.flarr",
+ substrs = ['flarr = arr =',
+ '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41'])
+
+ self.expect("frame variable intarr",
+ substrs = ['intarr = arr =',
+ '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00'])
+
+ self.expect("frame variable other.intarr",
+ substrs = ['intarr = arr = ',
+ '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00'])
+
+ self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"")
+ self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"")
+
+ self.expect("frame variable flarr",
+ substrs = ['flarr = arr =',
+ '00 00 9d 42 ...B,00 80 9a 42 ...B,00 00 9c 42 ...B,00 40 98 42 .@.B,00 80 99 42 ...B,00 c0 99 42 ...B,00 00 9a 42 ...B'])
+
+ self.expect("frame variable other.flarr",
+ substrs = ['flarr = arr =',
+ '00 00 cc 41 ...A,00 00 ca 41 ...A,00 00 c9 41 ...A,00 00 d6 41 ...A,00 00 db 41 ...A,00 00 dc 41 ...A,00 00 d1 41 ...A'])
+
+ self.expect("frame variable intarr",
+ substrs = ['intarr = arr =',
+ '....,01 00 00 00',
+ '....,05 00 00 00'])
+
+ self.expect("frame variable other.intarr",
+ substrs = ['intarr = arr = ',
+ '09 00 00 00',
+ '....,07 00 00 00'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp
new file mode 100644
index 000000000000..9279e414be31
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp
@@ -0,0 +1,65 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+struct SomeData
+{
+ int x;
+};
+
+struct SomeOtherData
+{
+ char strarr[32];
+ char *strptr;
+ int intarr[5];
+ float flarr[7];
+
+ SomeOtherData()
+ {
+ strcpy(strarr,"Nested Hello world!");
+ strptr = new char[128];
+ strcpy(strptr,"Nested Hello world!");
+ intarr[0] = 9;
+ intarr[1] = 8;
+ intarr[2] = 7;
+ intarr[3] = 6;
+ intarr[4] = 5;
+
+ flarr[0] = 25.5;
+ flarr[1] = 25.25;
+ flarr[2] = 25.125;
+ flarr[3] = 26.75;
+ flarr[4] = 27.375;
+ flarr[5] = 27.5;
+ flarr[6] = 26.125;
+ }
+};
+
+int main (int argc, const char * argv[])
+{
+ char strarr[32] = "Hello world!";
+ char *strptr = NULL;
+ strptr = "Hello world!";
+ int intarr[5] = {1,1,2,3,5};
+ float flarr[7] = {78.5,77.25,78.0,76.125,76.75,76.875,77.0};
+
+ SomeData data;
+
+ SomeOtherData other;
+
+ float* flptr = flarr;
+ int* intptr = intarr;
+
+ return 0; // Set break point at this line.
+
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
new file mode 100644
index 000000000000..d37bef7dc5cc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile
@@ -0,0 +1,4 @@
+LEVEL = ../../../../../make
+CXX_SOURCES := main.cpp
+CXXFLAGS += -std=c++11
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
new file mode 100644
index 000000000000..e01f1b6679fc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
@@ -0,0 +1,40 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class InitializerListTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows # libc++ not ported to Windows yet
+ @skipIfGcc
+ @expectedFailureLinux # fails on clang 3.5 and tot
+ def test(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable ili", substrs = ['[1] = 2','[4] = 5'])
+ self.expect("frame variable ils", substrs = ['[4] = "surprise it is a long string!! yay!!"'])
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp
new file mode 100644
index 000000000000..9109a20cb510
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp
@@ -0,0 +1,21 @@
+//===-- main.cpp --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <string>
+#include <vector>
+#include <initializer_list>
+
+int main ()
+{
+ std::initializer_list<int> ili{1,2,3,4,5};
+ std::initializer_list<std::string> ils{"1","2","3","4","surprise it is a long string!! yay!!"};
+
+ return 0; // Set break point at this line.
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
new file mode 100644
index 000000000000..a87a2ed2d434
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
@@ -0,0 +1,66 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxIteratorDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that libc++ iterators format properly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.expect('frame variable ivI', substrs = ['item = 3'])
+ self.expect('expr ivI', substrs = ['item = 3'])
+
+ self.expect('frame variable iimI', substrs = ['first = 0','second = 12'])
+ self.expect('expr iimI', substrs = ['first = 0','second = 12'])
+
+ self.expect('frame variable simI', substrs = ['first = "world"','second = 42'])
+ self.expect('expr simI', substrs = ['first = "world"','second = 42'])
+
+ self.expect('frame variable svI', substrs = ['item = "hello"'])
+ self.expect('expr svI', substrs = ['item = "hello"'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
new file mode 100644
index 000000000000..97b37851f53d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
@@ -0,0 +1,42 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <map>
+#include <vector>
+
+typedef std::map<int, int> intint_map;
+typedef std::map<std::string, int> strint_map;
+
+typedef std::vector<int> int_vector;
+typedef std::vector<std::string> string_vector;
+
+typedef intint_map::iterator iimter;
+typedef strint_map::iterator simter;
+
+typedef int_vector::iterator ivter;
+typedef string_vector::iterator svter;
+
+int main()
+{
+ intint_map iim;
+ iim[0] = 12;
+
+ strint_map sim;
+ sim["world"] = 42;
+
+ int_vector iv;
+ iv.push_back(3);
+
+ string_vector sv;
+ sv.push_back("hello");
+
+ iimter iimI = iim.begin();
+ simter simI = sim.begin();
+
+ ivter ivI = iv.begin();
+ svter svI = sv.begin();
+
+ return 0; // Set break point at this line.
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
new file mode 100644
index 000000000000..18ee31a86106
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
@@ -0,0 +1,186 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time, re
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxListDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+ self.line2 = line_number('main.cpp', '// Set second break point at this line.')
+ self.line3 = line_number('main.cpp', '// Set third break point at this line.')
+ self.line4 = line_number('main.cpp', '// Set fourth break point at this line.')
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=-1)
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=-1)
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line4, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("frame variable numbers_list --show-types")
+ self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e")
+ self.runCmd("type format add -f hex int")
+
+ self.expect("frame variable numbers_list --raw", matching=False,
+ substrs = ['list has 0 items',
+ '{}'])
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 0 items',
+ '{}'])
+
+ self.expect("p numbers_list",
+ substrs = ['list has 0 items',
+ '{}'])
+
+ self.runCmd("n")
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 1 items',
+ '[0] = ',
+ '0x12345678'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 4 items',
+ '[0] = ',
+ '0x12345678',
+ '[1] =',
+ '0x11223344',
+ '[2] =',
+ '0xbeeffeed',
+ '[3] =',
+ '0x00abba00'])
+
+ self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 6 items',
+ '[0] = ',
+ '0x12345678',
+ '0x11223344',
+ '0xbeeffeed',
+ '0x00abba00',
+ '[4] =',
+ '0x0abcdef0',
+ '[5] =',
+ '0x0cab0cab'])
+
+ self.expect("p numbers_list",
+ substrs = ['list has 6 items',
+ '[0] = ',
+ '0x12345678',
+ '0x11223344',
+ '0xbeeffeed',
+ '0x00abba00',
+ '[4] =',
+ '0x0abcdef0',
+ '[5] =',
+ '0x0cab0cab'])
+
+ # check access-by-index
+ self.expect("frame variable numbers_list[0]",
+ substrs = ['0x12345678']);
+ self.expect("frame variable numbers_list[1]",
+ substrs = ['0x11223344']);
+
+ self.runCmd("n")
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 0 items',
+ '{}'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['list has 4 items',
+ '[0] = ', '1',
+ '[1] = ', '2',
+ '[2] = ', '3',
+ '[3] = ', '4'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
+
+ self.runCmd("type format delete int")
+
+ self.runCmd("c")
+
+ self.expect("frame variable text_list",
+ substrs = ['list has 3 items',
+ '[0]', 'goofy',
+ '[1]', 'is',
+ '[2]', 'smart'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")
+
+ self.expect("p text_list",
+ substrs = ['list has 3 items',
+ '\"goofy\"',
+ '\"is\"',
+ '\"smart\"'])
+
+ self.runCmd("n")
+
+ # check access-by-index
+ self.expect("frame variable text_list[0]",
+ substrs = ['goofy']);
+ self.expect("frame variable text_list[3]",
+ substrs = ['!!!']);
+
+ self.runCmd("continue")
+
+ # check that the list provider correctly updates if elements move
+ countingList = self.frame().FindVariable("countingList")
+ countingList.SetPreferDynamicValue(True)
+ countingList.SetPreferSyntheticValue(True)
+
+ self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141")
+ self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141")
+
+ self.runCmd("continue")
+
+ self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "uniqued list[0] == 3141")
+ self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, "uniqued list[1] == 3142")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/Makefile
new file mode 100644
index 000000000000..a5dabdb6349d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
new file mode 100644
index 000000000000..167cb2b887af
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
@@ -0,0 +1,54 @@
+"""
+Test that the debugger handles loops in std::list (which can appear as a result of e.g. memory
+corruption).
+"""
+
+from __future__ import print_function
+
+
+
+import os, time, re
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxListDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["pyapi"])
+ def test_with_run_command(self):
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target and target.IsValid(), "Target is valid")
+
+ file_spec = lldb.SBFileSpec ("main.cpp", False)
+ breakpoint1 = target.BreakpointCreateBySourceRegex('// Set break point at this line.', file_spec)
+ self.assertTrue(breakpoint1 and breakpoint1.IsValid())
+ breakpoint2 = target.BreakpointCreateBySourceRegex('// Set second break point at this line.', file_spec)
+ self.assertTrue(breakpoint2 and breakpoint2.IsValid())
+
+ # Run the program, it should stop at breakpoint 1.
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ lldbutil.skip_if_library_missing(self, target, lldbutil.PrintableRegex("libc\+\+"))
+ self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
+ self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
+
+ # verify our list is displayed correctly
+ self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[5] = 6'])
+
+ # Continue to breakpoint 2.
+ process.Continue()
+ self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
+ self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1)
+
+ # The list is now inconsistent. However, we should be able to get the first three
+ # elements at least (and most importantly, not crash).
+ self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3'])
+
+ # Run to completion.
+ process.Continue()
+ self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp
new file mode 100644
index 000000000000..6a1266528d5e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp
@@ -0,0 +1,30 @@
+// Evil hack: To simulate memory corruption, we want to fiddle with some internals of std::list.
+// Make those accessible to us.
+#define private public
+#define protected public
+
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <list>
+
+#include <assert.h>
+
+typedef std::list<int> int_list;
+
+int main()
+{
+#ifdef LLDB_USING_LIBCPP
+ int_list *numbers_list = new int_list{1,2,3,4,5,6,7,8,9,10};
+
+ auto *third_elem = numbers_list->__end_.__next_->__next_->__next_; // Set break point at this line.
+ assert(third_elem->__value_ == 3);
+ auto *fifth_elem = third_elem->__next_->__next_;
+ assert(fifth_elem->__value_ == 5);
+ fifth_elem->__next_ = third_elem;
+#endif
+
+ // Any attempt to free the list will probably crash the program. Let's just leak it.
+ return 0; // Set second break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp
new file mode 100644
index 000000000000..4f2bd74495a9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp
@@ -0,0 +1,43 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <list>
+
+
+typedef std::list<int> int_list;
+typedef std::list<std::string> string_list;
+
+int main()
+{
+ int_list numbers_list;
+
+ (numbers_list.push_back(0x12345678)); // Set break point at this line.
+ (numbers_list.push_back(0x11223344));
+ (numbers_list.push_back(0xBEEFFEED));
+ (numbers_list.push_back(0x00ABBA00));
+ (numbers_list.push_back(0x0ABCDEF0));
+ (numbers_list.push_back(0x0CAB0CAB));
+
+ numbers_list.clear();
+
+ (numbers_list.push_back(1));
+ (numbers_list.push_back(2));
+ (numbers_list.push_back(3));
+ (numbers_list.push_back(4));
+
+ string_list text_list;
+ (text_list.push_back(std::string("goofy")));
+ (text_list.push_back(std::string("is")));
+ (text_list.push_back(std::string("smart")));
+
+ (text_list.push_back(std::string("!!!"))); // Set second break point at this line.
+
+ std::list<int> countingList = {3141, 3142, 3142,3142,3142, 3142, 3142, 3141};
+ countingList.sort();
+ countingList.unique(); // Set third break point at this line.
+ countingList.size(); // Set fourth break point at this line.
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
new file mode 100644
index 000000000000..70a98f9c2cae
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -0,0 +1,298 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxMapDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.expect('frame variable ii',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ii',
+ substrs = ['size=2',
+ '[0] = ',
+ 'first = 0',
+ 'second = 0',
+ '[1] = ',
+ 'first = 1',
+ 'second = 1'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ii',
+ substrs = ['size=4',
+ '[2] = ',
+ 'first = 2',
+ 'second = 0',
+ '[3] = ',
+ 'first = 3',
+ 'second = 1'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable ii",
+ substrs = ['size=8',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ self.expect("p ii",
+ substrs = ['size=8',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ # check access-by-index
+ self.expect("frame variable ii[0]",
+ substrs = ['first = 0',
+ 'second = 0']);
+ self.expect("frame variable ii[3]",
+ substrs = ['first =',
+ 'second =']);
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ii[8]", matching=False, error=True,
+ # substrs = ['1234567'])
+
+ self.runCmd("continue");
+
+ self.expect('frame variable ii',
+ substrs = ['size=0',
+ '{}'])
+
+ self.expect('frame variable si',
+ substrs = ['size=0',
+ '{}'])
+
+ self.runCmd("continue");
+
+ self.expect('frame variable si',
+ substrs = ['size=1',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable si",
+ substrs = ['size=4',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3'])
+
+ self.expect("p si",
+ substrs = ['size=4',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable si[0]",
+ substrs = ['first = ', 'one',
+ 'second = 1']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression si[0]", matching=False, error=True,
+ # substrs = ['first = ', 'zero'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable si',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable is',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable is",
+ substrs = ['size=4',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ self.expect("p is",
+ substrs = ['size=4',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable is[0]",
+ substrs = ['first = ',
+ 'second =']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression is[0]", matching=False, error=True,
+ # substrs = ['first = ', 'goofy'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable is',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ss',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable ss",
+ substrs = ['size=3',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"'])
+
+ self.expect("p ss",
+ substrs = ['size=3',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable ss[2]",
+ substrs = ['gatto', 'cat']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ss[3]", matching=False, error=True,
+ # substrs = ['gatto'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ss',
+ substrs = ['size=0',
+ '{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
new file mode 100644
index 000000000000..6247ca8b2412
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
@@ -0,0 +1,77 @@
+#include <string>
+#include <map>
+
+#define intint_map std::map<int, int>
+#define strint_map std::map<std::string, int>
+#define intstr_map std::map<int, std::string>
+#define strstr_map std::map<std::string, std::string>
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+ if (arg < 0)
+ arg = 0;
+ if (!arg)
+ arg = 1;
+ g_the_foo += arg;
+ return g_the_foo;
+}
+
+int main()
+{
+ intint_map ii;
+
+ ii[0] = 0; // Set break point at this line.
+ ii[1] = 1;
+ thefoo_rw(1); // Set break point at this line.
+ ii[2] = 0;
+ ii[3] = 1;
+ thefoo_rw(1); // Set break point at this line.
+ ii[4] = 0;
+ ii[5] = 1;
+ ii[6] = 0;
+ ii[7] = 1;
+ thefoo_rw(1); // Set break point at this line.
+ ii[85] = 1234567;
+
+ ii.clear();
+
+ strint_map si;
+ thefoo_rw(1); // Set break point at this line.
+
+ si["zero"] = 0;
+ thefoo_rw(1); // Set break point at this line.
+ si["one"] = 1;
+ si["two"] = 2;
+ si["three"] = 3;
+ thefoo_rw(1); // Set break point at this line.
+ si["four"] = 4;
+
+ si.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ intstr_map is;
+ thefoo_rw(1); // Set break point at this line.
+ is[85] = "goofy";
+ is[1] = "is";
+ is[2] = "smart";
+ is[3] = "!!!";
+ thefoo_rw(1); // Set break point at this line.
+
+ is.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ strstr_map ss;
+ thefoo_rw(1); // Set break point at this line.
+
+ ss["ciao"] = "hello";
+ ss["casa"] = "house";
+ ss["gatto"] = "cat";
+ thefoo_rw(1); // Set break point at this line.
+ ss["a Mac.."] = "..is always a Mac!";
+
+ ss.clear();
+ thefoo_rw(1); // Set break point at this line.
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
new file mode 100644
index 000000000000..d0ca73d3251d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
@@ -0,0 +1,298 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxMultiMapDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows # libc++ not ported to Windows yet
+ @skipIfGcc
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.expect('frame variable ii',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ii',
+ substrs = ['size=2',
+ '[0] = ',
+ 'first = 0',
+ 'second = 0',
+ '[1] = ',
+ 'first = 1',
+ 'second = 1'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ii',
+ substrs = ['size=4',
+ '[2] = ',
+ 'first = 2',
+ 'second = 0',
+ '[3] = ',
+ 'first = 3',
+ 'second = 1'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable ii",
+ substrs = ['size=8',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ self.expect("p ii",
+ substrs = ['size=8',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ # check access-by-index
+ self.expect("frame variable ii[0]",
+ substrs = ['first = 0',
+ 'second = 0']);
+ self.expect("frame variable ii[3]",
+ substrs = ['first =',
+ 'second =']);
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ii[8]", matching=False, error=True,
+ # substrs = ['1234567'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ii',
+ substrs = ['size=0',
+ '{}'])
+
+ self.expect('frame variable si',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable si',
+ substrs = ['size=1',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable si",
+ substrs = ['size=4',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3'])
+
+ self.expect("p si",
+ substrs = ['size=4',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable si[0]",
+ substrs = ['first = ', 'one',
+ 'second = 1']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression si[0]", matching=False, error=True,
+ # substrs = ['first = ', 'zero'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable si',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable is',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable is",
+ substrs = ['size=4',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ self.expect("p is",
+ substrs = ['size=4',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable is[0]",
+ substrs = ['first = ',
+ 'second =']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression is[0]", matching=False, error=True,
+ # substrs = ['first = ', 'goofy'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable is',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ss',
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable ss",
+ substrs = ['size=3',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"'])
+
+ self.expect("p ss",
+ substrs = ['size=3',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
+
+ # check access-by-index
+ self.expect("frame variable ss[2]",
+ substrs = ['gatto', 'cat']);
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ss[3]", matching=False, error=True,
+ # substrs = ['gatto'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect('frame variable ss',
+ substrs = ['size=0',
+ '{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp
new file mode 100644
index 000000000000..e8385994125d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp
@@ -0,0 +1,77 @@
+#include <string>
+#include <map>
+
+#define intint_map std::multimap<int, int>
+#define strint_map std::multimap<std::string, int>
+#define intstr_map std::multimap<int, std::string>
+#define strstr_map std::multimap<std::string, std::string>
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+ if (arg < 0)
+ arg = 0;
+ if (!arg)
+ arg = 1;
+ g_the_foo += arg;
+ return g_the_foo;
+}
+
+int main()
+{
+ intint_map ii;
+
+ ii.emplace(0,0); // Set break point at this line.
+ ii.emplace(1,1);
+ thefoo_rw(1); // Set break point at this line.
+ ii.emplace(2,0);
+ ii.emplace(3,1);
+ thefoo_rw(1); // Set break point at this line.
+ ii.emplace(4,0);
+ ii.emplace(5,1);
+ ii.emplace(6,0);
+ ii.emplace(7,1);
+ thefoo_rw(1); // Set break point at this line.
+ ii.emplace(85,1234567);
+
+ ii.clear();
+
+ strint_map si;
+ thefoo_rw(1); // Set break point at this line.
+
+ si.emplace("zero",0);
+ thefoo_rw(1); // Set break point at this line.
+ si.emplace("one",1);
+ si.emplace("two",2);
+ si.emplace("three",3);
+ thefoo_rw(1); // Set break point at this line.
+ si.emplace("four",4);
+
+ si.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ intstr_map is;
+ thefoo_rw(1); // Set break point at this line.
+ is.emplace(85,"goofy");
+ is.emplace(1,"is");
+ is.emplace(2,"smart");
+ is.emplace(3,"!!!");
+ thefoo_rw(1); // Set break point at this line.
+
+ is.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ strstr_map ss;
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.emplace("ciao","hello");
+ ss.emplace("casa","house");
+ ss.emplace("gatto","cat");
+ thefoo_rw(1); // Set break point at this line.
+ ss.emplace("a Mac..","..is always a Mac!");
+
+ ss.clear();
+ thefoo_rw(1); // Set break point at this line.
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
new file mode 100644
index 000000000000..384f6130d0c0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
@@ -0,0 +1,69 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxMultiSetDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"])
+ self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"])
+ self.expect("frame variable ii[2]",substrs = [" = 2"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ self.expect("frame variable ss",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"'])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"'])
+ self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"'])
+ self.expect("frame variable ss[2]",substrs = [' = "b"'])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
new file mode 100644
index 000000000000..1e1dd3b16039
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
@@ -0,0 +1,57 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <set>
+
+typedef std::multiset<int> intset;
+typedef std::multiset<std::string> stringset;
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+ if (arg < 0)
+ arg = 0;
+ if (!arg)
+ arg = 1;
+ g_the_foo += arg;
+ return g_the_foo;
+}
+
+int main()
+{
+ intset ii;
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.insert(0);
+ ii.insert(1);
+ ii.insert(2);
+ ii.insert(3);
+ ii.insert(4);
+ ii.insert(5);
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.insert(6);
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ stringset ss;
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.insert("a");
+ ss.insert("a very long string is right here");
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.insert("b");
+ ss.insert("c");
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.erase("b");
+ thefoo_rw(1); // Set break point at this line.
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py
new file mode 100644
index 000000000000..fcbfb0a8f0ed
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py
@@ -0,0 +1,69 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxSetDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"])
+ self.expect("frame variable ii[2]",substrs = [" = 2"])
+ self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ii",substrs = ["size=0","{}"])
+ self.expect("frame variable ss",substrs = ["size=0","{}"])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"'])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"'])
+ self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"'])
+ self.expect("frame variable ss[2]",substrs = [' = "b"'])
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+ self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp
new file mode 100644
index 000000000000..cc3033ef26e4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp
@@ -0,0 +1,57 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <set>
+
+typedef std::set<int> intset;
+typedef std::set<std::string> stringset;
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+ if (arg < 0)
+ arg = 0;
+ if (!arg)
+ arg = 1;
+ g_the_foo += arg;
+ return g_the_foo;
+}
+
+int main()
+{
+ intset ii;
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.insert(0);
+ ii.insert(1);
+ ii.insert(2);
+ ii.insert(3);
+ ii.insert(4);
+ ii.insert(5);
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.insert(6);
+ thefoo_rw(1); // Set break point at this line.
+
+ ii.clear();
+ thefoo_rw(1); // Set break point at this line.
+
+ stringset ss;
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.insert("a");
+ ss.insert("a very long string is right here");
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.insert("b");
+ ss.insert("c");
+ thefoo_rw(1); // Set break point at this line.
+
+ ss.erase("b");
+ thefoo_rw(1); // Set break point at this line.
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
new file mode 100644
index 000000000000..942124255f55
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -0,0 +1,86 @@
+#coding=utf8
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxStringDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect("frame variable",
+ substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"',
+ '(std::__1::wstring) S = L"!!!!"',
+ '(const wchar_t *) mazeltov = 0x','L"מזל טוב"',
+ '(std::__1::string) q = "hello world"',
+ '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
+ '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
+ '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
+
+ self.runCmd("n")
+
+ TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne");
+ summaryOptions = lldb.SBTypeSummaryOptions()
+ summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
+ uncappedSummaryStream = lldb.SBStream()
+ TheVeryLongOne.GetSummary(uncappedSummaryStream,summaryOptions)
+ uncappedSummary = uncappedSummaryStream.GetData()
+ self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string")
+ summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
+ cappedSummaryStream = lldb.SBStream()
+ TheVeryLongOne.GetSummary(cappedSummaryStream,summaryOptions)
+ cappedSummary = cappedSummaryStream.GetData()
+ self.assertTrue(cappedSummary.find("someText") <= 0, "cappedSummary includes the full string")
+
+ self.expect("frame variable",
+ substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"',
+ '(std::__1::wstring) S = L"!!!!!"',
+ '(const wchar_t *) mazeltov = 0x','L"מזל טוב"',
+ '(std::__1::string) q = "hello world"',
+ '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
+ '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
+ '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
new file mode 100644
index 000000000000..9ca0da39cfc8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
@@ -0,0 +1,15 @@
+#include <string>
+
+int main()
+{
+ std::wstring s(L"hello world! מזל טוב!");
+ std::wstring S(L"!!!!");
+ const wchar_t *mazeltov = L"מזל טוב";
+ std::string q("hello world");
+ std::string Q("quite a long std::strin with lots of info inside it");
+ std::string TheVeryLongOne("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890someText1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
+ std::string IHaveEmbeddedZeros("a\0b\0c\0d",7);
+ std::wstring IHaveEmbeddedZerosToo(L"hello world!\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監", 38);
+ S.assign(L"!!!!!"); // Set break point at this line.
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
new file mode 100644
index 000000000000..5e6ec2519323
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
@@ -0,0 +1,75 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxUnorderedDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows # libc++ not ported to Windows yet
+ @skipIfGcc
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('image list', substrs = self.getLibcPlusPlusLibs())
+
+ self.look_for_content_and_continue(
+ "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+ self.look_for_content_and_continue(
+ "mmap", ['size=6 {', 'first = 3', 'second = "this"',
+ 'first = 2', 'second = "hello"'])
+
+ self.look_for_content_and_continue(
+ "iset", ['size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
+
+ self.look_for_content_and_continue(
+ "sset", ['size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
+ '\[\d\] = "hello"'])
+
+ self.look_for_content_and_continue(
+ "imset", ['size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
+ '\[\d\] = 2', '\[\d\] = 1'])
+
+ self.look_for_content_and_continue(
+ "smset",
+ ['size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
+ '(\[\d\] = "world"(\\n|.)+){2}'])
+
+ def look_for_content_and_continue(self, var_name, patterns):
+ self.expect( ("frame variable %s" % var_name), patterns=patterns)
+ self.runCmd("continue")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
new file mode 100644
index 000000000000..4e8a1a779c0c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
@@ -0,0 +1,84 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <unordered_map>
+#include <unordered_set>
+
+using std::string;
+
+#define intstr_map std::unordered_map<int, string>
+#define intstr_mmap std::unordered_multimap<int, string>
+
+#define int_set std::unordered_set<int>
+#define str_set std::unordered_set<string>
+#define int_mset std::unordered_multiset<int>
+#define str_mset std::unordered_multiset<string>
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1)
+{
+ if (arg < 0)
+ arg = 0;
+ if (!arg)
+ arg = 1;
+ g_the_foo += arg;
+ return g_the_foo;
+}
+
+int main()
+{
+ intstr_map map;
+ map.emplace(1,"hello");
+ map.emplace(2,"world");
+ map.emplace(3,"this");
+ map.emplace(4,"is");
+ map.emplace(5,"me");
+ thefoo_rw(); // Set break point at this line.
+
+ intstr_mmap mmap;
+ mmap.emplace(1,"hello");
+ mmap.emplace(2,"hello");
+ mmap.emplace(2,"world");
+ mmap.emplace(3,"this");
+ mmap.emplace(3,"this");
+ mmap.emplace(3,"this");
+ thefoo_rw(); // Set break point at this line.
+
+ int_set iset;
+ iset.emplace(1);
+ iset.emplace(2);
+ iset.emplace(3);
+ iset.emplace(4);
+ iset.emplace(5);
+ thefoo_rw(); // Set break point at this line.
+
+ str_set sset;
+ sset.emplace("hello");
+ sset.emplace("world");
+ sset.emplace("this");
+ sset.emplace("is");
+ sset.emplace("me");
+ thefoo_rw(); // Set break point at this line.
+
+ int_mset imset;
+ imset.emplace(1);
+ imset.emplace(2);
+ imset.emplace(2);
+ imset.emplace(3);
+ imset.emplace(3);
+ imset.emplace(3);
+ thefoo_rw(); // Set break point at this line.
+
+ str_mset smset;
+ smset.emplace("hello");
+ smset.emplace("world");
+ smset.emplace("world");
+ smset.emplace("is");
+ smset.emplace("is");
+ thefoo_rw(); // Set break point at this line.
+
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile
new file mode 100644
index 000000000000..637fa7e80bfd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
new file mode 100644
index 000000000000..9771a819aa6b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
@@ -0,0 +1,58 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxVBoolDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows.
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect("frame variable vBool",
+ substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true'])
+
+ self.expect("expr vBool",
+ substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
new file mode 100644
index 000000000000..7b9956ed36ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
@@ -0,0 +1,69 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+
+#include <vector>
+
+int main()
+{
+ std::vector<bool> vBool;
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(true);
+
+ return 0; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile
new file mode 100644
index 000000000000..1f609a41d908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+include $(LEVEL)/Makefile.rules
+CXXFLAGS += -O0
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
new file mode 100644
index 000000000000..f8cd65be0931
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -0,0 +1,180 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LibcxxVectorDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfGcc
+ @skipIfWindows # libc++ not ported to Windows yet
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
+
+ bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here"))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # empty vectors (and storage pointers SHOULD BOTH BE NULL..)
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=0'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ # first value added
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=1',
+ '[0] = 1',
+ '}'])
+
+ # add some more data
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=4',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '}'])
+
+ self.expect("p numbers",
+ substrs = ['$', 'size=4',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '}'])
+
+
+ # check access to synthetic children
+ self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect")
+ self.expect('frame variable numbers',
+ substrs = ['item 0 is 1']);
+
+ self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect")
+ self.expect('frame variable numbers',
+ substrs = ['item 0 is 1']);
+ # move on with synths
+ self.runCmd("type summary delete std::int_vect")
+ self.runCmd("type summary delete int_vect")
+
+ # add some more data
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=7',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '[4] = 12345',
+ '[5] = 123456',
+ '[6] = 1234567',
+ '}'])
+
+ self.expect("p numbers",
+ substrs = ['$', 'size=7',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '[4] = 12345',
+ '[5] = 123456',
+ '[6] = 1234567',
+ '}'])
+
+ # check access-by-index
+ self.expect("frame variable numbers[0]",
+ substrs = ['1']);
+ self.expect("frame variable numbers[1]",
+ substrs = ['12']);
+ self.expect("frame variable numbers[2]",
+ substrs = ['123']);
+ self.expect("frame variable numbers[3]",
+ substrs = ['1234']);
+
+ # clear out the vector and see that we do the right thing once again
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=0'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ # first value added
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=1',
+ '[0] = 7',
+ '}'])
+
+ # check if we can display strings
+ self.expect("frame variable strings",
+ substrs = ['goofy',
+ 'is',
+ 'smart'])
+
+ self.expect("p strings",
+ substrs = ['goofy',
+ 'is',
+ 'smart'])
+
+ # test summaries based on synthetic children
+ self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e")
+ self.expect("frame variable strings",
+ substrs = ['vector has 3 items',
+ 'goofy',
+ 'is',
+ 'smart'])
+
+ self.expect("p strings",
+ substrs = ['vector has 3 items',
+ 'goofy',
+ 'is',
+ 'smart'])
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable strings",
+ substrs = ['vector has 4 items'])
+
+ # check access-by-index
+ self.expect("frame variable strings[0]",
+ substrs = ['goofy']);
+ self.expect("frame variable strings[1]",
+ substrs = ['is']);
+
+ lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+ self.expect("frame variable strings",
+ substrs = ['vector has 0 items'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp
new file mode 100644
index 000000000000..a9aeacf90e43
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp
@@ -0,0 +1,35 @@
+#include <string>
+#ifdef _LIBCPP_INLINE_VISIBILITY
+#undef _LIBCPP_INLINE_VISIBILITY
+#endif
+#define _LIBCPP_INLINE_VISIBILITY
+#include <vector>
+typedef std::vector<int> int_vect;
+typedef std::vector<std::string> string_vect;
+
+int main()
+{
+ int_vect numbers;
+ (numbers.push_back(1)); // break here
+ (numbers.push_back(12)); // break here
+ (numbers.push_back(123));
+ (numbers.push_back(1234));
+ (numbers.push_back(12345)); // break here
+ (numbers.push_back(123456));
+ (numbers.push_back(1234567));
+
+ numbers.clear(); // break here
+
+ (numbers.push_back(7)); // break here
+
+ string_vect strings;
+ (strings.push_back(std::string("goofy")));
+ (strings.push_back(std::string("is")));
+ (strings.push_back(std::string("smart")));
+
+ (strings.push_back(std::string("!!!"))); // break here
+
+ strings.clear(); // break here
+
+ return 0; // break here
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
new file mode 100644
index 000000000000..7fe01d004f03
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
@@ -0,0 +1,15 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -O0
+USE_LIBSTDCPP := 1
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
new file mode 100644
index 000000000000..6742c9e71701
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
@@ -0,0 +1,62 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdIteratorDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfWindows # libstdcpp not ported to Windows
+ @expectedFailureIcc # llvm.org/pr15301 LLDB prints incorrect sizes of STL containers
+ def test_with_run_command(self):
+ """Test that libstdcpp iterators format properly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect('frame variable ivI', substrs = ['item = 3'])
+ self.expect('expr ivI', substrs = ['item = 3'])
+
+ self.expect('frame variable iimI', substrs = ['first = 0','second = 12'])
+ self.expect('expr iimI', substrs = ['first = 0','second = 12'])
+
+ self.expect('frame variable simI', substrs = ['first = "world"','second = 42'])
+ self.expect('expr simI', substrs = ['first = "world"','second = 42'])
+
+ self.expect('frame variable svI', substrs = ['item = "hello"'])
+ self.expect('expr svI', substrs = ['item = "hello"'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp
new file mode 100644
index 000000000000..d7b046c5bff8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp
@@ -0,0 +1,38 @@
+#include <string>
+#include <map>
+#include <vector>
+
+typedef std::map<int, int> intint_map;
+typedef std::map<std::string, int> strint_map;
+
+typedef std::vector<int> int_vector;
+typedef std::vector<std::string> string_vector;
+
+typedef intint_map::iterator iimter;
+typedef strint_map::iterator simter;
+
+typedef int_vector::iterator ivter;
+typedef string_vector::iterator svter;
+
+int main()
+{
+ intint_map iim;
+ iim[0] = 12;
+
+ strint_map sim;
+ sim["world"] = 42;
+
+ int_vector iv;
+ iv.push_back(3);
+
+ string_vector sv;
+ sv.push_back("hello");
+
+ iimter iimI = iim.begin();
+ simter simI = sim.begin();
+
+ ivter ivI = iv.begin();
+ svter svI = sv.begin();
+
+ return 0; // Set break point at this line.
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile
new file mode 100644
index 000000000000..7fe01d004f03
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile
@@ -0,0 +1,15 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -O0
+USE_LIBSTDCPP := 1
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py
new file mode 100644
index 000000000000..5147d18da0fe
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py
@@ -0,0 +1,188 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdListDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break at for the different tests.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+ self.optional_line = line_number('main.cpp', '// Optional break point at this line.')
+ self.final_line = line_number('main.cpp', '// Set final break point at this line.')
+
+ @skipIfWindows # libstdcpp not ported to Windows
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("frame variable numbers_list --show-types")
+
+ self.runCmd("type format add -f hex int")
+
+ self.expect("frame variable numbers_list --raw", matching=False,
+ substrs = ['size=0',
+ '{}'])
+ self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False,
+ substrs = ['size=0',
+ '{}'])
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=0',
+ '{}'])
+
+ self.expect("p numbers_list",
+ substrs = ['size=0',
+ '{}'])
+
+ self.runCmd("n")
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=1',
+ '[0] = ',
+ '0x12345678'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=4',
+ '[0] = ',
+ '0x12345678',
+ '[1] =',
+ '0x11223344',
+ '[2] =',
+ '0xbeeffeed',
+ '[3] =',
+ '0x00abba00'])
+
+ self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=6',
+ '[0] = ',
+ '0x12345678',
+ '0x11223344',
+ '0xbeeffeed',
+ '0x00abba00',
+ '[4] =',
+ '0x0abcdef0',
+ '[5] =',
+ '0x0cab0cab'])
+
+ self.expect("p numbers_list",
+ substrs = ['size=6',
+ '[0] = ',
+ '0x12345678',
+ '0x11223344',
+ '0xbeeffeed',
+ '0x00abba00',
+ '[4] =',
+ '0x0abcdef0',
+ '[5] =',
+ '0x0cab0cab'])
+
+ # check access-by-index
+ self.expect("frame variable numbers_list[0]",
+ substrs = ['0x12345678']);
+ self.expect("frame variable numbers_list[1]",
+ substrs = ['0x11223344']);
+
+ # but check that expression does not rely on us
+ self.expect("expression numbers_list[0]", matching=False, error=True,
+ substrs = ['0x12345678'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
+
+ self.runCmd("n")
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=0',
+ '{}'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable numbers_list",
+ substrs = ['size=4',
+ '[0] = ', '1',
+ '[1] = ', '2',
+ '[2] = ', '3',
+ '[3] = ', '4'])
+
+ self.runCmd("type format delete int")
+
+ self.runCmd("n")
+
+ self.expect("frame variable text_list",
+ substrs = ['size=0',
+ '{}'])
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1)
+
+ self.runCmd("c", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable text_list",
+ substrs = ['size=4',
+ '[0]', 'goofy',
+ '[1]', 'is',
+ '[2]', 'smart',
+ '[3]', '!!!'])
+
+ self.expect("p text_list",
+ substrs = ['size=4',
+ '\"goofy\"',
+ '\"is\"',
+ '\"smart\"',
+ '\"!!!\"'])
+
+ # check access-by-index
+ self.expect("frame variable text_list[0]",
+ substrs = ['goofy']);
+ self.expect("frame variable text_list[3]",
+ substrs = ['!!!']);
+
+ # but check that expression does not rely on us
+ self.expect("expression text_list[0]", matching=False, error=True,
+ substrs = ['goofy'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/main.cpp
new file mode 100644
index 000000000000..191acdcc97be
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/main.cpp
@@ -0,0 +1,34 @@
+#include <list>
+#include <string>
+
+typedef std::list<int> int_list;
+typedef std::list<std::string> string_list;
+
+int main()
+{
+ int_list numbers_list;
+
+ numbers_list.push_back(0x12345678); // Set break point at this line.
+ numbers_list.push_back(0x11223344);
+ numbers_list.push_back(0xBEEFFEED);
+ numbers_list.push_back(0x00ABBA00);
+ numbers_list.push_back(0x0ABCDEF0);
+ numbers_list.push_back(0x0CAB0CAB);
+
+ numbers_list.clear();
+
+ numbers_list.push_back(1);
+ numbers_list.push_back(2);
+ numbers_list.push_back(3);
+ numbers_list.push_back(4);
+
+ string_list text_list;
+ text_list.push_back(std::string("goofy")); // Optional break point at this line.
+ text_list.push_back(std::string("is"));
+ text_list.push_back(std::string("smart"));
+
+ text_list.push_back(std::string("!!!"));
+
+ return 0; // Set final break point at this line.
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile
new file mode 100644
index 000000000000..2c6c3cf72842
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile
@@ -0,0 +1,14 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBSTDCPP := 1
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
new file mode 100644
index 000000000000..e21c4e94c2c4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -0,0 +1,322 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdMapDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @expectedFailureIcc # llvm.org/pr15301: LLDB prints incorrect size of libstdc++ containers
+ @skipIfWindows # libstdcpp not ported to Windows
+ @skipIfFreeBSD
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("frame variable ii --show-types")
+
+ self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
+
+ self.expect('frame variable ii',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("c");
+
+ self.expect('frame variable ii',
+ substrs = ['map has 2 items',
+ '[0] = ',
+ 'first = 0',
+ 'second = 0',
+ '[1] = ',
+ 'first = 1',
+ 'second = 1'])
+
+ self.runCmd("c");
+
+ self.expect('frame variable ii',
+ substrs = ['map has 4 items',
+ '[2] = ',
+ 'first = 2',
+ 'second = 0',
+ '[3] = ',
+ 'first = 3',
+ 'second = 1'])
+
+ self.runCmd("c");
+
+ self.expect("frame variable ii",
+ substrs = ['map has 9 items',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ self.expect("p ii",
+ substrs = ['map has 9 items',
+ '[5] = ',
+ 'first = 5',
+ 'second = 0',
+ '[7] = ',
+ 'first = 7',
+ 'second = 1'])
+
+ # check access-by-index
+ self.expect("frame variable ii[0]",
+ substrs = ['first = 0',
+ 'second = 0']);
+ self.expect("frame variable ii[3]",
+ substrs = ['first =',
+ 'second =']);
+
+ self.expect("frame variable ii[8]", matching=True,
+ substrs = ['1234567'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ii[8]", matching=False, error=True,
+ # substrs = ['1234567'])
+
+ self.runCmd("c")
+
+ self.expect('frame variable ii',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("frame variable si --show-types")
+
+ self.expect('frame variable si',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("c")
+
+ self.expect('frame variable si',
+ substrs = ['map has 1 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0'])
+
+ self.runCmd("c");
+
+ self.expect("frame variable si",
+ substrs = ['map has 5 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3',
+ '[4] = ',
+ 'first = \"four\"',
+ 'second = 4'])
+
+ self.expect("p si",
+ substrs = ['map has 5 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3',
+ '[4] = ',
+ 'first = \"four\"',
+ 'second = 4'])
+
+ # check access-by-index
+ self.expect("frame variable si[0]",
+ substrs = ['first = ', 'four',
+ 'second = 4']);
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression si[0]", matching=False, error=True,
+ # substrs = ['first = ', 'zero'])
+
+ self.runCmd("c")
+
+ self.expect('frame variable si',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("frame variable is --show-types")
+
+ self.expect('frame variable is',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("c");
+
+ self.expect("frame variable is",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ self.expect("p is",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 85',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ # check access-by-index
+ self.expect("frame variable is[0]",
+ substrs = ['first = ',
+ 'second =']);
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression is[0]", matching=False, error=True,
+ # substrs = ['first = ', 'goofy'])
+
+ self.runCmd("c")
+
+ self.expect('frame variable is',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("frame variable ss --show-types")
+
+ self.expect('frame variable ss',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("c");
+
+ self.expect("frame variable ss",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"',
+ '[3] = ',
+ 'second = \"..is always a Mac!\"',
+ 'first = \"a Mac..\"'])
+
+ self.expect("p ss",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"',
+ '[3] = ',
+ 'second = \"..is always a Mac!\"',
+ 'first = \"a Mac..\"'])
+
+ # check access-by-index
+ self.expect("frame variable ss[3]",
+ substrs = ['gatto', 'cat']);
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
+
+ # check that the expression parser does not make use of
+ # synthetic children instead of running code
+ # TOT clang has a fix for this, which makes the expression command here succeed
+ # since this would make the test fail or succeed depending on clang version in use
+ # this is safer commented for the time being
+ #self.expect("expression ss[3]", matching=False, error=True,
+ # substrs = ['gatto'])
+
+ self.runCmd("c")
+
+ self.expect('frame variable ss',
+ substrs = ['map has 0 items',
+ '{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp
new file mode 100644
index 000000000000..568c35efe072
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp
@@ -0,0 +1,55 @@
+#include <map>
+#include <string>
+
+#define intint_map std::map<int, int>
+#define strint_map std::map<std::string, int>
+#define intstr_map std::map<int, std::string>
+#define strstr_map std::map<std::string, std::string>
+
+
+int main()
+{
+ intint_map ii;
+
+ ii[0] = 0; // Set break point at this line.
+ ii[1] = 1;
+ ii[2] = 0;// Set break point at this line.
+ ii[3] = 1;
+ ii[4] = 0;// Set break point at this line.
+ ii[5] = 1;
+ ii[6] = 0;
+ ii[7] = 1;
+ ii[85] = 1234567;
+
+ ii.clear();// Set break point at this line.
+
+ strint_map si;
+
+ si["zero"] = 0;// Set break point at this line.
+ si["one"] = 1;// Set break point at this line.
+ si["two"] = 2;
+ si["three"] = 3;
+ si["four"] = 4;
+
+ si.clear();// Set break point at this line.
+
+ intstr_map is;
+
+ is[85] = "goofy";// Set break point at this line.
+ is[1] = "is";
+ is[2] = "smart";
+ is[3] = "!!!";
+
+ is.clear();// Set break point at this line.
+
+ strstr_map ss;
+
+ ss["ciao"] = "hello";// Set break point at this line.
+ ss["casa"] = "house";
+ ss["gatto"] = "cat";
+ ss["a Mac.."] = "..is always a Mac!";
+
+ ss.clear();// Set break point at this line.
+
+ return 0;// Set break point at this line.
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
new file mode 100644
index 000000000000..7fe01d004f03
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile
@@ -0,0 +1,15 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -O0
+USE_LIBSTDCPP := 1
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
new file mode 100644
index 000000000000..2d6af24c6afc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
@@ -0,0 +1,66 @@
+#coding=utf8
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdStringDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfWindows # libstdcpp not ported to Windows
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ var_s = self.frame().FindVariable('s')
+ var_S = self.frame().FindVariable('S')
+ var_mazeltov = self.frame().FindVariable('mazeltov')
+ var_q = self.frame().FindVariable('q')
+ var_Q = self.frame().FindVariable('Q')
+
+ self.assertTrue(var_s.GetSummary() == 'L"hello world! מזל טוב!"', "s summary wrong")
+ self.assertTrue(var_S.GetSummary() == 'L"!!!!"', "S summary wrong")
+ self.assertTrue(var_mazeltov.GetSummary() == 'L"מזל טוב"', "mazeltov summary wrong")
+ self.assertTrue(var_q.GetSummary() == '"hello world"', "q summary wrong")
+ self.assertTrue(var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', "Q summary wrong")
+
+ self.runCmd("next")
+
+ self.assertTrue(var_S.GetSummary() == 'L"!!!!!"', "new S summary wrong")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
new file mode 100644
index 000000000000..4a9b4fc7d0db
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
@@ -0,0 +1,12 @@
+#include <string>
+
+int main()
+{
+ std::wstring s(L"hello world! מזל טוב!");
+ std::wstring S(L"!!!!");
+ const wchar_t *mazeltov = L"מזל טוב";
+ std::string q("hello world");
+ std::string Q("quite a long std::strin with lots of info inside it");
+ S.assign(L"!!!!!"); // Set break point at this line.
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile
new file mode 100644
index 000000000000..2e8bcb9079bd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -O0
+USE_LIBSTDCPP := 1
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py
new file mode 100644
index 000000000000..9e73009aba83
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py
@@ -0,0 +1,58 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdVBoolDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @expectedFailureFreeBSD("llvm.org/pr20548") # fails to build on lab.llvm.org buildbot
+ @expectedFailureIcc # llvm.org/pr15301: lldb does not print the correct sizes of STL containers when building with ICC
+ @skipIfWindows # libstdcpp not ported to Windows.
+ @skipIfDarwin
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.expect("frame variable vBool",
+ substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true'])
+
+ self.expect("expr vBool",
+ substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp
new file mode 100644
index 000000000000..73956dd3fda3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp
@@ -0,0 +1,63 @@
+#include <vector>
+
+int main()
+{
+ std::vector<bool> vBool;
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(false);
+ vBool.push_back(true);
+ vBool.push_back(true);
+
+ return 0; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/Makefile
new file mode 100644
index 000000000000..88cb026aba1c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/Makefile
@@ -0,0 +1,15 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+CXXFLAGS := -O0
+USE_LIBSTDCPP := 1
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
new file mode 100644
index 000000000000..ed4313657e93
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
@@ -0,0 +1,207 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StdVectorDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ @skipIfFreeBSD
+ @expectedFailureIcc # llvm.org/pr15301 LLDB prints incorrect sizes of STL containers
+ @skipIfWindows # libstdcpp not ported to Windows
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # empty vectors (and storage pointers SHOULD BOTH BE NULL..)
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=0'])
+
+ self.runCmd("c")
+
+ # first value added
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=1',
+ '[0] = 1',
+ '}'])
+
+ # add some more data
+ self.runCmd("c");
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=4',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '}'])
+
+ self.expect("p numbers",
+ substrs = ['$', 'size=4',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '}'])
+
+
+ # check access to synthetic children
+ self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect")
+ self.expect('frame variable numbers',
+ substrs = ['item 0 is 1']);
+
+ self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect")
+ #import time
+ #time.sleep(19)
+ self.expect('frame variable numbers',
+ substrs = ['item 0 is 1']);
+ # move on with synths
+ self.runCmd("type summary delete std::int_vect")
+ self.runCmd("type summary delete int_vect")
+
+ # add some more data
+ self.runCmd("c");
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=7',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '[4] = 12345',
+ '[5] = 123456',
+ '[6] = 1234567',
+ '}'])
+
+ self.expect("p numbers",
+ substrs = ['$', 'size=7',
+ '[0] = 1',
+ '[1] = 12',
+ '[2] = 123',
+ '[3] = 1234',
+ '[4] = 12345',
+ '[5] = 123456',
+ '[6] = 1234567',
+ '}'])
+
+ # check access-by-index
+ self.expect("frame variable numbers[0]",
+ substrs = ['1']);
+ self.expect("frame variable numbers[1]",
+ substrs = ['12']);
+ self.expect("frame variable numbers[2]",
+ substrs = ['123']);
+ self.expect("frame variable numbers[3]",
+ substrs = ['1234']);
+
+ # but check that expression does not rely on us
+ # (when expression gets to call into STL code correctly, we will have to find
+ # another way to check this)
+ self.expect("expression numbers[6]", matching=False, error=True,
+ substrs = ['1234567'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("numbers").MightHaveChildren(), "numbers.MightHaveChildren() says False for non empty!")
+
+ # clear out the vector and see that we do the right thing once again
+ self.runCmd("c")
+
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=0'])
+
+ self.runCmd("c")
+
+ # first value added
+ self.expect("frame variable numbers",
+ substrs = ['numbers = size=1',
+ '[0] = 7',
+ '}'])
+
+ # check if we can display strings
+ self.runCmd("c")
+
+ self.expect("frame variable strings",
+ substrs = ['goofy',
+ 'is',
+ 'smart'])
+
+ self.expect("p strings",
+ substrs = ['goofy',
+ 'is',
+ 'smart'])
+
+ # test summaries based on synthetic children
+ self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e")
+ self.expect("frame variable strings",
+ substrs = ['vector has 3 items',
+ 'goofy',
+ 'is',
+ 'smart'])
+
+ self.expect("p strings",
+ substrs = ['vector has 3 items',
+ 'goofy',
+ 'is',
+ 'smart'])
+
+ self.runCmd("c");
+
+ self.expect("frame variable strings",
+ substrs = ['vector has 4 items'])
+
+ # check access-by-index
+ self.expect("frame variable strings[0]",
+ substrs = ['goofy']);
+ self.expect("frame variable strings[1]",
+ substrs = ['is']);
+
+ # but check that expression does not rely on us
+ # (when expression gets to call into STL code correctly, we will have to find
+ # another way to check this)
+ self.expect("expression strings[0]", matching=False, error=True,
+ substrs = ['goofy'])
+
+ # check that MightHaveChildren() gets it right
+ self.assertTrue(self.frame().FindVariable("strings").MightHaveChildren(), "strings.MightHaveChildren() says False for non empty!")
+
+ self.runCmd("c")
+
+ self.expect("frame variable strings",
+ substrs = ['vector has 0 items'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/main.cpp
new file mode 100644
index 000000000000..010917995e40
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/main.cpp
@@ -0,0 +1,31 @@
+#include <string>
+#include <vector>
+typedef std::vector<int> int_vect;
+typedef std::vector<std::string> string_vect;
+
+int main()
+{
+ int_vect numbers;
+ numbers.push_back(1); // Set break point at this line.
+ numbers.push_back(12); // Set break point at this line.
+ numbers.push_back(123);
+ numbers.push_back(1234);
+ numbers.push_back(12345); // Set break point at this line.
+ numbers.push_back(123456);
+ numbers.push_back(1234567);
+
+ numbers.clear(); // Set break point at this line.
+
+ numbers.push_back(7); // Set break point at this line.
+
+ string_vect strings; // Set break point at this line.
+ strings.push_back(std::string("goofy"));
+ strings.push_back(std::string("is"));
+ strings.push_back(std::string("smart"));
+
+ strings.push_back(std::string("!!!")); // Set break point at this line.
+
+ strings.clear(); // Set break point at this line.
+
+ return 0;// Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/Makefile
new file mode 100644
index 000000000000..04f39271f0cd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
new file mode 100644
index 000000000000..8cebf20ddd2a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
@@ -0,0 +1,205 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SynthDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Pick some values and check that the basics work
+ self.runCmd("type filter add BagOfInts --child x --child z")
+ self.expect("frame variable int_bag",
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # Check we can still access the missing child by summary
+ self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\"")
+ self.expect('frame variable int_bag',
+ substrs = ['y=7'])
+
+ # Even if we have synth children, the summary prevails
+ self.expect("frame variable int_bag", matching=False,
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # if we skip synth and summary show y
+ self.expect("frame variable int_bag --synthetic-type false --no-summary-depth=1",
+ substrs = ['x = 6',
+ 'y = 7',
+ 'z = 8'])
+
+ # if we ask for raw output same happens
+ self.expect("frame variable int_bag --raw-output",
+ substrs = ['x = 6',
+ 'y = 7',
+ 'z = 8'])
+
+ # Summary+Synth must work together
+ self.runCmd("type summary add BagOfInts --summary-string \"x=${var.x}\" -e")
+ self.expect('frame variable int_bag',
+ substrs = ['x=6',
+ 'x = 6',
+ 'z = 8'])
+
+ # Same output, but using Python
+ self.runCmd("type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e")
+ self.expect('frame variable int_bag',
+ substrs = ['x=6',
+ 'x = 6',
+ 'z = 8'])
+
+ # If I skip summaries, still give me the artificial children
+ self.expect("frame variable int_bag --no-summary-depth=1",
+ substrs = ['x = 6',
+ 'z = 8'])
+
+ # Delete synth and check that the view reflects it immediately
+ self.runCmd("type filter delete BagOfInts")
+ self.expect("frame variable int_bag",
+ substrs = ['x = 6',
+ 'y = 7',
+ 'z = 8'])
+
+ # Add the synth again and check that it's honored deeper in the hierarchy
+ self.runCmd("type filter add BagOfInts --child x --child z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x = x=69 {',
+ 'x = 69',
+ 'z = 71',
+ 'y = x=66 {',
+ 'x = 66',
+ 'z = 68'])
+ self.expect('frame variable bag_bag', matching=False,
+ substrs = ['y = 70',
+ 'y = 67'])
+
+ # Check that a synth can expand nested stuff
+ self.runCmd("type filter add BagOfBags --child x.y --child y.z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.y = 70',
+ 'y.z = 68'])
+
+ # ...even if we get -> and . wrong
+ self.runCmd("type filter add BagOfBags --child x.y --child \"y->z\"")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.y = 70',
+ 'y->z = 68'])
+
+ # ...even bitfields
+ self.runCmd("type filter add BagOfBags --child x.y --child \"y->z[1-2]\"")
+ self.expect('frame variable bag_bag --show-types',
+ substrs = ['x.y = 70',
+ '(int:2) y->z[1-2] = 2'])
+
+ # ...even if we format the bitfields
+ self.runCmd("type filter add BagOfBags --child x.y --child \"y->y[0-0]\"")
+ self.runCmd("type format add \"int:1\" -f bool")
+ self.expect('frame variable bag_bag --show-types',
+ substrs = ['x.y = 70',
+ '(int:1) y->y[0-0] = true'])
+
+ # ...even if we use one-liner summaries
+ self.runCmd("type summary add -c BagOfBags")
+ self.expect('frame variable bag_bag',
+ substrs = ['(BagOfBags) bag_bag = (x.y = 70, y->y[0-0] = true)'])
+
+ self.runCmd("type summary delete BagOfBags")
+
+ # now check we are dynamic (and arrays work)
+ self.runCmd("type filter add Plenty --child bitfield --child array[0] --child array[2]")
+ self.expect('frame variable plenty_of_stuff',
+ substrs = ['bitfield = 1',
+ 'array[0] = 5',
+ 'array[2] = 3'])
+
+ self.runCmd("n")
+ self.expect('frame variable plenty_of_stuff',
+ substrs = ['bitfield = 17',
+ 'array[0] = 5',
+ 'array[2] = 3'])
+
+ # skip synthetic children
+ self.expect('frame variable plenty_of_stuff --synthetic-type no',
+ substrs = ['some_values = 0x',
+ 'array = 0x',
+ 'array_size = 5'])
+
+
+ # check flat printing with synthetic children
+ self.expect('frame variable plenty_of_stuff --flat',
+ substrs = ['plenty_of_stuff.bitfield = 17',
+ '*(plenty_of_stuff.array) = 5',
+ '*(plenty_of_stuff.array) = 3'])
+
+ # check that we do not lose location information for our children
+ self.expect('frame variable plenty_of_stuff --location',
+ substrs = ['0x',
+ ': bitfield = 17'])
+
+ # check we work across pointer boundaries
+ self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1',
+ substrs = ['(BagOfInts *) plenty_of_stuff.some_values',
+ 'x = 5',
+ 'z = 7'])
+
+ # but not if we don't want to
+ self.runCmd("type filter add BagOfInts --child x --child z -p")
+ self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1',
+ substrs = ['(BagOfInts *) plenty_of_stuff.some_values',
+ 'x = 5',
+ 'y = 6',
+ 'z = 7'])
+
+ # check we're dynamic even if nested
+ self.runCmd("type filter add BagOfBags --child x.z")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.z = 71'])
+
+ self.runCmd("n")
+ self.expect('frame variable bag_bag',
+ substrs = ['x.z = 12'])
+
+ self.runCmd('type summary add -e -s "I am always empty but have" EmptyStruct')
+ self.expect('frame variable es', substrs = ["I am always empty but have {}"])
+ self.runCmd('type summary add -e -h -s "I am really empty" EmptyStruct')
+ self.expect('frame variable es', substrs = ["I am really empty"])
+ self.expect('frame variable es', substrs = ["I am really empty {}"], matching=False)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp
new file mode 100644
index 000000000000..bac38d84fae3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp
@@ -0,0 +1,86 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+struct BagOfInts
+{
+ int x;
+ int y;
+ int z;
+ BagOfInts(int X) :
+ x(X),
+ y(X+1),
+ z(X+2) {}
+};
+
+struct BagOfFloats
+{
+ float x;
+ float y;
+ float z;
+ BagOfFloats(float X) :
+ x(X+0.334),
+ y(X+0.500),
+ z(X+0.667) {}
+};
+
+struct BagOfBags
+{
+ BagOfInts x;
+ BagOfInts y;
+ BagOfFloats z;
+ BagOfFloats q;
+ BagOfBags() :
+ x('E'),
+ y('B'),
+ z(1.1),
+ q(20.11) {}
+};
+
+struct EmptyStruct {};
+
+struct Plenty
+{
+ BagOfInts *some_values;
+ int* array;
+ int array_size;
+ int bitfield;
+
+ Plenty(int N, bool flagA, bool flagB) :
+ some_values(new BagOfInts(N)),
+ array(new int[N]),
+ array_size(N),
+ bitfield( (flagA ? 0x01 : 0x00) | (flagB ? 0x10 : 0x00) )
+ {
+ for (int j = 0; j < N; j++)
+ array[j] = N-j;
+ }
+};
+
+int main (int argc, const char * argv[])
+{
+ BagOfInts int_bag(6);
+ BagOfFloats float_bag(2.71);
+
+ BagOfBags bag_bag;
+ EmptyStruct es;
+
+ Plenty plenty_of_stuff(5,true,false);
+
+ plenty_of_stuff.bitfield = 0x11; // Set break point at this line.
+
+ bag_bag.x.z = 12;
+
+ return 0;
+
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
new file mode 100644
index 000000000000..8d6e5df37a5c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
@@ -0,0 +1,96 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterSynthValueTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', 'break here')
+
+ @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Test using Python synthetic children provider to provide a value."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ x = self.frame().FindVariable("x")
+ x.SetPreferSyntheticValue(True)
+ y = self.frame().FindVariable("y")
+ y.SetPreferSyntheticValue(True)
+ z = self.frame().FindVariable("z")
+ z.SetPreferSyntheticValue(True)
+
+ x_val = x.GetValueAsUnsigned
+ y_val = y.GetValueAsUnsigned
+ z_val = z.GetValueAsUnsigned
+
+ if self.TraceOn():
+ print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val()))
+
+ self.assertFalse(x_val() == 3, "x == 3 before synthetics")
+ self.assertFalse(y_val() == 4, "y == 4 before synthetics")
+ self.assertFalse(z_val() == 7, "z == 7 before synthetics")
+
+ # now set up the synth
+ self.runCmd("script from myIntSynthProvider import *")
+ self.runCmd("type synth add -l myIntSynthProvider myInt")
+ self.runCmd("type synth add -l myArraySynthProvider myArray")
+
+ if self.TraceOn():
+ print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val()))
+
+ self.assertTrue(x_val() == 3, "x != 3 after synthetics")
+ self.assertTrue(y_val() == 4, "y != 4 after synthetics")
+ self.assertTrue(z_val() == 7, "z != 7 after synthetics")
+
+ self.expect("frame variable x", substrs=['3'])
+ self.expect("frame variable x", substrs=['theValue = 3'], matching=False)
+
+ # check that an aptly defined synthetic provider does not affect one-lining
+ self.expect("expression struct S { myInt theInt{12}; }; S()", substrs = ['(theInt = 12)'])
+
+ # check that we can use a synthetic value in a summary
+ self.runCmd("type summary add hasAnInt -s ${var.theInt}")
+ hi = self.frame().FindVariable("hi")
+ self.assertEqual(hi.GetSummary(), "42")
+
+ ma = self.frame().FindVariable("ma")
+ self.assertTrue(ma.IsValid())
+ self.assertEqual(ma.GetNumChildren(15), 15)
+ self.assertEqual(ma.GetNumChildren(16), 16)
+ self.assertEqual(ma.GetNumChildren(17), 16)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp
new file mode 100644
index 000000000000..accbf0a5a578
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp
@@ -0,0 +1,29 @@
+class myInt {
+ private: int theValue;
+ public: myInt() : theValue(0) {}
+ public: myInt(int _x) : theValue(_x) {}
+ int val() { return theValue; }
+};
+
+class myArray {
+public:
+ int array[16];
+};
+
+class hasAnInt {
+ public:
+ myInt theInt;
+ hasAnInt() : theInt(42) {}
+};
+
+myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); }
+
+int main() {
+ myInt x{3};
+ myInt y{4};
+ myInt z {x+y};
+ hasAnInt hi;
+ myArray ma;
+
+ return z.val(); // break here
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py
new file mode 100644
index 000000000000..c8517a442932
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py
@@ -0,0 +1,36 @@
+class myIntSynthProvider(object):
+ def __init__(self, valobj, dict):
+ self.valobj = valobj;
+ self.val = self.valobj.GetChildMemberWithName("theValue")
+ def num_children(self):
+ return 0;
+ def get_child_at_index(self, index):
+ return None
+ def get_child_index(self, name):
+ return None
+ def update(self):
+ return False
+ def has_children(self):
+ return False
+ def get_value(self):
+ return self.val
+
+
+class myArraySynthProvider(object):
+ def __init__(self, valobj, dict):
+ self.valobj = valobj
+ self.array = self.valobj.GetChildMemberWithName("array")
+
+ def num_children(self, max_count):
+ if 16 < max_count:
+ return 16
+ return max_count
+
+ def get_child_at_index(self, index):
+ return None # Keep it simple when this is not tested here.
+
+ def get_child_index(self, name):
+ return None # Keep it simple when this is not tested here.
+
+ def has_children(self):
+ return True
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/Makefile
new file mode 100644
index 000000000000..69dde1b76184
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+CXXFLAGS += -std=c++11
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
new file mode 100644
index 000000000000..8ae09d691940
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
@@ -0,0 +1,5 @@
+from __future__ import absolute_import
+
+from lldbsuite.test import lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureWindows("llvm.org/pr24663")])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp
new file mode 100644
index 000000000000..bc8e05829316
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp
@@ -0,0 +1,35 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+class Base {
+public:
+ Base () = default;
+ virtual int func() { return 1; }
+ virtual ~Base() = default;
+};
+
+class Derived : public Base {
+private:
+ int m_derived_data;
+public:
+ Derived () : Base(), m_derived_data(0x0fedbeef) {}
+ virtual ~Derived() = default;
+ virtual int func() { return m_derived_data; }
+};
+
+int main (int argc, char const *argv[])
+{
+ Base *base = new Derived();
+ return 0; //% stream = lldb.SBStream()
+ //% base = self.frame().FindVariable("base")
+ //% base.SetPreferDynamicValue(lldb.eDynamicDontRunTarget)
+ //% base.GetDescription(stream)
+ //% if self.TraceOn(): print(stream.GetData())
+ //% self.assertTrue(stream.GetData().startswith("(Derived *"))
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py
new file mode 100644
index 000000000000..5cb7c82c9e09
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py
@@ -0,0 +1,75 @@
+"""
+Check if changing Format on an SBValue correctly propagates that new format to children as it should
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class FormatPropagationTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ # rdar://problem/14035604
+ def test_with_run_command(self):
+ """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ pass
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # extract the parent and the children
+ frame = self.frame()
+ parent = self.frame().FindVariable("f")
+ self.assertTrue(parent != None and parent.IsValid(),"could not find f")
+ X = parent.GetChildMemberWithName("X")
+ self.assertTrue(X != None and X.IsValid(),"could not find X")
+ Y = parent.GetChildMemberWithName("Y")
+ self.assertTrue(Y != None and Y.IsValid(),"could not find Y")
+ # check their values now
+ self.assertTrue(X.GetValue() == "1", "X has an invalid value")
+ self.assertTrue(Y.GetValue() == "2", "Y has an invalid value")
+ # set the format on the parent
+ parent.SetFormat(lldb.eFormatHex)
+ self.assertTrue(X.GetValue() == "0x00000001", "X has not changed format")
+ self.assertTrue(Y.GetValue() == "0x00000002", "Y has not changed format")
+ # Step and check if the values make sense still
+ self.runCmd("next")
+ self.assertTrue(X.GetValue() == "0x00000004", "X has not become 4")
+ self.assertTrue(Y.GetValue() == "0x00000002", "Y has not stuck as hex")
+ # Check that children can still make their own choices
+ Y.SetFormat(lldb.eFormatDecimal)
+ self.assertTrue(X.GetValue() == "0x00000004", "X is still hex")
+ self.assertTrue(Y.GetValue() == "2", "Y has not been reset")
+ # Make a few more changes
+ parent.SetFormat(lldb.eFormatDefault)
+ X.SetFormat(lldb.eFormatHex)
+ Y.SetFormat(lldb.eFormatDefault)
+ self.assertTrue(X.GetValue() == "0x00000004", "X is not hex as it asked")
+ self.assertTrue(Y.GetValue() == "2", "Y is not defaulted")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/main.cpp
new file mode 100644
index 000000000000..5822fbc2a710
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/main.cpp
@@ -0,0 +1,13 @@
+struct foo
+{
+ int X;
+ int Y;
+ foo(int a, int b) : X(a), Y(b) {}
+};
+
+int main()
+{
+ foo f(1,2);
+ f.X = 4; // Set break point at this line.
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py
new file mode 100644
index 000000000000..555351998c2d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py
@@ -0,0 +1,38 @@
+"""
+Test that the user can input a format but it will not prevail over summary format's choices.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class FrameFormatSmallStructTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that the user can input a format but it will not prevail over summary format's choices."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("thread list", substrs = ['addPair(p=(x = 3, y = -3))'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp
new file mode 100644
index 000000000000..120ef0ea0910
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp
@@ -0,0 +1,25 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+struct Pair {
+ int x;
+ int y;
+
+ Pair(int _x, int _y) : x(_x), y(_y) {}
+};
+
+int addPair(Pair p)
+{
+ return p.x + p.y; // Set break point at this line.
+}
+
+int main() {
+ Pair p1(3,-3);
+ return addPair(p1);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py
new file mode 100644
index 000000000000..3c28b68056f5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py
@@ -0,0 +1,82 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterHexCapsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format delete hex', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type format add -f uppercase int")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ 'first = 0x001122AA', 'second = 0x1122BB44'])
+
+ self.runCmd("type format add -f hex int")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ 'first = 0x001122aa', 'second = 0x1122bb44'])
+
+ self.runCmd("type format delete int")
+
+ self.runCmd("type summary add -s \"${var.first%X} and ${var.second%x}\" foo")
+
+ self.expect('frame variable mine',
+ substrs = ['(foo) mine = 0x001122AA and 0x1122bb44'])
+
+ self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo")
+ self.runCmd("next")
+ self.runCmd("next")
+ self.expect('frame variable mine',
+ substrs = ['(foo) mine = 0xAABBCCDD and 0x1122BB44'])
+
+ self.runCmd("type summary add -s \"${var.first%x} and ${var.second%X}\" foo")
+ self.expect('frame variable mine',
+ substrs = ['(foo) mine = 0xaabbccdd and 0x1122BB44'])
+ self.runCmd("next")
+ self.runCmd("next")
+ self.runCmd("type summary add -s \"${var.first%x} and ${var.second%x}\" foo")
+ self.expect('frame variable mine',
+ substrs = ['(foo) mine = 0xaabbccdd and 0xff00ff00'])
+ self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo")
+ self.expect('frame variable mine',
+ substrs = ['(foo) mine = 0xAABBCCDD and 0xFF00FF00'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp
new file mode 100644
index 000000000000..5ee113c17b28
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp
@@ -0,0 +1,28 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+struct foo
+{
+ int first;
+ int second;
+};
+
+int main ()
+{
+ struct foo mine = {0x001122AA, 0x1122BB44};
+ printf("main.first = 0x%8.8x, main.second = 0x%8.8x\n", mine.first, mine.second);
+ mine.first = 0xAABBCCDD; // Set break point at this line.
+ printf("main.first = 0x%8.8x, main.second = 0x%8.8x\n", mine.first, mine.second);
+ mine.second = 0xFF00FF00;
+ printf("main.first = 0x%8.8x, main.second = 0x%8.8x\n", mine.first, mine.second);
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
new file mode 100644
index 000000000000..b7562c4336a6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
@@ -0,0 +1,60 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class LanguageCategoryUpdatesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// break here')
+
+ @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
+ def test_with_run_command(self):
+ """Test that LLDB correctly cleans caches when language categories change."""
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ if hasattr(self, 'type_category') and hasattr(self, 'type_specifier'):
+ self.type_category.DeleteTypeSummary(self.type_specifier)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True)
+
+ self.type_category = self.dbg.GetCategory(lldb.eLanguageTypeC_plus_plus)
+ type_summary = lldb.SBTypeSummary.CreateWithSummaryString("this is an object of type S")
+ self.type_specifier = lldb.SBTypeNameSpecifier('S')
+ self.type_category.AddTypeSummary(self.type_specifier, type_summary)
+
+ self.expect("frame variable", substrs = ['this is an object of type S'], matching=True)
+
+ self.type_category.DeleteTypeSummary(self.type_specifier)
+ self.expect("frame variable", substrs = ['this is an object of type S'], matching=False)
+ self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True)
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp
new file mode 100644
index 000000000000..ac77e537b80a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp
@@ -0,0 +1,20 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+struct S {
+ int x;
+ int y;
+
+ S() : x(123), y(456) {}
+};
+
+int main() {
+ S object;
+ return 0; // break here
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/Makefile
new file mode 100644
index 000000000000..9f7fb1ca6231
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py
new file mode 100644
index 000000000000..a12f9c841a7f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py
@@ -0,0 +1,67 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class NSArraySyntheticTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_rdar11086338_with_run_command(self):
+ """Test that NSArray reports its synthetic children properly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we are displaying Cocoa classes correctly
+ self.expect('frame variable arr',
+ substrs = ['@"6 elements"'])
+ self.expect('frame variable other_arr',
+ substrs = ['@"4 elements"'])
+ self.expect('frame variable arr --ptr-depth 1',
+ substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x'])
+ self.expect('frame variable other_arr --ptr-depth 1',
+ substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x'])
+ self.expect('frame variable arr --ptr-depth 1 -d no-run-target',
+ substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
+ self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target',
+ substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"'])
+ self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target',
+ substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
+
+ self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!")
+ self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m
new file mode 100644
index 000000000000..1b4a6e03857a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m
@@ -0,0 +1,35 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+
+ NSMutableArray* arr = [[NSMutableArray alloc] init];
+ [arr addObject:@"hello"];
+ [arr addObject:@"world"];
+ [arr addObject:@"this"];
+ [arr addObject:@"is"];
+ [arr addObject:@"me"];
+ [arr addObject:[NSURL URLWithString:@"http://www.apple.com/"]];
+
+ NSDate *aDate = [NSDate distantFuture];
+ NSValue *aValue = [NSNumber numberWithInt:5];
+ NSString *aString = @"a string";
+
+ NSArray *other_arr = [NSArray arrayWithObjects:aDate, aValue, aString, arr, nil];
+
+ [pool drain];// Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/Makefile
new file mode 100644
index 000000000000..9f7fb1ca6231
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py
new file mode 100644
index 000000000000..13d493ecbdcc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py
@@ -0,0 +1,69 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class NSDictionarySyntheticTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_rdar11988289_with_run_command(self):
+ """Test that NSDictionary reports its synthetic children properly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we are displaying Cocoa classes correctly
+ self.expect('frame variable dictionary',
+ substrs = ['3 key/value pairs'])
+ self.expect('frame variable mutabledict',
+ substrs = ['4 key/value pairs'])
+ self.expect('frame variable dictionary --ptr-depth 1',
+ substrs = ['3 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = '])
+ self.expect('frame variable mutabledict --ptr-depth 1',
+ substrs = ['4 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ','[3] = '])
+ self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target',
+ substrs = ['3 key/value pairs','@"bar"','@"2 elements"','@"baz"','2 key/value pairs'])
+ self.expect('frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target',
+ substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs'])
+ self.expect('frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target',
+ substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"'])
+ self.expect('frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target',
+ substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"','(int)1','@"two"'])
+
+ self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!")
+ self.assertTrue(self.frame().FindVariable("mutabledict").MightHaveChildren(), "mutable says it does not have children!")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m
new file mode 100644
index 000000000000..fdc533aeaf24
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m
@@ -0,0 +1,30 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+
+ NSArray* keys = @[@"foo",@"bar",@"baz"];
+ NSArray* values = @[@"hello",@[@"X",@"Y"],@{@1 : @"one",@2 : @"two"}];
+ NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
+ NSMutableDictionary* mutabledict = [NSMutableDictionary dictionaryWithCapacity:5];
+ [mutabledict setObject:@"123" forKey:@23];
+ [mutabledict setObject:[NSURL URLWithString:@"http://www.apple.com"] forKey:@"foobar"];
+ [mutabledict setObject:@[@"a",@12] forKey:@57];
+ [mutabledict setObject:dictionary forKey:@"sourceofstuff"];
+
+ [pool drain];// Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/Makefile
new file mode 100644
index 000000000000..9f7fb1ca6231
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py
new file mode 100644
index 000000000000..6c558001bb04
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py
@@ -0,0 +1,74 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class NSSetSyntheticTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_rdar12529957_with_run_command(self):
+ """Test that NSSet reports its synthetic children properly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we are displaying Cocoa classes correctly
+ self.expect('frame variable set',
+ substrs = ['4 elements'])
+ self.expect('frame variable mutable',
+ substrs = ['9 elements'])
+ self.expect('frame variable set --ptr-depth 1 -d run -T',
+ substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2'])
+ self.expect('frame variable mutable --ptr-depth 1 -d run -T',
+ substrs = ['9 elements','(int)5','@"3 elements"','@"www.apple.com"','(int)3','@"world"','(int)4'])
+
+ self.runCmd("next")
+ self.expect('frame variable mutable',
+ substrs = ['0 elements'])
+
+ self.runCmd("next")
+ self.expect('frame variable mutable',
+ substrs = ['4 elements'])
+ self.expect('frame variable mutable --ptr-depth 1 -d run -T',
+ substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2'])
+
+ self.runCmd("next")
+ self.expect('frame variable mutable',
+ substrs = ['4 elements'])
+ self.expect('frame variable mutable --ptr-depth 1 -d run -T',
+ substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m
new file mode 100644
index 000000000000..7bc49583606f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m
@@ -0,0 +1,34 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ NSSet* set = [NSSet setWithArray:@[@1,@"hello",@2,@"world"]];
+ NSMutableSet* mutable = [NSMutableSet setWithCapacity:5];
+ [mutable addObject:@1];
+ [mutable addObject:@2];
+ [mutable addObject:@3];
+ [mutable addObject:@4];
+ [mutable addObject:@5];
+ [mutable addObject:[NSURL URLWithString:@"www.apple.com"]];
+ [mutable addObject:@[@1,@2,@3]];
+ [mutable unionSet:set];
+ [mutable removeAllObjects]; // Set break point at this line.
+ [mutable unionSet:set];
+ [mutable addObject:@1];
+
+ [pool drain];
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/Makefile
new file mode 100644
index 000000000000..261658b10ae8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+OBJCXX_SOURCES := main.mm
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py
new file mode 100644
index 000000000000..4fb6176e9e4f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py
@@ -0,0 +1,52 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterOSTypeTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.mm', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_ostype_with_run_command(self):
+ """Test the formatters we use for OSType."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now check that we use the right summary for OSType
+ self.expect('frame variable',
+ substrs = ["'test'","'best'"])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm
new file mode 100644
index 000000000000..8d22659374a7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm
@@ -0,0 +1,23 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ OSType a = 'test';
+ OSType b = 'best';
+
+ [pool drain];// Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/Makefile
new file mode 100644
index 000000000000..d85e665333ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -std=c++11
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py
new file mode 100644
index 000000000000..bf98559cd0c1
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py
@@ -0,0 +1,57 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class PtrRef2TypedefTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set breakpoint here')
+
+ def test_with_run_command(self):
+ """Test that a pointer/reference to a typedef is formatted as we want."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd('type summary add --cascade true -s "IntPointer" "int *"')
+ self.runCmd('type summary add --cascade true -s "IntLRef" "int &"')
+ self.runCmd('type summary add --cascade true -s "IntRRef" "int &&"')
+
+ self.expect("frame variable x", substrs = ['(Foo *) x = 0x','IntPointer'])
+ # note: Ubuntu 12.04 x86_64 build with gcc 4.8.2 is getting a
+ # const after the ref that isn't showing up on FreeBSD. This
+ # tweak changes the behavior so that the const is not part of
+ # the match.
+ self.expect("frame variable y", substrs = ['(Foo &', ') y = 0x','IntLRef'])
+ self.expect("frame variable z", substrs = ['(Foo &&', ') z = 0x','IntRRef'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp
new file mode 100644
index 000000000000..219f398da3f5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp
@@ -0,0 +1,19 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+typedef int Foo;
+
+int main() {
+ int lval = 1;
+ Foo* x = &lval;
+ Foo& y = lval;
+ Foo&& z = 1;
+ return 0; // Set breakpoint here
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py
new file mode 100644
index 000000000000..13b84e9f74c7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py
@@ -0,0 +1,41 @@
+"""
+Test that ValueObjectPrinter does not cause an infinite loop when a reference to a struct that contains a pointer to itself is printed.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DataFormatterRefPtrRecursionTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that ValueObjectPrinter does not cause an infinite loop when a reference to a struct that contains a pointer to itself is printed."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable foo", substrs = []);
+ self.expect("frame variable foo --ptr-depth=1", substrs = ['ID = 1']);
+ self.expect("frame variable foo --ptr-depth=2", substrs = ['ID = 1']);
+ self.expect("frame variable foo --ptr-depth=3", substrs = ['ID = 1']);
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/main.cpp
new file mode 100644
index 000000000000..4b576bd266dd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/main.cpp
@@ -0,0 +1,21 @@
+int _ID = 0;
+
+class Foo {
+ public:
+ Foo *next;
+ int ID;
+
+ Foo () : next(0), ID(++_ID) {}
+};
+
+int evalFoo(Foo& foo)
+{
+ return foo.ID; // Set break point at this line.
+}
+
+int main() {
+ Foo f;
+ f.next = &f;
+ return evalFoo(f);
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/Makefile
new file mode 100644
index 000000000000..62a57f6cd9be
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/Makefile
@@ -0,0 +1,4 @@
+LEVEL = ../../../make
+OBJC_SOURCES := main.m
+include $(LEVEL)/Makefile.rules
+LDFLAGS += -framework Foundation
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py
new file mode 100644
index 000000000000..80305e303d03
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py
@@ -0,0 +1,4 @@
+import lldbsuite.test.lldbinline as lldbinline
+import lldbsuite.test.lldbtest as lldbtest
+
+lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m
new file mode 100644
index 000000000000..3dd455081007
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m
@@ -0,0 +1,19 @@
+//===-- main.m ---------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#import <Foundation/Foundation.h>
+
+int main() {
+ NSDictionary* dic = @{@1 : @2};
+ NSLog(@"hello world"); //% dic = self.frame().FindVariable("dic")
+ //% dic.SetPreferSyntheticValue(True)
+ //% dic.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+ //% dic.SetValueFromCString("12")
+ return 0; //% dic = self.frame().FindVariable("dic")
+ //% self.assertTrue(dic.GetValueAsUnsigned() == 0xC, "failed to read what I wrote")
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/Makefile
new file mode 100644
index 000000000000..69dde1b76184
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+CXXFLAGS += -std=c++11
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py
new file mode 100644
index 000000000000..69f7d48c8b6c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py
@@ -0,0 +1,4 @@
+import lldbsuite.test.lldbinline as lldbinline
+import lldbsuite.test.lldbtest as lldbtest
+
+lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.expectedFailureWindows("llvm.org/pr24772")])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp
new file mode 100644
index 000000000000..4a449e9716c3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp
@@ -0,0 +1,40 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <string>
+
+int main (int argc, char const *argv[])
+{
+ std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); //%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables true"))
+ const char* constcharstar = stdstring.c_str();
+ std::string longstring(
+"I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
+" is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
+" a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
+" for science, or something"
+ "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
+ " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
+ " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
+ " for science, or something"
+ "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
+ " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
+ " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
+ " for science, or something"
+ );
+ const char* longconstcharstar = longstring.c_str();
+ return 0; //% if self.TraceOn(): self.runCmd('frame variable')
+ //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
+ //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
+ //% self.runCmd("setting set escape-non-printables false")
+ //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
+ //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
+ //% self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...'))
+ //% self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...'))
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Makefile
new file mode 100644
index 000000000000..04f39271f0cd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py
new file mode 100644
index 000000000000..2873e35368fb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py
@@ -0,0 +1,133 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class Radar9974002DataFormatterTestCase(TestBase):
+
+ # test for rdar://problem/9974002 ()
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
+ self.skipTest("llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
+
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '<parent is NULL>'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s foo contained")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', 'foo'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', 'foo'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '<parent is NULL>'])
+
+ self.runCmd("type summary delete contained")
+ self.runCmd("n")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '<parent is NULL>'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s foo contained")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', 'foo'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', 'foo'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '0x000000'])
+
+ self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container")
+
+ self.expect('frame variable mine',
+ substrs = ['mine = ',
+ '1', '<parent is NULL>'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp
new file mode 100644
index 000000000000..03a9f278b7ec
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp
@@ -0,0 +1,30 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+struct contained
+{
+ int first;
+ int second;
+};
+
+struct container
+{
+ int scalar;
+ struct contained *pointer;
+};
+
+int main ()
+{
+ struct container mine = {1, 0};
+ printf ("Mine's scalar is the only thing that is good: %d.\n", mine.scalar); // Set break point at this line.
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
new file mode 100644
index 000000000000..0550f57ae62a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
@@ -0,0 +1,75 @@
+"""
+Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SyntheticCappingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # set up the synthetic children provider
+ self.runCmd("script from fooSynthProvider import *")
+ self.runCmd("type synth add -l fooSynthProvider foo")
+
+ # check that the synthetic children work, so we know we are doing the right thing
+ self.expect("frame variable f00_1",
+ substrs = ['r = 33',
+ 'fake_a = 16777216',
+ 'a = 0']);
+
+ # check that capping works
+ self.runCmd("settings set target.max-children-count 2", check=False)
+
+ self.expect("frame variable f00_1",
+ substrs = ['...',
+ 'fake_a = 16777216',
+ 'a = 0']);
+
+ self.expect("frame variable f00_1", matching=False,
+ substrs = ['r = 33']);
+
+
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ self.expect("frame variable f00_1", matching=True,
+ substrs = ['r = 33']);
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py
new file mode 100644
index 000000000000..fb95ac2b54d0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py
@@ -0,0 +1,21 @@
+import lldb
+class fooSynthProvider:
+ def __init__(self, valobj, dict):
+ self.valobj = valobj;
+ self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt)
+ def num_children(self):
+ return 3;
+ def get_child_at_index(self, index):
+ if index == 0:
+ child = self.valobj.GetChildMemberWithName('a');
+ if index == 1:
+ child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type);
+ if index == 2:
+ child = self.valobj.GetChildMemberWithName('r');
+ return child;
+ def get_child_index(self, name):
+ if name == 'a':
+ return 0;
+ if name == 'fake_a':
+ return 1;
+ return 2;
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp
new file mode 100644
index 000000000000..b921915b91c5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp
@@ -0,0 +1,62 @@
+struct foo
+{
+ int a;
+ int b;
+ int c;
+ int d;
+ int e;
+ int f;
+ int g;
+ int h;
+ int i;
+ int j;
+ int k;
+ int l;
+ int m;
+ int n;
+ int o;
+ int p;
+ int q;
+ int r;
+
+ foo(int X) :
+ a(X),
+ b(X+1),
+ c(X+3),
+ d(X+5),
+ e(X+7),
+ f(X+9),
+ g(X+11),
+ h(X+13),
+ i(X+15),
+ j(X+17),
+ k(X+19),
+ l(X+21),
+ m(X+23),
+ n(X+25),
+ o(X+27),
+ p(X+29),
+ q(X+31),
+ r(X+33) {}
+};
+
+struct wrapint
+{
+ int x;
+ wrapint(int X) : x(X) {}
+};
+
+int main()
+{
+ foo f00_1(0);
+ foo *f00_ptr = new foo(12);
+
+ f00_1.a++; // Set break point at this line.
+
+ wrapint test_cast('A' +
+ 256*'B' +
+ 256*256*'C'+
+ 256*256*256*'D');
+
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/Makefile
new file mode 100644
index 000000000000..a8e1853a1290
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -w
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
+
+clean::
+ rm -rf $(wildcard *.o *.d *.dSYM *.log)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py
new file mode 100644
index 000000000000..6b70a88b9f2c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py
@@ -0,0 +1,74 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import datetime
+import lldbsuite.test.lldbutil as lldbutil
+
+class SyntheticFilterRecomputingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.m', '// Set break point at this line.')
+
+ @skipUnlessDarwin
+ def test_rdar12437442_with_run_command(self):
+ """Test that we update SBValues correctly as dynamic types change."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Now run the bulk of the test
+ id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x")
+ id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+ id_x.SetPreferSyntheticValue(True)
+
+ if self.TraceOn():
+ self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x")
+
+ self.assertTrue(id_x.GetSummary() == '@"5 elements"', "array does not get correct summary")
+
+ self.runCmd("next")
+ self.runCmd("frame select 0")
+
+ id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x")
+ id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
+ id_x.SetPreferSyntheticValue(True)
+
+ if self.TraceOn():
+ self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x")
+
+ self.assertTrue(id_x.GetNumChildren() == 7, "dictionary does not have 7 children")
+ id_x.SetPreferSyntheticValue(False)
+ self.assertFalse(id_x.GetNumChildren() == 7, "dictionary still looks synthetic")
+ id_x.SetPreferSyntheticValue(True)
+ self.assertTrue(id_x.GetSummary() == "7 key/value pairs", "dictionary does not get correct summary")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m
new file mode 100644
index 000000000000..a7e94d29d469
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m
@@ -0,0 +1,25 @@
+//===-- main.m ------------------------------------------------*- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[])
+{
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ NSArray* foo = [NSArray arrayWithObjects:@1,@2,@3,@4,@5, nil];
+ NSDictionary *bar = @{@1 : @"one",@2 : @"two", @3 : @"three", @4 : @"four", @5 : @"five", @6 : @"six", @7 : @"seven"};
+ id x = foo;
+ x = bar; // Set break point at this line.
+
+ [pool drain];
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/Makefile
new file mode 100644
index 000000000000..3e2b0187b954
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/Makefile
@@ -0,0 +1,4 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+CXXFLAGS += -std=c++11
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py
new file mode 100644
index 000000000000..30b66e062827
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py
@@ -0,0 +1,4 @@
+import lldbsuite.test.lldbinline as lldbinline
+import lldbsuite.test.lldbtest as lldbtest
+
+lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.expectedFailureGcc])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp
new file mode 100644
index 000000000000..649c1e09a6a5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp
@@ -0,0 +1,14 @@
+//===-- main.cpp --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+typedef int Foo;
+
+int main() {
+ Foo array[3] = {1,2,3};
+ return 0; //% self.expect("frame variable array --show-types --", substrs = ['(Foo [3]) array = {','(Foo) [0] = 1','(Foo) [1] = 2','(Foo) [2] = 3'])
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py
new file mode 100644
index 000000000000..dba2816d2647
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py
@@ -0,0 +1,59 @@
+"""
+Test that the user can input a format but it will not prevail over summary format's choices.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class UserFormatVSSummaryTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that the user can input a format but it will not prevail over summary format's choices."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.expect("frame variable p1", substrs = ['(Pair) p1 = (x = 3, y = -3)']);
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"')
+
+ self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']);
+ self.expect("frame variable -f x p1", substrs = ['(Pair) p1 = x=0x00000003,y=0xfffffffd'], matching=False);
+ self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'], matching=False);
+ self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']);
+
+ self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"')
+
+ self.expect("frame variable p1", substrs = ['(Pair) p1 = x=0x00000003,y=4294967293']);
+ self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'],matching=False);
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp
new file mode 100644
index 000000000000..41c934aec0c3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp
@@ -0,0 +1,20 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+struct Pair {
+ int x;
+ int y;
+
+ Pair(int _x, int _y) : x(_x), y(_y) {}
+};
+
+int main() {
+ Pair p1(3,-3);
+ return p1.x + p1.y; // Set break point at this line.
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/Makefile
new file mode 100644
index 000000000000..18c35a7d84a5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/Makefile
@@ -0,0 +1,11 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+# Workaround for llvm.org/pr16214: clang doesn't emit structure definition DWARF
+# information without the flag below.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py
new file mode 100644
index 000000000000..5899469651d3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py
@@ -0,0 +1,74 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class VarInAggregateMisuseTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def test_with_run_command(self):
+ """Test that that file and class static variables display correctly."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize")
+
+ self.expect('frame variable mine_ptr',
+ substrs = ['SUMMARY SUCCESS summarize_ptr_t @ '])
+
+ self.expect('frame variable *mine_ptr',
+ substrs = ['SUMMARY SUCCESS summarize_t @'])
+
+ self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize")
+
+ self.expect('frame variable mine_ptr',
+ substrs = ['SUMMARY SUCCESS 10'])
+
+ self.expect('frame variable *mine_ptr',
+ substrs = ['SUMMARY SUCCESS 10'])
+
+ self.runCmd("type summary add --summary-string \"${var}\" Summarize")
+ self.runCmd("type summary add --summary-string \"${var}\" -e TwoSummarizes")
+
+ self.expect('frame variable',
+ substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ',
+ 'first = summarize_t @ ',
+ 'second = summarize_t @ '])
+
+ self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize")
+ self.expect('frame variable',
+ substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ',
+ 'first = SUMMARY SUCCESS 1',
+ 'second = SUMMARY SUCCESS 3'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp
new file mode 100644
index 000000000000..72c7e138205d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp
@@ -0,0 +1,41 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+struct Summarize
+{
+ int first;
+ int second;
+};
+
+typedef struct Summarize summarize_t;
+typedef summarize_t *summarize_ptr_t;
+
+summarize_t global_mine = {30, 40};
+
+struct TwoSummarizes
+{
+ summarize_t first;
+ summarize_t second;
+};
+
+int
+main()
+{
+ summarize_t mine = {10, 20};
+ summarize_ptr_t mine_ptr = &mine;
+
+ TwoSummarizes twos = { {1,2}, {3,4} };
+
+ printf ("Summarize: first: %d second: %d and address: 0x%p\n", mine.first, mine.second, mine_ptr); // Set break point at this line.
+ printf ("Global summarize: first: %d second: %d.\n", global_mine.first, global_mine.second);
+ return 0;
+}
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py
new file mode 100644
index 000000000000..4d060c332f93
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py
@@ -0,0 +1,56 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+import os.path
+
+class PythonSynthDataFormatterTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', ' // Set breakpoint here.')
+
+ @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser
+ def test_with_run_command(self):
+ """Test using Python synthetic children provider."""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("command script import helperfunc.py")
+ self.runCmd('type summary add -x "^something<.*>$" -s "T is a ${script.var:helperfunc.f}"')
+
+ self.expect("frame variable x", substrs = ['T is a non-pointer type']);
+
+ self.expect("frame variable y", substrs = ['T is a pointer type']);
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py
new file mode 100644
index 000000000000..01562c5baa8d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py
@@ -0,0 +1,5 @@
+import lldb
+
+def f(value,d):
+ return "pointer type" if value.GetType().GetTemplateArgumentType(0).IsPointerType() else "non-pointer type"
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp
new file mode 100644
index 000000000000..4dc94af3566c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp
@@ -0,0 +1,8 @@
+template <typename T>
+struct something {};
+
+int main() {
+ something<int> x;
+ something<void*> y;
+ return 0; // Set breakpoint here.
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py
new file mode 100644
index 000000000000..05899a24ad22
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py
@@ -0,0 +1,73 @@
+"""
+Check that vector types format properly
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class VectorTypesFormattingTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// break here')
+
+ # rdar://problem/14035604
+ @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension
+ def test_with_run_command(self):
+ """Check that vector types format properly"""
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ pass
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ pass # my code never fails
+
+ v = self.frame().FindVariable("v")
+ v.SetPreferSyntheticValue(True)
+ v.SetFormat(lldb.eFormatVectorOfFloat32)
+
+ if self.TraceOn(): print(v)
+
+ self.assertTrue(v.GetNumChildren() == 4, "v as float32[] has 4 children")
+ self.assertTrue(v.GetChildAtIndex(0).GetData().float[0] == 1.25, "child 0 == 1.25")
+ self.assertTrue(v.GetChildAtIndex(1).GetData().float[0] == 1.25, "child 1 == 1.25")
+ self.assertTrue(v.GetChildAtIndex(2).GetData().float[0] == 2.50, "child 2 == 2.50")
+ self.assertTrue(v.GetChildAtIndex(3).GetData().float[0] == 2.50, "child 3 == 2.50")
+
+ self.expect("expr -f int16_t[] -- v", substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)'])
+ self.expect("expr -f uint128_t[] -- v", substrs=['(85236745249553456609335044694184296448)'])
+ self.expect("expr -f float32[] -- v", substrs=['(1.25, 1.25, 2.5, 2.5)'])
+
+ oldValue = v.GetChildAtIndex(0).GetValue()
+ v.SetFormat(lldb.eFormatHex)
+ newValue = v.GetChildAtIndex(0).GetValue()
+ self.assertFalse(oldValue == newValue, "values did not change along with format")
+
+ v.SetFormat(lldb.eFormatVectorOfFloat32)
+ oldValueAgain = v.GetChildAtIndex(0).GetValue()
+ self.assertTrue(oldValue == oldValueAgain, "same format but different values")
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp
new file mode 100644
index 000000000000..b9d67ad20ab2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef unsigned char vec __attribute__((ext_vector_type(16)));
+
+int main() {
+ float4 f4 = {1.25, 1.25, 2.50, 2.50};
+ vec v = (vec)f4;
+ return 0; // break here
+}