aboutsummaryrefslogtreecommitdiff
path: root/source/DataFormatters
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
committerEd Maste <emaste@FreeBSD.org>2015-07-03 16:57:06 +0000
commit5e95aa85bb660d45e9905ef1d7180b2678280660 (patch)
tree3c2e41c3be19b7fc7666ed45a5f91ec3b6e35f2a /source/DataFormatters
parent12bd4897ff0678fa663e09d78ebc22dd255ceb86 (diff)
Import LLDB as of upstream SVN 241361 (git 612c075f)vendor/lldb/lldb-r241361
Notes
Notes: svn path=/vendor/lldb/dist/; revision=285101 svn path=/vendor/lldb/lldb-r241361/; revision=285102; tag=vendor/lldb/lldb-r241361
Diffstat (limited to 'source/DataFormatters')
-rw-r--r--source/DataFormatters/CF.cpp2
-rw-r--r--source/DataFormatters/CXXFormatterFunctions.cpp7
-rw-r--r--source/DataFormatters/Cocoa.cpp2
-rw-r--r--source/DataFormatters/CoreMedia.cpp85
-rw-r--r--source/DataFormatters/DataVisualization.cpp2
-rw-r--r--source/DataFormatters/FormatCache.cpp2
-rw-r--r--source/DataFormatters/FormatManager.cpp73
-rw-r--r--source/DataFormatters/LibCxx.cpp4
-rw-r--r--source/DataFormatters/LibCxxInitializerList.cpp2
-rw-r--r--source/DataFormatters/LibCxxList.cpp2
-rw-r--r--source/DataFormatters/LibCxxMap.cpp2
-rw-r--r--source/DataFormatters/LibCxxUnorderedMap.cpp2
-rw-r--r--source/DataFormatters/LibCxxVector.cpp2
-rw-r--r--source/DataFormatters/LibStdcpp.cpp171
-rw-r--r--source/DataFormatters/NSArray.cpp2
-rw-r--r--source/DataFormatters/NSDictionary.cpp2
-rw-r--r--source/DataFormatters/NSIndexPath.cpp219
-rw-r--r--source/DataFormatters/NSSet.cpp2
-rw-r--r--source/DataFormatters/StringPrinter.cpp32
-rw-r--r--source/DataFormatters/TypeCategory.cpp2
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp2
-rw-r--r--source/DataFormatters/TypeFormat.cpp3
-rw-r--r--source/DataFormatters/TypeSummary.cpp2
-rw-r--r--source/DataFormatters/TypeSynthetic.cpp6
-rw-r--r--source/DataFormatters/ValueObjectPrinter.cpp28
-rw-r--r--source/DataFormatters/VectorType.cpp276
26 files changed, 593 insertions, 341 deletions
diff --git a/source/DataFormatters/CF.cpp b/source/DataFormatters/CF.cpp
index 483419e5ac3f..6ab9013268bd 100644
--- a/source/DataFormatters/CF.cpp
+++ b/source/DataFormatters/CF.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/CXXFormatterFunctions.cpp b/source/DataFormatters/CXXFormatterFunctions.cpp
index 5aa8289794c1..49eacee42f78 100644
--- a/source/DataFormatters/CXXFormatterFunctions.cpp
+++ b/source/DataFormatters/CXXFormatterFunctions.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -29,10 +27,13 @@
#include "lldb/Utility/ProcessStructReader.h"
#include <algorithm>
+
#if __ANDROID_NDK__
#include <sys/types.h>
#endif
+#include "lldb/Host/Time.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
@@ -317,7 +318,7 @@ lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Strea
return false;
ClangASTType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar);
- const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr);
+ const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
ReadStringAndDumpToStreamOptions options(valobj);
options.SetLocation(data_addr);
diff --git a/source/DataFormatters/Cocoa.cpp b/source/DataFormatters/Cocoa.cpp
index 137fd4f483cc..28f3d4f1d41b 100644
--- a/source/DataFormatters/Cocoa.cpp
+++ b/source/DataFormatters/Cocoa.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/CoreMedia.cpp b/source/DataFormatters/CoreMedia.cpp
new file mode 100644
index 000000000000..5c33c0b69f72
--- /dev/null
+++ b/source/DataFormatters/CoreMedia.cpp
@@ -0,0 +1,85 @@
+//===-- CoreMedia.cpp --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+
+#include "lldb/Core/Flags.h"
+#include "lldb/Symbol/ClangASTContext.h"
+
+#include <inttypes.h>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+bool
+lldb_private::formatters::CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+{
+ ClangASTContext *ast_ctx = ClangASTContext::GetASTContext(valobj.GetClangType().GetASTContext());
+ if (!ast_ctx)
+ return false;
+
+ // fetch children by offset to compensate for potential lack of debug info
+ auto int64_ty = ast_ctx->GetIntTypeFromBitSize(64, true);
+ auto int32_ty = ast_ctx->GetIntTypeFromBitSize(32, true);
+
+ auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true));
+ auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty, true));
+ auto flags_sp(valobj.GetSyntheticChildAtOffset(12, int32_ty, true));
+
+ if (!value_sp || !timescale_sp || !flags_sp)
+ return false;
+
+ auto value = value_sp->GetValueAsUnsigned(0);
+ auto timescale = (int32_t)timescale_sp->GetValueAsUnsigned(0); // the timescale specifies the fraction of a second each unit in the numerator occupies
+ auto flags = Flags(flags_sp->GetValueAsUnsigned(0) & 0x00000000000000FF); // the flags I need sit in the LSB
+
+ const unsigned int FlagPositiveInf = 4;
+ const unsigned int FlagNegativeInf = 8;
+ const unsigned int FlagIndefinite = 16;
+
+ if (flags.AnySet(FlagIndefinite))
+ {
+ stream.Printf("indefinite");
+ return true;
+ }
+
+ if (flags.AnySet(FlagPositiveInf))
+ {
+ stream.Printf("+oo");
+ return true;
+ }
+
+ if (flags.AnySet(FlagNegativeInf))
+ {
+ stream.Printf("-oo");
+ return true;
+ }
+
+ if (timescale == 0)
+ return false;
+
+ switch (timescale)
+ {
+ case 0:
+ return false;
+ case 1:
+ stream.Printf("%" PRId64 " seconds", value);
+ return true;
+ case 2:
+ stream.Printf("%" PRId64 " half seconds", value);
+ return true;
+ case 3:
+ stream.Printf("%" PRId64 " third%sof a second", value, value == 1 ? " " : "s ");
+ return true;
+ default:
+ stream.Printf("%" PRId64 " %" PRId32 "th%sof a second", value, timescale, value == 1 ? " " : "s ");
+ return true;
+ }
+}
diff --git a/source/DataFormatters/DataVisualization.cpp b/source/DataFormatters/DataVisualization.cpp
index 7ef0be50efe0..361254185b31 100644
--- a/source/DataFormatters/DataVisualization.cpp
+++ b/source/DataFormatters/DataVisualization.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/DataVisualization.h"
// C Includes
diff --git a/source/DataFormatters/FormatCache.cpp b/source/DataFormatters/FormatCache.cpp
index aaa4bc1f958a..748c6d80fbd2 100644
--- a/source/DataFormatters/FormatCache.cpp
+++ b/source/DataFormatters/FormatCache.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
// C Includes
// C++ Includes
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp
index ae52b3309ed8..47456ba5c45b 100644
--- a/source/DataFormatters/FormatManager.cpp
+++ b/source/DataFormatters/FormatManager.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/FormatManager.h"
// C Includes
@@ -18,7 +16,6 @@
#include "lldb/Core/Debugger.h"
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "llvm/ADT/STLExtras.h"
@@ -477,7 +474,7 @@ FormatManager::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp)
lldb::TypeCategoryImplSP
FormatManager::GetCategory (const ConstString& category_name,
- bool can_create)
+ bool can_create)
{
if (!category_name)
return GetCategory(m_default_category_name);
@@ -665,7 +662,8 @@ FormatManager::GetFormat (ValueObject& valobj,
log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded a chance.");
retval = GetHardcodedFormat(valobj, use_dynamic);
}
- else if (valobj_type)
+
+ if (valobj_type && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetFormat] Caching %p for type %s",
@@ -722,7 +720,8 @@ FormatManager::GetSummaryFormat (ValueObject& valobj,
log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving hardcoded a chance.");
retval = GetHardcodedSummaryFormat(valobj, use_dynamic);
}
- else if (valobj_type)
+
+ if (valobj_type && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",
@@ -780,7 +779,8 @@ FormatManager::GetSyntheticChildren (ValueObject& valobj,
log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving hardcoded a chance.");
retval = GetHardcodedSyntheticChildren(valobj, use_dynamic);
}
- else if (valobj_type)
+
+ if (valobj_type && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s",
@@ -825,7 +825,8 @@ FormatManager::GetValidator (ValueObject& valobj,
log->Printf("[FormatManager::GetValidator] Search failed. Giving hardcoded a chance.");
retval = GetHardcodedValidator(valobj, use_dynamic);
}
- else if (valobj_type)
+
+ if (valobj_type && (!retval || !retval->NonCacheable()))
{
if (log)
log->Printf("[FormatManager::GetValidator] Caching %p for type %s",
@@ -866,6 +867,7 @@ FormatManager::FormatManager() :
m_coreservices_category_name(ConstString("CoreServices")),
m_vectortypes_category_name(ConstString("VectorTypes")),
m_appkit_category_name(ConstString("AppKit")),
+ m_coremedia_category_name(ConstString("CoreMedia")),
m_hardcoded_formats(),
m_hardcoded_summaries(),
m_hardcoded_synthetics(),
@@ -876,6 +878,7 @@ FormatManager::FormatManager() :
LoadLibStdcppFormatters();
LoadLibcxxFormatters();
LoadObjCFormatters();
+ LoadCoreMediaFormatters();
LoadHardcodedFormatters();
EnableCategory(m_objc_category_name,TypeCategoryMap::Last);
@@ -883,6 +886,7 @@ FormatManager::FormatManager() :
EnableCategory(m_appkit_category_name,TypeCategoryMap::Last);
EnableCategory(m_coreservices_category_name,TypeCategoryMap::Last);
EnableCategory(m_coregraphics_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_coremedia_category_name,TypeCategoryMap::Last);
EnableCategory(m_gnu_cpp_category_name,TypeCategoryMap::Last);
EnableCategory(m_libcxx_category_name,TypeCategoryMap::Last);
EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last);
@@ -1152,19 +1156,23 @@ FormatManager::LoadSystemFormatters()
.SetShowMembersOneLiner(false)
.SetHideItemNames(false);
+ TypeSummaryImpl::Flags string_array_flags;
+ string_array_flags.SetCascades(false)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(string_flags, "${var%s}"));
- lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false),
+ lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(string_array_flags,
"${var%s}"));
lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
+ lldb::RegularExpressionSP any_size_wchar_arr(new RegularExpression("wchar_t \\[[0-9]+\\]"));
TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name);
@@ -1190,6 +1198,7 @@ FormatManager::LoadSystemFormatters()
AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
+ AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
@@ -1212,7 +1221,6 @@ FormatManager::LoadSystemFormatters()
fourchar_flags.SetCascades(true).SetSkipPointers(true).SetSkipReferences(true);
AddFormat(sys_category_sp, lldb::eFormatOSType, ConstString("FourCharCode"), fourchar_flags);
-
#endif
}
@@ -1563,6 +1571,25 @@ FormatManager::LoadObjCFormatters()
}
void
+FormatManager::LoadCoreMediaFormatters()
+{
+ TypeSummaryImpl::Flags cm_flags;
+ cm_flags.SetCascades(true)
+ .SetDontShowChildren(false)
+ .SetDontShowValue(false)
+ .SetHideItemNames(false)
+ .SetShowMembersOneLiner(false)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false);
+
+ TypeCategoryImpl::SharedPointer cm_category_sp = GetCategory(m_coremedia_category_name);
+
+#ifndef LLDB_DISABLE_PYTHON
+ AddCXXSummary(cm_category_sp, lldb_private::formatters::CMTimeSummaryProvider, "CMTime summary provider", ConstString("CMTime"), cm_flags);
+#endif // LLDB_DISABLE_PYTHON
+}
+
+void
FormatManager::LoadHardcodedFormatters()
{
{
@@ -1584,6 +1611,20 @@ FormatManager::LoadHardcodedFormatters()
}
{
// insert code to load synthetics here
+ m_hardcoded_synthetics.push_back(
+ [](lldb_private::ValueObject& valobj,
+ lldb::DynamicValueType,
+ FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
+ "vector_type synthetic children",
+ lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
+ if (valobj.GetClangType().IsVectorType(nullptr, nullptr))
+ {
+ if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled())
+ return formatter_sp;
+ }
+ return nullptr;
+ });
}
{
// insert code to load validators here
diff --git a/source/DataFormatters/LibCxx.cpp b/source/DataFormatters/LibCxx.cpp
index 728ad84341f0..a04b4ff6b8c7 100644
--- a/source/DataFormatters/LibCxx.cpp
+++ b/source/DataFormatters/LibCxx.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
@@ -266,7 +264,7 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update()
NULL,
NULL,
NULL,
- ValueObject::GetValueForExpressionPathOptions().DontCheckDotVsArrowSyntax().DontAllowSyntheticChildren(),
+ ValueObject::GetValueForExpressionPathOptions().DontCheckDotVsArrowSyntax().SetSyntheticChildrenTraversal(ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None),
NULL).get();
return false;
diff --git a/source/DataFormatters/LibCxxInitializerList.cpp b/source/DataFormatters/LibCxxInitializerList.cpp
index 91f1f90507a7..0dcef981e5e5 100644
--- a/source/DataFormatters/LibCxxInitializerList.cpp
+++ b/source/DataFormatters/LibCxxInitializerList.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/ConstString.h"
diff --git a/source/DataFormatters/LibCxxList.cpp b/source/DataFormatters/LibCxxList.cpp
index 5bb6ce07480f..f3e07fe7a017 100644
--- a/source/DataFormatters/LibCxxList.cpp
+++ b/source/DataFormatters/LibCxxList.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/LibCxxMap.cpp b/source/DataFormatters/LibCxxMap.cpp
index 82e747e2db08..2ff623284845 100644
--- a/source/DataFormatters/LibCxxMap.cpp
+++ b/source/DataFormatters/LibCxxMap.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/LibCxxUnorderedMap.cpp b/source/DataFormatters/LibCxxUnorderedMap.cpp
index da2a88966f5e..43669803195e 100644
--- a/source/DataFormatters/LibCxxUnorderedMap.cpp
+++ b/source/DataFormatters/LibCxxUnorderedMap.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/LibCxxVector.cpp b/source/DataFormatters/LibCxxVector.cpp
index d0e6be486d65..6ccb732f6779 100644
--- a/source/DataFormatters/LibCxxVector.cpp
+++ b/source/DataFormatters/LibCxxVector.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/ConstString.h"
diff --git a/source/DataFormatters/LibStdcpp.cpp b/source/DataFormatters/LibStdcpp.cpp
index b8f031ceeb2f..2b3bcb58afac 100644
--- a/source/DataFormatters/LibStdcpp.cpp
+++ b/source/DataFormatters/LibStdcpp.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
@@ -25,175 +23,6 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::LibstdcppVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_count(0),
-m_base_data_address(0),
-m_options()
-{
- if (valobj_sp)
- Update();
- m_options.SetCoerceToId(false);
- m_options.SetUnwindOnError(true);
- m_options.SetKeepInMemory(true);
- m_options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-}
-
-size_t
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::CalculateNumChildren ()
-{
- return m_count;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (idx >= m_count)
- return ValueObjectSP();
- if (m_base_data_address == 0 || m_count == 0)
- return ValueObjectSP();
- size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
- size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
- lldb::addr_t byte_location = m_base_data_address + byte_idx;
- ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
- if (!process_sp)
- return ValueObjectSP();
- uint8_t byte = 0;
- uint8_t mask = 0;
- Error err;
- size_t bytes_read = process_sp->ReadMemory(byte_location, &byte, 1, err);
- if (err.Fail() || bytes_read == 0)
- return ValueObjectSP();
- switch (bit_index)
- {
- case 0:
- mask = 1; break;
- case 1:
- mask = 2; break;
- case 2:
- mask = 4; break;
- case 3:
- mask = 8; break;
- case 4:
- mask = 16; break;
- case 5:
- mask = 32; break;
- case 6:
- mask = 64; break;
- case 7:
- mask = 128; break;
- default:
- return ValueObjectSP();
- }
- bool bit_set = ((byte & mask) != 0);
- Target& target(process_sp->GetTarget());
- ValueObjectSP retval_sp;
- if (bit_set)
- target.EvaluateExpression("(bool)true", NULL, retval_sp);
- else
- target.EvaluateExpression("(bool)false", NULL, retval_sp);
- StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- if (retval_sp)
- retval_sp->SetName(ConstString(name.GetData()));
- return retval_sp;
-}
-
-/*((std::vector<std::allocator<bool> >) vBool = {
- (std::_Bvector_base<std::allocator<bool> >) std::_Bvector_base<std::allocator<bool> > = {
- (std::_Bvector_base<std::allocator<bool> >::_Bvector_impl) _M_impl = {
- (std::_Bit_iterator) _M_start = {
- (std::_Bit_iterator_base) std::_Bit_iterator_base = {
- (_Bit_type *) _M_p = 0x0016b160
- (unsigned int) _M_offset = 0
- }
- }
- (std::_Bit_iterator) _M_finish = {
- (std::_Bit_iterator_base) std::_Bit_iterator_base = {
- (_Bit_type *) _M_p = 0x0016b16c
- (unsigned int) _M_offset = 16
- }
- }
- (_Bit_type *) _M_end_of_storage = 0x0016b170
- }
- }
- }
- */
-
-bool
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::Update()
-{
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-
- ValueObjectSP m_impl_sp(valobj_sp->GetChildMemberWithName(ConstString("_M_impl"), true));
- if (!m_impl_sp)
- return false;
-
- ValueObjectSP m_start_sp(m_impl_sp->GetChildMemberWithName(ConstString("_M_start"), true));
- ValueObjectSP m_finish_sp(m_impl_sp->GetChildMemberWithName(ConstString("_M_finish"), true));
-
- ValueObjectSP start_p_sp, finish_p_sp, finish_offset_sp;
-
- if (!m_start_sp || !m_finish_sp)
- return false;
-
- start_p_sp = m_start_sp->GetChildMemberWithName(ConstString("_M_p"), true);
- finish_p_sp = m_finish_sp->GetChildMemberWithName(ConstString("_M_p"), true);
- finish_offset_sp = m_finish_sp->GetChildMemberWithName(ConstString("_M_offset"), true);
-
- if (!start_p_sp || !finish_offset_sp || !finish_p_sp)
- return false;
-
- m_base_data_address = start_p_sp->GetValueAsUnsigned(0);
- if (!m_base_data_address)
- return false;
-
- lldb::addr_t end_data_address(finish_p_sp->GetValueAsUnsigned(0));
- if (!end_data_address)
- return false;
-
- if (end_data_address < m_base_data_address)
- return false;
- else
- m_count = finish_offset_sp->GetValueAsUnsigned(0) + (end_data_address-m_base_data_address)*8;
-
- return true;
-}
-
-bool
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_count || !m_base_data_address)
- return UINT32_MAX;
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEnd::~LibstdcppVectorBoolSyntheticFrontEnd ()
-{}
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibstdcppVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- if (!valobj_sp)
- return NULL;
- return (new LibstdcppVectorBoolSyntheticFrontEnd(valobj_sp));
-}
-
/*
(std::_Rb_tree_iterator<std::pair<const int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) ibeg = {
(_Base_ptr) _M_node = 0x0000000100103910 {
diff --git a/source/DataFormatters/NSArray.cpp b/source/DataFormatters/NSArray.cpp
index e242155f4fef..640982efdb3c 100644
--- a/source/DataFormatters/NSArray.cpp
+++ b/source/DataFormatters/NSArray.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/NSDictionary.cpp b/source/DataFormatters/NSDictionary.cpp
index fdac05192c46..30bc3acfbec7 100644
--- a/source/DataFormatters/NSDictionary.cpp
+++ b/source/DataFormatters/NSDictionary.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/NSIndexPath.cpp b/source/DataFormatters/NSIndexPath.cpp
index ee9583ef4cc1..363bd5c0527e 100644
--- a/source/DataFormatters/NSIndexPath.cpp
+++ b/source/DataFormatters/NSIndexPath.cpp
@@ -47,7 +47,7 @@ public:
virtual bool
Update()
{
- m_impl.m_mode = Mode::Invalid;
+ m_impl.Clear();
m_ast_ctx = ClangASTContext::GetASTContext(m_backend.GetClangType().GetASTContext());
if (!m_ast_ctx)
@@ -76,8 +76,8 @@ public:
if (descriptor->GetTaggedPointerInfo(&info_bits, &value_bits, &payload))
{
- m_impl.m_mode = Mode::Inlined;
m_impl.m_inlined.SetIndexes(payload, *process_sp);
+ m_impl.m_mode = Mode::Inlined;
}
else
{
@@ -191,104 +191,133 @@ protected:
}
struct InlinedIndexes {
- public:
- void SetIndexes(uint64_t value, Process& p)
- {
- m_indexes = value;
- _lengthForInlinePayload(p.GetAddressByteSize());
- m_process = &p;
- }
-
- size_t
- GetNumIndexes ()
- {
- return m_count;
- }
-
- lldb::ValueObjectSP
- GetIndexAtIndex (size_t idx, const ClangASTType& desired_type)
- {
- std::pair<uint64_t, bool> value(_indexAtPositionForInlinePayload(idx));
- if (!value.second)
- return nullptr;
- Value v;
- if (m_ptr_size == 8)
- {
- Scalar scalar( (unsigned long long)value.first );
- v = Value(scalar);
- }
- else
- {
- Scalar scalar( (unsigned int)value.first );
- v = Value(scalar);
- }
- v.SetClangType(desired_type);
- StreamString idx_name;
- idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- return ValueObjectConstResult::Create(m_process, v, ConstString(idx_name.GetData()));
- }
-
- private:
- uint64_t m_indexes;
- size_t m_count;
- uint32_t m_ptr_size;
- Process *m_process;
-
- // cfr. Foundation for the details of this code
- size_t _lengthForInlinePayload(uint32_t ptr_size) {
- m_ptr_size = ptr_size;
- if (m_ptr_size == 8)
- m_count = ((m_indexes >> 3) & 0x7);
- else
- m_count = ((m_indexes >> 3) & 0x3);
- return m_count;
- }
-
- std::pair<uint64_t, bool>
- _indexAtPositionForInlinePayload(size_t pos) {
- if (m_ptr_size == 8)
- {
- switch (pos) {
- case 5: return {((m_indexes >> 51) & 0x1ff),true};
- case 4: return {((m_indexes >> 42) & 0x1ff),true};
- case 3: return {((m_indexes >> 33) & 0x1ff),true};
- case 2: return {((m_indexes >> 24) & 0x1ff),true};
- case 1: return {((m_indexes >> 15) & 0x1ff),true};
- case 0: return {((m_indexes >> 6) & 0x1ff),true};
- }
- }
- else
- {
- switch (pos) {
- case 2: return {((m_indexes >> 23) & 0x1ff),true};
- case 1: return {((m_indexes >> 14) & 0x1ff),true};
- case 0: return {((m_indexes >> 5) & 0x1ff),true};
- }
- }
- return {0,false};
- }
+ public:
+ void SetIndexes(uint64_t value, Process& p)
+ {
+ m_indexes = value;
+ _lengthForInlinePayload(p.GetAddressByteSize());
+ m_process = &p;
+ }
+
+ size_t
+ GetNumIndexes ()
+ {
+ return m_count;
+ }
+
+ lldb::ValueObjectSP
+ GetIndexAtIndex (size_t idx, const ClangASTType& desired_type)
+ {
+ std::pair<uint64_t, bool> value(_indexAtPositionForInlinePayload(idx));
+ if (!value.second)
+ return nullptr;
+
+ Value v;
+ if (m_ptr_size == 8)
+ {
+ Scalar scalar( (unsigned long long)value.first );
+ v = Value(scalar);
+ }
+ else
+ {
+ Scalar scalar( (unsigned int)value.first );
+ v = Value(scalar);
+ }
+
+ v.SetClangType(desired_type);
- };
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+
+ return ValueObjectConstResult::Create(m_process, v, ConstString(idx_name.GetData()));
+ }
+
+ void
+ Clear ()
+ {
+ m_indexes = 0;
+ m_count = 0;
+ m_ptr_size = 0;
+ m_process = nullptr;
+ }
+
+ private:
+ uint64_t m_indexes;
+ size_t m_count;
+ uint32_t m_ptr_size;
+ Process *m_process;
+
+ // cfr. Foundation for the details of this code
+ size_t _lengthForInlinePayload(uint32_t ptr_size) {
+ m_ptr_size = ptr_size;
+ if (m_ptr_size == 8)
+ m_count = ((m_indexes >> 3) & 0x7);
+ else
+ m_count = ((m_indexes >> 3) & 0x3);
+ return m_count;
+ }
+
+ std::pair<uint64_t, bool>
+ _indexAtPositionForInlinePayload(size_t pos)
+ {
+ if (m_ptr_size == 8)
+ {
+ switch (pos) {
+ case 5: return {((m_indexes >> 51) & 0x1ff),true};
+ case 4: return {((m_indexes >> 42) & 0x1ff),true};
+ case 3: return {((m_indexes >> 33) & 0x1ff),true};
+ case 2: return {((m_indexes >> 24) & 0x1ff),true};
+ case 1: return {((m_indexes >> 15) & 0x1ff),true};
+ case 0: return {((m_indexes >> 6) & 0x1ff),true};
+ }
+ }
+ else
+ {
+ switch (pos) {
+ case 2: return {((m_indexes >> 23) & 0x1ff),true};
+ case 1: return {((m_indexes >> 14) & 0x1ff),true};
+ case 0: return {((m_indexes >> 5) & 0x1ff),true};
+ }
+ }
+ return {0,false};
+ }
+
+ };
struct OutsourcedIndexes {
- ValueObject *m_indexes;
- size_t m_count;
-
- lldb::ValueObjectSP
- GetIndexAtIndex (size_t idx)
- {
- if (m_indexes)
- {
- ValueObjectSP index_sp(m_indexes->GetSyntheticArrayMemberFromPointer(idx, true));
- return index_sp;
- }
- return nullptr;
- }
- };
+ ValueObject *m_indexes;
+ size_t m_count;
+
+ lldb::ValueObjectSP
+ GetIndexAtIndex (size_t idx)
+ {
+ if (m_indexes)
+ {
+ ValueObjectSP index_sp(m_indexes->GetSyntheticArrayMember(idx, true));
+ return index_sp;
+ }
+ return nullptr;
+ }
+
+ void
+ Clear ()
+ {
+ m_indexes = nullptr;
+ m_count = 0;
+ }
+ };
union {
- struct InlinedIndexes m_inlined;
- struct OutsourcedIndexes m_outsourced;
+ struct InlinedIndexes m_inlined;
+ struct OutsourcedIndexes m_outsourced;
};
+
+ void
+ Clear ()
+ {
+ m_mode = Mode::Invalid;
+ m_inlined.Clear();
+ m_outsourced.Clear();
+ }
} m_impl;
uint32_t m_ptr_size;
diff --git a/source/DataFormatters/NSSet.cpp b/source/DataFormatters/NSSet.cpp
index 194d1bd29ea1..116904ce99b4 100644
--- a/source/DataFormatters/NSSet.cpp
+++ b/source/DataFormatters/NSSet.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/CXXFormatterFunctions.h"
#include "lldb/Core/DataBufferHeap.h"
diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp
index 3af5931ad716..a011cd553d0c 100644
--- a/source/DataFormatters/StringPrinter.cpp
+++ b/source/DataFormatters/StringPrinter.cpp
@@ -181,12 +181,13 @@ GetPrintableImpl<StringElementType::ASCII> (uint8_t* buffer, uint8_t* buffer_end
break;
default:
if (isprint(*buffer))
- retval = {buffer,1};
+ retval = {buffer,1};
else
{
- retval = { new uint8_t[5],4,[] (const uint8_t* c) {delete[] c;} };
- sprintf((char*)retval.GetBytes(),"\\x%02x",*buffer);
- break;
+ uint8_t* data = new uint8_t[5];
+ sprintf((char*)data,"\\x%02x",*buffer);
+ retval = {data, 4, [] (const uint8_t* c) {delete[] c;} };
+ break;
}
}
@@ -288,8 +289,9 @@ GetPrintableImpl<StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end,
retval = {buffer,utf8_encoded_len};
else
{
- retval = { new uint8_t[11],10,[] (const uint8_t* c) {delete[] c;} };
- sprintf((char*)retval.GetBytes(),"\\U%08x",codepoint);
+ uint8_t* data = new uint8_t[11];
+ sprintf((char*)data,"\\U%08x",codepoint);
+ retval = { data,10,[] (const uint8_t* c) {delete[] c;} };
break;
}
}
@@ -352,8 +354,8 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
sourceSize = bufferSPSize/(origin_encoding / 4);
}
- SourceDataType *data_ptr = (SourceDataType*)data.GetDataStart();
- SourceDataType *data_end_ptr = data_ptr + sourceSize;
+ const SourceDataType *data_ptr = (const SourceDataType*)data.GetDataStart();
+ const SourceDataType *data_end_ptr = data_ptr + sourceSize;
while (data_ptr < data_end_ptr)
{
@@ -365,7 +367,7 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
data_ptr++;
}
- data_ptr = (SourceDataType*)data.GetDataStart();
+ data_ptr = (const SourceDataType*)data.GetDataStart();
lldb::DataBufferSP utf8_data_buffer_sp;
UTF8* utf8_data_ptr = nullptr;
@@ -376,7 +378,7 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
utf8_data_buffer_sp.reset(new DataBufferHeap(4*bufferSPSize,0));
utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
utf8_data_end_ptr = utf8_data_ptr + utf8_data_buffer_sp->GetByteSize();
- ConvertFunction ( (const SourceDataType**)&data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion );
+ ConvertFunction ( &data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion );
utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr
}
else
@@ -449,7 +451,6 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
{
assert(options.GetStream() && "need a Stream to print the string to");
Error my_error;
- size_t my_data_read;
ProcessSP process_sp(options.GetProcessSP());
@@ -467,7 +468,7 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0));
- my_data_read = process_sp->ReadCStringFromMemory(options.GetLocation(), (char*)buffer_sp->GetBytes(), size, my_error);
+ process_sp->ReadCStringFromMemory(options.GetLocation(), (char*)buffer_sp->GetBytes(), size, my_error);
if (my_error.Fail())
return false;
@@ -555,7 +556,7 @@ ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
sourceSize = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
needs_zero_terminator = true;
}
- else
+ else if (!options.GetIgnoreMaxLength())
sourceSize = std::min(sourceSize,process_sp->GetTarget().GetMaximumSizeOfStringSummary());
const int bufferSPSize = sourceSize * type_width;
@@ -568,11 +569,10 @@ ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
Error error;
char *buffer = reinterpret_cast<char *>(buffer_sp->GetBytes());
- size_t data_read = 0;
if (needs_zero_terminator)
- data_read = process_sp->ReadStringFromMemory(options.GetLocation(), buffer, bufferSPSize, error, type_width);
+ process_sp->ReadStringFromMemory(options.GetLocation(), buffer, bufferSPSize, error, type_width);
else
- data_read = process_sp->ReadMemoryFromInferior(options.GetLocation(), (char*)buffer_sp->GetBytes(), bufferSPSize, error);
+ process_sp->ReadMemoryFromInferior(options.GetLocation(), (char*)buffer_sp->GetBytes(), bufferSPSize, error);
if (error.Fail())
{
diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp
index 3df6884fe679..b05cea55ff51 100644
--- a/source/DataFormatters/TypeCategory.cpp
+++ b/source/DataFormatters/TypeCategory.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/TypeCategory.h"
// C Includes
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index ae34d0339011..96b9e6df8a47 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/DataFormatters/TypeCategoryMap.h"
#include "lldb/DataFormatters/FormatClasses.h"
diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp
index f07d8127d2b9..c4a65fea7da5 100644
--- a/source/DataFormatters/TypeFormat.cpp
+++ b/source/DataFormatters/TypeFormat.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
// C Includes
// C++ Includes
@@ -22,6 +20,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/DataFormatters/TypeFormat.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/ClangASTType.h"
diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp
index 4c9cd582e642..fa06f297f829 100644
--- a/source/DataFormatters/TypeSummary.cpp
+++ b/source/DataFormatters/TypeSummary.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
// C Includes
// C++ Includes
diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp
index b150b2bb6ee3..5bd8d30e4873 100644
--- a/source/DataFormatters/TypeSynthetic.cpp
+++ b/source/DataFormatters/TypeSynthetic.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
// C Includes
// C++ Includes
@@ -23,7 +21,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -196,7 +194,7 @@ ScriptedSyntheticChildren::FrontEnd::GetChildAtIndex (size_t idx)
bool
ScriptedSyntheticChildren::FrontEnd::IsValid ()
{
- return m_wrapper_sp.get() != nullptr && m_wrapper_sp->operator bool() && m_interpreter != nullptr;
+ return (m_wrapper_sp && m_wrapper_sp->IsValid() && m_interpreter);
}
size_t
diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp
index 5560ce2971e7..7c794ee2ddac 100644
--- a/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/source/DataFormatters/ValueObjectPrinter.cpp
@@ -21,6 +21,28 @@
using namespace lldb;
using namespace lldb_private;
+DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
+DumpValueObjectOptions()
+{
+ m_use_dynamic = valobj.GetDynamicValueType();
+ m_use_synthetic = valobj.IsSynthetic();
+}
+
+ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
+ Stream* s)
+{
+ if (valobj)
+ {
+ DumpValueObjectOptions options(*valobj);
+ Init (valobj,s,options,options.m_max_ptr_depth,0);
+ }
+ else
+ {
+ DumpValueObjectOptions options;
+ Init (valobj,s,options,options.m_max_ptr_depth,0);
+ }
+}
+
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options)
@@ -631,7 +653,11 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
uint32_t curr_ptr_depth = m_ptr_depth;
bool print_children = ShouldPrintChildren (is_failed_description,curr_ptr_depth);
- bool print_oneline = (curr_ptr_depth > 0 || options.m_show_types || !options.m_allow_oneliner_mode) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
+ bool print_oneline = (curr_ptr_depth > 0 ||
+ options.m_show_types ||
+ !options.m_allow_oneliner_mode ||
+ options.m_flat_output ||
+ options.m_show_location) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
if (print_children)
{
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
new file mode 100644
index 000000000000..57bf696ba4fa
--- /dev/null
+++ b/source/DataFormatters/VectorType.cpp
@@ -0,0 +1,276 @@
+//===-- VectorType.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTType.h"
+
+#include "lldb/Utility/LLDBAssert.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+static ClangASTType
+GetClangTypeForFormat (lldb::Format format,
+ ClangASTType element_type,
+ ClangASTContext *ast_ctx)
+{
+ lldbassert(ast_ctx && "ast_ctx needs to be not NULL");
+
+ switch (format)
+ {
+ case lldb::eFormatAddressInfo:
+ case lldb::eFormatPointer:
+ return ast_ctx->GetPointerSizedIntType(false);
+
+ case lldb::eFormatBoolean:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeBool);
+
+ case lldb::eFormatBytes:
+ case lldb::eFormatBytesWithASCII:
+ case lldb::eFormatChar:
+ case lldb::eFormatCharArray:
+ case lldb::eFormatCharPrintable:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+
+ case lldb::eFormatComplex /* lldb::eFormatComplexFloat */:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeFloatComplex);
+
+ case lldb::eFormatCString:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeChar).GetPointerType();
+
+ case lldb::eFormatFloat:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+
+ case lldb::eFormatHex:
+ case lldb::eFormatHexUppercase:
+ case lldb::eFormatOctal:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeInt);
+
+ case lldb::eFormatHexFloat:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeFloat);
+
+ case lldb::eFormatUnicode16:
+ case lldb::eFormatUnicode32:
+
+ case lldb::eFormatUnsigned:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedInt);
+
+ case lldb::eFormatVectorOfChar:
+ return ast_ctx->GetBasicType(lldb::eBasicTypeChar);
+
+ case lldb::eFormatVectorOfFloat32:
+ return ast_ctx->GetFloatTypeFromBitSize(32);
+
+ case lldb::eFormatVectorOfFloat64:
+ return ast_ctx->GetFloatTypeFromBitSize(64);
+
+ case lldb::eFormatVectorOfSInt16:
+ return ast_ctx->GetIntTypeFromBitSize(16, true);
+
+ case lldb::eFormatVectorOfSInt32:
+ return ast_ctx->GetIntTypeFromBitSize(32, true);
+
+ case lldb::eFormatVectorOfSInt64:
+ return ast_ctx->GetIntTypeFromBitSize(64, true);
+
+ case lldb::eFormatVectorOfSInt8:
+ return ast_ctx->GetIntTypeFromBitSize(8, true);
+
+ case lldb::eFormatVectorOfUInt128:
+ return ast_ctx->GetIntTypeFromBitSize(128, false);
+
+ case lldb::eFormatVectorOfUInt16:
+ return ast_ctx->GetIntTypeFromBitSize(16, false);
+
+ case lldb::eFormatVectorOfUInt32:
+ return ast_ctx->GetIntTypeFromBitSize(32, false);
+
+ case lldb::eFormatVectorOfUInt64:
+ return ast_ctx->GetIntTypeFromBitSize(64, false);
+
+ case lldb::eFormatVectorOfUInt8:
+ return ast_ctx->GetIntTypeFromBitSize(8, false);
+
+ case lldb::eFormatDefault:
+ return element_type;
+
+ case lldb::eFormatBinary:
+ case lldb::eFormatComplexInteger:
+ case lldb::eFormatDecimal:
+ case lldb::eFormatEnum:
+ case lldb::eFormatInstruction:
+ case lldb::eFormatOSType:
+ case lldb::eFormatVoid:
+ default:
+ return ast_ctx->GetIntTypeFromBitSize(8, false);
+ }
+}
+
+static lldb::Format
+GetItemFormatForFormat (lldb::Format format,
+ ClangASTType element_type)
+{
+ switch (format)
+ {
+ case lldb::eFormatVectorOfChar:
+ return lldb::eFormatChar;
+
+ case lldb::eFormatVectorOfFloat32:
+ case lldb::eFormatVectorOfFloat64:
+ return lldb::eFormatFloat;
+
+ case lldb::eFormatVectorOfSInt16:
+ case lldb::eFormatVectorOfSInt32:
+ case lldb::eFormatVectorOfSInt64:
+ case lldb::eFormatVectorOfSInt8:
+ return lldb::eFormatDecimal;
+
+ case lldb::eFormatVectorOfUInt128:
+ case lldb::eFormatVectorOfUInt16:
+ case lldb::eFormatVectorOfUInt32:
+ case lldb::eFormatVectorOfUInt64:
+ case lldb::eFormatVectorOfUInt8:
+ return lldb::eFormatUnsigned;
+
+ case lldb::eFormatBinary:
+ case lldb::eFormatComplexInteger:
+ case lldb::eFormatDecimal:
+ case lldb::eFormatEnum:
+ case lldb::eFormatInstruction:
+ case lldb::eFormatOSType:
+ case lldb::eFormatVoid:
+ return eFormatHex;
+
+ case lldb::eFormatDefault:
+ {
+ // special case the (default, char) combination to actually display as an integer value
+ // most often, you won't want to see the ASCII characters... (and if you do, eFormatChar is a keystroke away)
+ bool is_char = element_type.IsCharType();
+ bool is_signed = false;
+ element_type.IsIntegerType(is_signed);
+ return is_char ? (is_signed ? lldb::eFormatDecimal : eFormatHex) : format;
+ }
+ break;
+
+ default:
+ return format;
+ }
+}
+
+static size_t
+CalculateNumChildren (ClangASTType container_type,
+ ClangASTType element_type,
+ lldb_private::ExecutionContextScope *exe_scope = nullptr // does not matter here because all we trade in are basic types
+ )
+{
+ auto container_size = container_type.GetByteSize(exe_scope);
+ auto element_size = element_type.GetByteSize(exe_scope);
+
+ if (element_size)
+ {
+ if (container_size % element_size)
+ return 0;
+ return container_size / element_size;
+ }
+ return 0;
+}
+
+namespace lldb_private {
+ namespace formatters {
+
+ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd
+ {
+ public:
+ VectorTypeSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
+ SyntheticChildrenFrontEnd(*valobj_sp),
+ m_parent_format (eFormatInvalid),
+ m_item_format(eFormatInvalid),
+ m_child_type(),
+ m_num_children(0)
+ {}
+
+ virtual size_t
+ CalculateNumChildren ()
+ {
+ return m_num_children;
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (size_t idx)
+ {
+ if (idx >= CalculateNumChildren())
+ return lldb::ValueObjectSP();
+ auto offset = idx * m_child_type.GetByteSize(nullptr);
+ ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset(offset, m_child_type, true));
+ if (!child_sp)
+ return child_sp;
+
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ child_sp->SetName( ConstString( idx_name.GetData() ) );
+
+ child_sp->SetFormat(m_item_format);
+
+ return child_sp;
+ }
+
+ virtual bool
+ Update()
+ {
+ m_parent_format = m_backend.GetFormat();
+ ClangASTType parent_type(m_backend.GetClangType());
+ ClangASTType element_type;
+ parent_type.IsVectorType(&element_type, nullptr);
+ m_child_type = ::GetClangTypeForFormat(m_parent_format, element_type, ClangASTContext::GetASTContext(parent_type.GetASTContext()));
+ m_num_children = ::CalculateNumChildren(parent_type,
+ m_child_type);
+ m_item_format = GetItemFormatForFormat(m_parent_format,
+ m_child_type);
+ return false;
+ }
+
+ virtual bool
+ MightHaveChildren ()
+ {
+ return true;
+ }
+
+ virtual size_t
+ GetIndexOfChildWithName (const ConstString &name)
+ {
+ const char* item_name = name.GetCString();
+ uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+ }
+
+ virtual
+ ~VectorTypeSyntheticFrontEnd () {}
+
+ private:
+ lldb::Format m_parent_format;
+ lldb::Format m_item_format;
+ ClangASTType m_child_type;
+ size_t m_num_children;
+ };
+ }
+}
+
+lldb_private::SyntheticChildrenFrontEnd*
+lldb_private::formatters::VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+{
+ if (!valobj_sp)
+ return NULL;
+ return (new VectorTypeSyntheticFrontEnd(valobj_sp));
+}