1 //===-- CoreMedia.cpp --------------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #include "CoreMedia.h"
13 #include "lldb/Utility/Flags.h"
15 #include "lldb/Symbol/TypeSystem.h"
16 #include "lldb/Target/Target.h"
20 using namespace lldb_private;
21 using namespace lldb_private::formatters;
23 bool lldb_private::formatters::CMTimeSummaryProvider(
24 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
25 CompilerType type = valobj.GetCompilerType();
29 TypeSystem *type_system =
30 valobj.GetExecutionContextRef()
32 ->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC);
36 // fetch children by offset to compensate for potential lack of debug info
38 type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64);
40 type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 32);
42 auto value_sp(valobj.GetSyntheticChildAtOffset(0, int64_ty, true));
43 auto timescale_sp(valobj.GetSyntheticChildAtOffset(8, int32_ty, true));
44 auto flags_sp(valobj.GetSyntheticChildAtOffset(12, int32_ty, true));
46 if (!value_sp || !timescale_sp || !flags_sp)
49 auto value = value_sp->GetValueAsUnsigned(0);
50 auto timescale = (int32_t)timescale_sp->GetValueAsUnsigned(
51 0); // the timescale specifies the fraction of a second each unit in the
53 auto flags = Flags(flags_sp->GetValueAsUnsigned(0) &
54 0x00000000000000FF); // the flags I need sit in the LSB
56 const unsigned int FlagPositiveInf = 4;
57 const unsigned int FlagNegativeInf = 8;
58 const unsigned int FlagIndefinite = 16;
60 if (flags.AnySet(FlagIndefinite)) {
61 stream.Printf("indefinite");
65 if (flags.AnySet(FlagPositiveInf)) {
70 if (flags.AnySet(FlagNegativeInf)) {
82 stream.Printf("%" PRId64 " seconds", value);
85 stream.Printf("%" PRId64 " half seconds", value);
88 stream.Printf("%" PRId64 " third%sof a second", value,
89 value == 1 ? " " : "s ");
92 stream.Printf("%" PRId64 " %" PRId32 "th%sof a second", value, timescale,
93 value == 1 ? " " : "s ");