40 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
54 assert(
m_stream &&
"cannot print to a NULL Stream");
68 printed_instance_pointers
69 ? printed_instance_pointers
96 bool value_printed =
false;
97 bool summary_printed =
false;
114 if (!update_success) {
170 return root_valobj_name ? root_valobj_name :
"";
218 eTypeInstanceIsPointer) != 0
235 bool show_type =
true;
265 std::string type_name_str(type_name.
GetCString());
267 for (
auto iter = type_name_str.find(
" *"); iter != std::string::npos;
268 iter = type_name_str.find(
" *")) {
269 type_name_str.erase(iter, 2);
272 typeName << type_name_str.c_str();
285 bool decl_printed =
false;
310 decl_print_options, dest_stream)) {
318 if (!typeName.
Empty())
320 if (!varName.
Empty())
351 if (type_flags.
AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
352 return type_flags.
AllClear(eTypeIsBuiltIn);
357 std::string &summary,
358 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;
434 const bool has_nil_or_uninitialized_summary =
436 if (!has_nil_or_uninitialized_summary && !
m_value.empty() &&
448 value_printed =
true;
456 summary_printed =
true;
460 return !error_printed;
464 bool summary_printed) {
471 const char *object_desc =
nullptr;
472 if (value_printed || summary_printed)
476 if (object_desc && *object_desc) {
478 size_t object_end = strlen(object_desc) - 1;
479 if (object_desc[object_end] ==
'\n')
484 }
else if (!value_printed && !summary_printed)
506 const bool is_ref = IsRef();
507 const bool is_ptr = IsPtr();
508 const bool is_uninit = IsUninitialized();
514 if (HasReachedMaximumDepth())
519 if (m_options.m_pointer_as_array)
522 if (m_options.m_use_objc)
525 bool print_children =
true;
527 print_children = type_summary->DoesPrintChildren(m_valobj);
536 if (is_ptr || is_ref) {
540 if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
543 const bool is_root_level = m_curr_depth == 0;
545 if (is_ref && is_root_level && print_children) {
556 return print_children || m_summary.empty();
573 bool summary_printed) {
574 if (m_options.m_flat_output) {
575 if (ShouldPrintValueObject())
578 if (ShouldPrintValueObject()) {
580 m_stream->PutCString(
": ");
581 }
else if (value_printed || summary_printed || ShouldShowName()) {
582 m_stream->PutChar(
' ');
584 m_stream->PutCString(
"{\n");
586 m_stream->IndentMore();
593 const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
594 const bool does_consume_ptr_depth =
595 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
598 child_options.
SetFormat(m_options.m_format)
606 consumed_summary_depth
610 if (child_sp.get()) {
611 auto ptr_depth = curr_ptr_depth;
612 if (does_consume_ptr_depth)
616 ptr_depth, m_curr_depth + 1,
617 m_printed_instance_pointers);
623 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
625 if (m_options.m_pointer_as_array)
626 return m_options.m_pointer_as_array.m_element_count;
629 print_dotdotdot =
false;
631 const size_t max_num_children =
632 m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
634 if (num_children > max_num_children && !m_options.m_ignore_cap) {
635 print_dotdotdot =
true;
636 return max_num_children;
643 if (!m_options.m_flat_output) {
644 if (print_dotdotdot) {
645 m_valobj->GetTargetSP()
647 .GetCommandInterpreter()
648 .ChildrenTruncated();
649 m_stream->Indent(
"...\n");
651 m_stream->IndentLess();
652 m_stream->Indent(
"}\n");
657 bool summary_printed) {
658 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
663 if (!m_options.m_reveal_empty_aggregates) {
664 if (value_printed || summary_printed)
671 if (m_val_summary_ok)
679 return base + logical * stride;
684 if (m_options.m_pointer_as_array) {
688 m_options.m_pointer_as_array.m_base_element,
689 m_options.m_pointer_as_array.m_stride, idx),
698 bool value_printed,
bool summary_printed,
700 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
702 bool print_dotdotdot =
false;
703 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
705 bool any_children_printed =
false;
707 for (
size_t idx = 0; idx < num_children; ++idx) {
708 if (
ValueObjectSP child_sp = GenerateChild(synth_m_valobj, idx)) {
709 if (m_options.m_child_printing_decider &&
710 !m_options.m_child_printing_decider(child_sp->GetName()))
712 if (!any_children_printed) {
713 PrintChildrenPreamble(value_printed, summary_printed);
714 any_children_printed =
true;
716 PrintChild(child_sp, curr_ptr_depth);
720 if (any_children_printed)
721 PrintChildrenPostamble(print_dotdotdot);
723 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
724 if (ShouldPrintValueObject())
725 m_stream->PutCString(
" {}\n");
731 }
else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
733 if (ShouldPrintValueObject()) {
736 if (m_valobj->DoesProvideSyntheticValue() ||
737 !ShouldExpandEmptyAggregates())
738 m_stream->PutCString(
"\n");
740 m_stream->PutCString(
" {}\n");
743 if (ShouldPrintValueObject())
749 if (!GetMostSpecializedValue() || m_valobj ==
nullptr)
752 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
754 bool print_dotdotdot =
false;
755 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
758 m_stream->PutChar(
'(');
760 bool did_print_children =
false;
761 for (uint32_t idx = 0; idx < num_children; ++idx) {
764 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
765 m_options.m_use_dynamic, m_options.m_use_synthetic);
767 if (m_options.m_child_printing_decider &&
768 !m_options.m_child_printing_decider(child_sp->GetName()))
770 if (idx && did_print_children)
771 m_stream->PutCString(
", ");
772 did_print_children =
true;
774 const char *name = child_sp.get()->GetName().AsCString();
776 m_stream->PutCString(name);
777 m_stream->PutCString(
" = ");
780 child_sp->DumpPrintableRepresentation(
788 m_stream->PutCString(
", ...)");
790 m_stream->PutChar(
')');
796 bool summary_printed) {
797 PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
800 const bool print_children = ShouldPrintChildren(curr_ptr_depth);
801 const bool print_oneline =
803 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
804 (m_options.m_pointer_as_array) || m_options.m_show_location)
807 if (print_children && IsInstancePointer()) {
808 uint64_t instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
809 if (m_printed_instance_pointers->count(instance_ptr_value)) {
811 m_stream->PutCString(
" {...}\n");
815 m_printed_instance_pointers->emplace(instance_ptr_value);
819 if (print_children) {
821 m_stream->PutChar(
' ');
822 PrintChildrenOneLiner(
false);
825 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
826 }
else if (HasReachedMaximumDepth() && IsAggregate() &&
827 ShouldPrintValueObject()) {
828 m_stream->PutCString(
"{...}\n");
833 if (m_options.m_max_depth_is_default)
834 m_valobj->GetTargetSP()
836 .GetCommandInterpreter()
837 .SetReachedMaximumDepth();
843 return m_curr_depth >= m_options.m_max_depth;
847 if (m_curr_depth == 0)
848 return !m_options.m_hide_root_name && !m_options.m_hide_name;
849 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
lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx)
LazyBool m_is_instance_ptr
bool ShouldPrintValueObject()
std::pair< TypeSummaryImpl *, bool > m_summary_formatter
void Init(ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth, InstancePointersSetSP printed_instance_pointers)
void PrintChild(lldb::ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
TypeSummaryImpl * GetSummaryFormatter(bool null_if_omitted=true)
ValueObject * GetValueObjectForChildrenGeneration()
void PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
bool HasReachedMaximumDepth()
DumpValueObjectOptions m_options
bool ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool ShouldShowName() const
DumpValueObjectOptions::PointerDepth m_ptr_depth
bool GetMostSpecializedValue()
uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot)
void PrintChildrenPostamble(bool print_dotdotdot)
CompilerType m_compiler_type
ValueObject * m_orig_valobj
bool ShouldExpandEmptyAggregates()
bool CheckScopeIfNeeded()
InstancePointersSetSP m_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)
std::set< uint64_t > InstancePointersSet
ValueObjectPrinter(ValueObject *valobj, Stream *s)
void GetValueSummaryError(std::string &value, std::string &summary, std::string &error)
bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed)
const char * GetDescriptionForDisplay()
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
lldb::TypeSummaryImplSP GetSummaryFormat()
size_t GetNumChildren(uint32_t max=UINT32_MAX)
virtual bool MightHaveChildren()
Find out if a ValueObject might have children.
CompilerType GetCompilerType()
lldb::ValueObjectSP GetSyntheticValue()
lldb::Format GetFormat() const
virtual void GetExpressionPath(Stream &s, GetExpressionPathFormat=eGetExpressionPathFormatDereferencePointers)
virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType)
virtual ConstString GetDisplayTypeName()
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create=true)
virtual bool IsBaseClass()
bool IsUninitializedReference()
bool UpdateValueIfNeeded(bool update_format=true)
const Status & GetError()
virtual const char * GetValueAsCString()
virtual const char * GetLocationAsCString()
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