summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-02-10 23:02:25 +0000
committerEnrico Granata <egranata@apple.com>2015-02-10 23:02:25 +0000
commitbb557065f60fa03e7a46a0b69bc0abea6ae46ca4 (patch)
tree147af4d700cc99f43508c660dc572961cf2399ba /lldb/source/DataFormatters
parentc9c9c3489aa8a7218deeae9024c96482cbfc9dfa (diff)
downloadbcm5719-llvm-bb557065f60fa03e7a46a0b69bc0abea6ae46ca4.tar.gz
bcm5719-llvm-bb557065f60fa03e7a46a0b69bc0abea6ae46ca4.zip
Add an LLDB summary for CMTime. Fixes rdar://15370376
llvm-svn: 228759
Diffstat (limited to 'lldb/source/DataFormatters')
-rw-r--r--lldb/source/DataFormatters/CoreMedia.cpp85
-rw-r--r--lldb/source/DataFormatters/FormatManager.cpp19
2 files changed, 104 insertions, 0 deletions
diff --git a/lldb/source/DataFormatters/CoreMedia.cpp b/lldb/source/DataFormatters/CoreMedia.cpp
new file mode 100644
index 00000000000..003d01f1569
--- /dev/null
+++ b/lldb/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 " of a second", value, timescale);
+ return true;
+ }
+}
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index ae52b3309ed..324f05b8f6a 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -866,6 +866,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 +877,7 @@ FormatManager::FormatManager() :
LoadLibStdcppFormatters();
LoadLibcxxFormatters();
LoadObjCFormatters();
+ LoadCoreMediaFormatters();
LoadHardcodedFormatters();
EnableCategory(m_objc_category_name,TypeCategoryMap::Last);
@@ -1563,6 +1565,23 @@ 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);
+
+ AddCXXSummary(cm_category_sp, lldb_private::formatters::CMTimeSummaryProvider, "CMTime summary provider", ConstString("CMTime"), cm_flags);
+}
+
+void
FormatManager::LoadHardcodedFormatters()
{
{
OpenPOWER on IntegriCloud