22 : m_orig_valobj(valobj) {
29 : m_orig_valobj(valobj) {
37 : m_orig_valobj(valobj) {
38 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
50 assert(
m_stream &&
"cannot print to a NULL Stream");
64 printed_instance_pointers
65 ? printed_instance_pointers
87 bool value_printed =
false;
88 bool summary_printed =
false;
102 assert(
m_cached_valobj &&
"ValueObjectPrinter must have a valid ValueObject");
111 if (update_success) {
145 "SetupMostSpecialized value must compute a valid ValueObject");
159 const char *root_valobj_name =
163 return root_valobj_name ? root_valobj_name :
"";
214 eTypeInstanceIsPointer) != 0
231 bool show_type =
true;
263 std::string type_name_str(type_name.
GetCString());
265 for (
auto iter = type_name_str.find(
" *"); iter != std::string::npos;
266 iter = type_name_str.find(
" *")) {
267 type_name_str.erase(iter, 2);
270 typeName << type_name_str.c_str();
283 bool decl_printed =
false;
308 decl_print_options, dest_stream)) {
316 if (!typeName.
Empty())
318 if (!varName.
Empty())
350 if (type_flags.
AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
351 return type_flags.
AllClear(eTypeIsBuiltIn);
356 std::string &summary,
357 std::string &
error) {
369 value.assign(val_cstr);
373 error.assign(err_cstr);
384 summary.assign(lang_plugin->GetNilReferenceSummaryString().str());
388 summary.assign(
"NULL");
391 summary.assign(
"<uninitialized>");
398 const char *sum_cstr =
401 summary.assign(sum_cstr);
407 bool &summary_printed) {
408 bool error_printed =
false;
411 m_error.assign(
"out of scope");
426 error_printed =
true;
435 const bool has_nil_or_uninitialized_summary =
437 if (!has_nil_or_uninitialized_summary && !
m_value.empty() &&
449 value_printed =
true;
457 summary_printed =
true;
461 return !error_printed;
465 bool summary_printed) {
472 const char *object_desc =
nullptr;
473 if (value_printed || summary_printed)
477 if (object_desc && *object_desc) {
479 size_t object_end = strlen(object_desc) - 1;
480 if (object_desc[object_end] ==
'\n')
485 }
else if (!value_printed && !summary_printed)
507 const bool is_ref = IsRef();
508 const bool is_ptr = IsPtr();
509 const bool is_uninit = IsUninitialized();
515 if (HasReachedMaximumDepth())
520 if (m_options.m_pointer_as_array)
523 if (m_options.m_use_objc)
526 bool print_children =
true;
529 print_children = type_summary->DoesPrintChildren(&valobj);
538 if (is_ptr || is_ref) {
545 const bool is_root_level = m_curr_depth == 0;
547 if (is_ref && is_root_level && print_children) {
558 return print_children || m_summary.empty();
571 return GetMostSpecializedValue();
575 bool summary_printed) {
576 if (m_options.m_flat_output) {
577 if (ShouldPrintValueObject())
580 if (ShouldPrintValueObject()) {
582 m_stream->PutCString(
": ");
583 }
else if (value_printed || summary_printed || ShouldShowName()) {
584 m_stream->PutChar(
' ');
586 m_stream->PutCString(
"{\n");
588 m_stream->IndentMore();
595 const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
596 const bool does_consume_ptr_depth =
597 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
600 child_options.
SetFormat(m_options.m_format)
608 consumed_summary_depth
612 if (child_sp.get()) {
613 auto ptr_depth = curr_ptr_depth;
614 if (does_consume_ptr_depth)
618 ptr_depth, m_curr_depth + 1,
619 m_printed_instance_pointers);
624llvm::Expected<uint32_t>
626 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
628 if (m_options.m_pointer_as_array)
629 return m_options.m_pointer_as_array.m_element_count;
632 if (!num_children_or_err)
633 return num_children_or_err;
634 uint32_t num_children = *num_children_or_err;
635 print_dotdotdot =
false;
637 const size_t max_num_children = GetMostSpecializedValue()
639 ->GetMaximumNumberOfChildrenToDisplay();
641 if (num_children > max_num_children && !m_options.m_ignore_cap) {
642 print_dotdotdot =
true;
643 return max_num_children;
650 if (!m_options.m_flat_output) {
651 if (print_dotdotdot) {
652 GetMostSpecializedValue()
655 .GetCommandInterpreter()
656 .ChildrenTruncated();
657 m_stream->Indent(
"...\n");
659 m_stream->IndentLess();
660 m_stream->Indent(
"}\n");
665 bool summary_printed) {
666 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
671 if (!m_options.m_reveal_empty_aggregates) {
672 if (value_printed || summary_printed)
679 if (m_val_summary_ok)
687 return base + logical * stride;
692 if (m_options.m_pointer_as_array) {
696 m_options.m_pointer_as_array.m_base_element,
697 m_options.m_pointer_as_array.m_stride, idx),
706 bool value_printed,
bool summary_printed,
708 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
710 bool print_dotdotdot =
false;
711 auto num_children_or_err = GetMaxNumChildrenToPrint(print_dotdotdot);
712 if (!num_children_or_err) {
713 *m_stream <<
" <" << llvm::toString(num_children_or_err.takeError()) <<
'>';
716 uint32_t num_children = *num_children_or_err;
718 bool any_children_printed =
false;
720 for (
size_t idx = 0; idx < num_children; ++idx) {
721 if (
ValueObjectSP child_sp = GenerateChild(synth_valobj, idx)) {
722 if (m_options.m_child_printing_decider &&
723 !m_options.m_child_printing_decider(child_sp->GetName()))
725 if (!any_children_printed) {
726 PrintChildrenPreamble(value_printed, summary_printed);
727 any_children_printed =
true;
729 PrintChild(child_sp, curr_ptr_depth);
733 if (any_children_printed)
734 PrintChildrenPostamble(print_dotdotdot);
736 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
737 if (ShouldPrintValueObject())
738 m_stream->PutCString(
" {}\n");
744 }
else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
746 if (ShouldPrintValueObject()) {
749 if (GetMostSpecializedValue().DoesProvideSyntheticValue() ||
750 !ShouldExpandEmptyAggregates())
751 m_stream->PutCString(
"\n");
753 m_stream->PutCString(
" {}\n");
756 if (ShouldPrintValueObject())
762 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
764 bool print_dotdotdot =
false;
765 auto num_children_or_err = GetMaxNumChildrenToPrint(print_dotdotdot);
766 if (!num_children_or_err) {
767 *m_stream <<
'<' << llvm::toString(num_children_or_err.takeError()) <<
'>';
770 uint32_t num_children = *num_children_or_err;
773 m_stream->PutChar(
'(');
775 bool did_print_children =
false;
776 for (uint32_t idx = 0; idx < num_children; ++idx) {
779 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
780 m_options.m_use_dynamic, m_options.m_use_synthetic);
782 if (m_options.m_child_printing_decider &&
783 !m_options.m_child_printing_decider(child_sp->GetName()))
785 if (idx && did_print_children)
786 m_stream->PutCString(
", ");
787 did_print_children =
true;
789 const char *name = child_sp.get()->GetName().AsCString();
791 m_stream->PutCString(name);
792 m_stream->PutCString(
" = ");
795 child_sp->DumpPrintableRepresentation(
803 m_stream->PutCString(
", ...)");
805 m_stream->PutChar(
')');
811 bool summary_printed) {
812 PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
816 const bool print_children = ShouldPrintChildren(curr_ptr_depth);
817 const bool print_oneline =
819 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
820 (m_options.m_pointer_as_array) || m_options.m_show_location)
823 if (print_children && IsInstancePointer()) {
825 if (m_printed_instance_pointers->count(instance_ptr_value)) {
827 m_stream->PutCString(
" {...}\n");
831 m_printed_instance_pointers->emplace(instance_ptr_value);
835 if (print_children) {
837 m_stream->PutChar(
' ');
838 PrintChildrenOneLiner(
false);
841 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
842 }
else if (HasReachedMaximumDepth() && IsAggregate() &&
843 ShouldPrintValueObject()) {
844 m_stream->PutCString(
"{...}\n");
849 if (m_options.m_max_depth_is_default)
852 .GetCommandInterpreter()
853 .SetReachedMaximumDepth();
859 return m_curr_depth >= m_options.m_max_depth;
863 if (m_curr_depth == 0)
864 return !m_options.m_hide_root_name && !m_options.m_hide_name;
865 return !m_options.m_hide_name;
static llvm::raw_ostream & error(Stream &strm)
static bool IsPointerValue(const CompilerType &type)
static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride, size_t logical)
Generic representation of a type in a programming language.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
static bool ShouldPrintAsOneLiner(ValueObject &valobj)
DumpValueObjectOptions & SetHideName(bool hide_name=false)
uint32_t m_omit_summary_depth
lldb::DynamicValueType m_use_dynamic
DumpValueObjectOptions & SetSummary(lldb::TypeSummaryImplSP summary=lldb::TypeSummaryImplSP())
bool m_hide_pointer_value
std::string m_root_valobj_name
bool m_use_type_display_name
bool m_scope_already_checked
PointerDepth m_max_ptr_depth
DumpValueObjectOptions & SetOmitSummaryDepth(uint32_t depth=0)
PointerAsArraySettings m_pointer_as_array
DumpValueObjectOptions & SetRootValueObjectName(const char *name=nullptr)
DumpValueObjectOptions & SetFormat(lldb::Format format=lldb::eFormatDefault)
DumpValueObjectOptions & SetScopeChecked(bool check=true)
lldb::TypeSummaryImplSP m_summary_sp
DeclPrintingHelper m_decl_printing_helper
DumpValueObjectOptions & SetHideValue(bool hide_value=false)
lldb::LanguageType m_varformat_language
DumpValueObjectOptions & SetElementCount(uint32_t element_count=0)
bool AllClear(ValueType mask) const
Test if all bits in mask are clear.
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
static Language * FindPlugin(lldb::LanguageType language)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
virtual bool DoesPrintEmptyAggregates() const
virtual bool DoesPrintValue(ValueObject *valobj) const
bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
void PrintChildrenPreamble(bool value_printed, bool summary_printed)
std::shared_ptr< InstancePointersSet > InstancePointersSetSP
ValueObject & m_orig_valobj
ValueObjectPrinter(ValueObject &valobj, Stream *s)
The ValueObjectPrinter is a one-shot printer for ValueObjects.
LazyBool m_is_instance_ptr
bool ShouldPrintValueObject()
std::pair< TypeSummaryImpl *, bool > m_summary_formatter
void PrintChild(lldb::ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
TypeSummaryImpl * GetSummaryFormatter(bool null_if_omitted=true)
ValueObject & GetMostSpecializedValue()
Cache the ValueObject we are actually going to print.
void PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
Stream * m_stream
Cache the current "most specialized" value.
bool HasReachedMaximumDepth()
DumpValueObjectOptions m_options
bool ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool ShouldShowName() const
DumpValueObjectOptions::PointerDepth m_ptr_depth
void SetupMostSpecializedValue()
ValueObject & GetValueObjectForChildrenGeneration()
void PrintChildrenPostamble(bool print_dotdotdot)
CompilerType m_compiler_type
bool ShouldExpandEmptyAggregates()
bool CheckScopeIfNeeded()
lldb::ValueObjectSP GenerateChild(ValueObject &synth_valobj, size_t idx)
InstancePointersSetSP m_printed_instance_pointers
void Init(ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth, InstancePointersSetSP printed_instance_pointers)
bool PrintLocationIfNeeded()
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
const char * GetRootNameForDisplay()
bool PrintChildrenOneLiner(bool hide_names)
ValueObject * m_cached_valobj
std::set< uint64_t > InstancePointersSet
void GetValueSummaryError(std::string &value, std::string &summary, std::string &error)
bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed)
const char * GetDescriptionForDisplay()
llvm::Expected< uint32_t > GetMaxNumChildrenToPrint(bool &print_dotdotdot)
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
lldb::TypeSummaryImplSP GetSummaryFormat()
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
CompilerType GetCompilerType()
lldb::ValueObjectSP GetSyntheticValue()
lldb::Format GetFormat() const
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
llvm::Expected< uint32_t > GetNumChildren(uint32_t max=UINT32_MAX)
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType)
virtual ConstString GetDisplayTypeName()
virtual bool IsBaseClass()
bool IsUninitializedReference()
bool UpdateValueIfNeeded(bool update_format=true)
const Status & GetError()
lldb::TargetSP GetTargetSP() const
virtual const char * GetValueAsCString()
ConstString GetName() const
virtual lldb::ValueObjectSP GetStaticValue()
virtual ConstString GetQualifiedTypeName()
const char * GetObjectDescription()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
const char * GetSummaryAsCString(lldb::LanguageType lang=lldb::eLanguageTypeUnknown)
@ eValueObjectRepresentationStyleSummary
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool IsSynthetic()
const Value & GetValue() const
virtual lldb::LanguageType GetPreferredDisplayLanguage()
const CompilerType & GetCompilerType()
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
enum lldb_private::DumpValueObjectOptions::PointerDepth::Mode m_mode
PointerDepth Decremented() const
bool CanAllowExpansion() const