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)
505 bool is_failed_description,
507 const bool is_ref = IsRef();
508 const bool is_ptr = IsPtr();
509 const bool is_uninit = IsUninitialized();
516 if (m_options.m_pointer_as_array)
519 if (m_options.m_use_objc)
522 bool print_children =
true;
524 print_children = type_summary->DoesPrintChildren(m_valobj);
526 if (is_failed_description || !HasReachedMaximumDepth()) {
534 if (is_ptr || is_ref) {
538 if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
541 const bool is_root_level = m_curr_depth == 0;
543 if (is_ref && is_root_level && print_children) {
554 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();
591 ValueObjectSP child_sp,
593 const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
594 const bool does_consume_ptr_depth =
595 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
598 child_options.
SetFormat(m_options.m_format)
610 if (child_sp.get()) {
612 child_sp.get(), m_stream, child_options,
613 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
614 m_curr_depth + consumed_depth, m_printed_instance_pointers);
620 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
622 if (m_options.m_pointer_as_array)
623 return m_options.m_pointer_as_array.m_element_count;
626 print_dotdotdot =
false;
628 const size_t max_num_children =
629 m_valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
631 if (num_children > max_num_children && !m_options.m_ignore_cap) {
632 print_dotdotdot =
true;
633 return max_num_children;
640 if (!m_options.m_flat_output) {
641 if (print_dotdotdot) {
642 m_valobj->GetTargetSP()
644 .GetCommandInterpreter()
645 .ChildrenTruncated();
646 m_stream->Indent(
"...\n");
648 m_stream->IndentLess();
649 m_stream->Indent(
"}\n");
654 bool summary_printed) {
655 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
660 if (!m_options.m_reveal_empty_aggregates) {
661 if (value_printed || summary_printed)
668 if (m_val_summary_ok)
676 return base + logical * stride;
681 if (m_options.m_pointer_as_array) {
685 m_options.m_pointer_as_array.m_base_element,
686 m_options.m_pointer_as_array.m_stride, idx),
695 bool value_printed,
bool summary_printed,
697 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
699 bool print_dotdotdot =
false;
700 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
702 bool any_children_printed =
false;
704 for (
size_t idx = 0; idx < num_children; ++idx) {
705 if (ValueObjectSP child_sp = GenerateChild(synth_m_valobj, idx)) {
706 if (m_options.m_child_printing_decider &&
707 !m_options.m_child_printing_decider(child_sp->GetName()))
709 if (!any_children_printed) {
710 PrintChildrenPreamble(value_printed, summary_printed);
711 any_children_printed =
true;
713 PrintChild(child_sp, curr_ptr_depth);
717 if (any_children_printed)
718 PrintChildrenPostamble(print_dotdotdot);
720 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
721 if (ShouldPrintValueObject())
722 m_stream->PutCString(
" {}\n");
728 }
else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
730 if (ShouldPrintValueObject()) {
733 if (m_valobj->DoesProvideSyntheticValue() ||
734 !ShouldExpandEmptyAggregates())
735 m_stream->PutCString(
"\n");
737 m_stream->PutCString(
" {}\n");
740 if (ShouldPrintValueObject())
746 if (!GetMostSpecializedValue() || m_valobj ==
nullptr)
749 ValueObject *synth_m_valobj = GetValueObjectForChildrenGeneration();
751 bool print_dotdotdot =
false;
752 size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot);
755 m_stream->PutChar(
'(');
757 bool did_print_children =
false;
758 for (
uint32_t idx = 0; idx < num_children; ++idx) {
759 lldb::ValueObjectSP child_sp(synth_m_valobj->
GetChildAtIndex(idx,
true));
761 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
762 m_options.m_use_dynamic, m_options.m_use_synthetic);
764 if (m_options.m_child_printing_decider &&
765 !m_options.m_child_printing_decider(child_sp->GetName()))
767 if (idx && did_print_children)
768 m_stream->PutCString(
", ");
769 did_print_children =
true;
771 const char *name = child_sp.get()->GetName().AsCString();
773 m_stream->PutCString(name);
774 m_stream->PutCString(
" = ");
777 child_sp->DumpPrintableRepresentation(
785 m_stream->PutCString(
", ...)");
787 m_stream->PutChar(
')');
793 bool summary_printed) {
796 bool is_failed_description =
797 !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
800 const bool print_children =
801 ShouldPrintChildren(is_failed_description, curr_ptr_depth);
802 const bool print_oneline =
804 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
805 (m_options.m_pointer_as_array) || m_options.m_show_location)
808 if (print_children && IsInstancePointer()) {
809 uint64_t instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
810 if (m_printed_instance_pointers->count(instance_ptr_value)) {
812 m_stream->PutCString(
" {...}\n");
816 m_printed_instance_pointers->emplace(instance_ptr_value);
820 if (print_children) {
822 m_stream->PutChar(
' ');
823 PrintChildrenOneLiner(
false);
826 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
827 }
else if (HasReachedMaximumDepth() && IsAggregate() &&
828 ShouldPrintValueObject()) {
829 m_stream->PutCString(
"{...}\n");
834 if (m_options.m_max_depth_is_default)
835 m_valobj->GetTargetSP()
837 .GetCommandInterpreter()
838 .SetReachedMaximumDepth();
844 return m_curr_depth >= m_options.m_max_depth;
848 if (m_curr_depth == 0)
849 return !m_options.m_hide_root_name && !m_options.m_hide_name;
850 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 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 ShouldPrintChildren(bool is_failed_description, DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
lldb::TypeSummaryImplSP GetSummaryFormat()
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create)
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 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.
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
enum lldb_private::DumpValueObjectOptions::PointerDepth::Mode m_mode
bool CanAllowExpansion() const