forked from OSchip/llvm-project
Add an LLDB summary for CMTime. Fixes rdar://15370376
llvm-svn: 228759
This commit is contained in:
parent
c9c9c3489a
commit
bb557065f6
|
@ -186,6 +186,9 @@ namespace lldb_private {
|
|||
extern template bool
|
||||
ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
|
||||
|
||||
bool
|
||||
CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
|
||||
|
||||
SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
|
||||
|
||||
SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
|
||||
|
|
|
@ -287,6 +287,7 @@ private:
|
|||
ConstString m_coreservices_category_name;
|
||||
ConstString m_vectortypes_category_name;
|
||||
ConstString m_appkit_category_name;
|
||||
ConstString m_coremedia_category_name;
|
||||
|
||||
HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats;
|
||||
HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries;
|
||||
|
@ -326,6 +327,9 @@ private:
|
|||
|
||||
void
|
||||
LoadObjCFormatters ();
|
||||
|
||||
void
|
||||
LoadCoreMediaFormatters ();
|
||||
|
||||
void
|
||||
LoadHardcodedFormatters ();
|
||||
|
|
|
@ -784,6 +784,7 @@
|
|||
9475C18F14E5F858001BFC6D /* SBTypeNameSpecifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18C14E5F826001BFC6D /* SBTypeNameSpecifier.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 947A1D621616476A0017C8D1 /* CommandObjectPlugin.cpp */; };
|
||||
947A1D651616476B0017C8D1 /* CommandObjectPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 947A1D631616476A0017C8D1 /* CommandObjectPlugin.h */; };
|
||||
9492E2A51A8AC11000295BBD /* CoreMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9492E2A41A8AC11000295BBD /* CoreMedia.cpp */; };
|
||||
949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */; };
|
||||
94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */; };
|
||||
94BA8B6D176F8C9B005A91B5 /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94BA8B6C176F8C9B005A91B5 /* Range.cpp */; };
|
||||
|
@ -2420,6 +2421,7 @@
|
|||
9475C18D14E5F834001BFC6D /* SBTypeNameSpecifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeNameSpecifier.cpp; path = source/API/SBTypeNameSpecifier.cpp; sourceTree = "<group>"; };
|
||||
947A1D621616476A0017C8D1 /* CommandObjectPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectPlugin.cpp; path = source/Commands/CommandObjectPlugin.cpp; sourceTree = "<group>"; };
|
||||
947A1D631616476A0017C8D1 /* CommandObjectPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectPlugin.h; path = source/Commands/CommandObjectPlugin.h; sourceTree = "<group>"; };
|
||||
9492E2A41A8AC11000295BBD /* CoreMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CoreMedia.cpp; path = source/DataFormatters/CoreMedia.cpp; sourceTree = "<group>"; };
|
||||
949ADF001406F62E004833E1 /* ValueObjectConstResultImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResultImpl.h; path = include/lldb/Core/ValueObjectConstResultImpl.h; sourceTree = "<group>"; };
|
||||
949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResultImpl.cpp; path = source/Core/ValueObjectConstResultImpl.cpp; sourceTree = "<group>"; };
|
||||
94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = "<group>"; };
|
||||
|
@ -4969,6 +4971,7 @@
|
|||
children = (
|
||||
94CD704B16F8DDEA00CF1E42 /* CF.cpp */,
|
||||
94CD704C16F8DDEA00CF1E42 /* Cocoa.cpp */,
|
||||
9492E2A41A8AC11000295BBD /* CoreMedia.cpp */,
|
||||
94CB255F16B069800059775D /* CXXFormatterFunctions.h */,
|
||||
94CB255716B069770059775D /* CXXFormatterFunctions.cpp */,
|
||||
94CB256016B069800059775D /* DataVisualization.h */,
|
||||
|
@ -6057,6 +6060,7 @@
|
|||
268900EB13353E6F00698AC0 /* ExecutionContext.cpp in Sources */,
|
||||
268900EC13353E6F00698AC0 /* LanguageRuntime.cpp in Sources */,
|
||||
268900ED13353E6F00698AC0 /* ObjCLanguageRuntime.cpp in Sources */,
|
||||
9492E2A51A8AC11000295BBD /* CoreMedia.cpp in Sources */,
|
||||
268900EE13353E6F00698AC0 /* PathMappingList.cpp in Sources */,
|
||||
268900EF13353E6F00698AC0 /* Platform.cpp in Sources */,
|
||||
268900F013353E6F00698AC0 /* Process.cpp in Sources */,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
@ -1562,6 +1564,23 @@ FormatManager::LoadObjCFormatters()
|
|||
vector_flags);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue