LLDB mainline
ValueObjectPrinter.cpp
Go to the documentation of this file.
1//===-- ValueObjectPrinter.cpp --------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
15#include "lldb/Target/Target.h"
16#include "lldb/Utility/Stream.h"
17#include "llvm/Support/MathExtras.h"
18#include <cstdint>
19
20using namespace lldb;
21using namespace lldb_private;
22
24 : m_orig_valobj(valobj) {
25 DumpValueObjectOptions options(valobj);
26 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
27}
28
30 const DumpValueObjectOptions &options)
31 : m_orig_valobj(valobj) {
32 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
33}
34
36 ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options,
37 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
38 InstancePointersSetSP printed_instance_pointers)
39 : m_orig_valobj(valobj) {
40 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
41}
42
44 ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options,
45 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
46 InstancePointersSetSP printed_instance_pointers) {
47 m_cached_valobj = nullptr;
48 m_stream = s;
49 m_options = options;
50 m_ptr_depth = ptr_depth;
51 m_curr_depth = curr_depth;
52 assert(m_stream && "cannot print to a NULL Stream");
60 m_summary_formatter = {nullptr, false};
61 m_value.assign("");
62 m_summary.assign("");
63 m_error.assign("");
64 m_val_summary_ok = false;
66 printed_instance_pointers
67 ? printed_instance_pointers
70}
71
73 // If the incoming ValueObject is in an error state, the best we're going to
74 // get out of it is its type. But if we don't even have that, just print
75 // the error and exit early.
76 if (m_orig_valobj.GetError().Fail() &&
79
83
84 PrintDecl();
85 }
86
87 bool value_printed = false;
88 bool summary_printed = false;
89
91 PrintValueAndSummaryIfNeeded(value_printed, summary_printed);
92
94 return PrintChildrenIfNeeded(value_printed, summary_printed);
95 m_stream->EOL();
96
97 return llvm::Error::success();
98}
99
101 assert(m_cached_valobj && "ValueObjectPrinter must have a valid ValueObject");
102 return *m_cached_valobj;
103}
104
106 bool update_success = m_orig_valobj.UpdateValueIfNeeded(true);
107 // If we can't find anything better, we'll fall back on the original
108 // ValueObject.
110 if (update_success) {
111 if (m_orig_valobj.IsDynamic()) {
113 ValueObject *static_value = m_orig_valobj.GetStaticValue().get();
114 if (static_value)
115 m_cached_valobj = static_value;
116 }
117 } else {
119 ValueObject *dynamic_value =
121 if (dynamic_value)
122 m_cached_valobj = dynamic_value;
123 }
124 }
125
128 ValueObject *non_synthetic =
130 if (non_synthetic)
131 m_cached_valobj = non_synthetic;
132 }
133 } else {
135 ValueObject *synthetic = m_cached_valobj->GetSyntheticValue().get();
136 if (synthetic)
137 m_cached_valobj = synthetic;
138 }
139 }
140 }
143 assert(m_cached_valobj &&
144 "SetupMostSpecialized value must compute a valid ValueObject");
145}
146
147llvm::Expected<std::string> ValueObjectPrinter::GetDescriptionForDisplay() {
149 llvm::Expected<std::string> maybe_str = valobj.GetObjectDescription();
150 if (maybe_str)
151 return maybe_str;
152
153 const char *str = nullptr;
154 if (!str)
155 str = valobj.GetSummaryAsCString();
156 if (!str)
157 str = valobj.GetValueAsCString();
158
159 if (!str)
160 return maybe_str;
161 llvm::consumeError(maybe_str.takeError());
162 return str;
163}
164
166 const char *root_valobj_name =
170 return root_valobj_name ? root_valobj_name : "";
171}
172
176 (!m_options.m_flat_output || m_type_flags.Test(eTypeHasValue))
178 : eLazyBoolNo;
180}
181
184 m_is_nil =
186 return m_is_nil == eLazyBoolYes;
187}
188
193 : eLazyBoolNo;
194 return m_is_uninit == eLazyBoolYes;
195}
196
199 m_is_ptr = m_type_flags.Test(eTypeIsPointer) ? eLazyBoolYes : eLazyBoolNo;
200 return m_is_ptr == eLazyBoolYes;
201}
202
205 m_is_ref = m_type_flags.Test(eTypeIsReference) ? eLazyBoolYes : eLazyBoolNo;
206 return m_is_ref == eLazyBoolYes;
207}
208
212 m_type_flags.Test(eTypeHasChildren) ? eLazyBoolYes : eLazyBoolNo;
214}
215
217 // you need to do this check on the value's clang type
221 eTypeInstanceIsPointer) != 0
223 : eLazyBoolNo;
224 if ((eLazyBoolYes == m_is_instance_ptr) && valobj.IsBaseClass())
227}
228
231 m_stream->Printf("%s: ", GetMostSpecializedValue().GetLocationAsCString());
232 return true;
233 }
234 return false;
235}
236
238 bool show_type = true;
239 // if we are at the root-level and been asked to hide the root's type, then
240 // hide it
242 show_type = false;
243 else
244 // otherwise decide according to the usual rules (asked to show types -
245 // always at the root level)
246 show_type = m_options.m_show_types ||
248
249 StreamString typeName;
250 // Figure out which ValueObject we're acting on
252
253 // always show the type at the root level if it is invalid
254 if (show_type) {
255 // Some ValueObjects don't have types (like registers sets). Only print the
256 // type if there is one to print
257 ConstString type_name;
258 if (m_compiler_type.IsValid()) {
260 ? valobj.GetDisplayTypeName()
261 : valobj.GetQualifiedTypeName();
262 } else {
263 // only show an invalid type name if the user explicitly triggered
264 // show_type
266 type_name = ConstString("<invalid type>");
267 }
268
269 if (type_name) {
270 std::string type_name_str(type_name.GetCString());
272 for (auto iter = type_name_str.find(" *"); iter != std::string::npos;
273 iter = type_name_str.find(" *")) {
274 type_name_str.erase(iter, 2);
275 }
276 }
277 typeName << type_name_str.c_str();
278 }
279 }
280
281 StreamString varName;
282
283 if (ShouldShowName()) {
285 valobj.GetExpressionPath(varName);
286 else
287 varName << GetRootNameForDisplay();
288 }
289
290 bool decl_printed = false;
292 // if the user didn't give us a custom helper, pick one based upon the
293 // language, either the one that this printer is bound to, or the preferred
294 // one for the ValueObject
295 lldb::LanguageType lang_type =
299 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
300 m_options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
301 }
302 }
303
305 ConstString type_name_cstr(typeName.GetString());
306 ConstString var_name_cstr(varName.GetString());
307
308 DumpValueObjectOptions decl_print_options = m_options;
309 // Pass printing helpers an option object that indicates whether the name
310 // should be shown or hidden.
311 decl_print_options.SetHideName(!ShouldShowName());
312
313 StreamString dest_stream;
314 if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
315 decl_print_options, dest_stream)) {
316 decl_printed = true;
317 m_stream->PutCString(dest_stream.GetString());
318 }
319 }
320
321 // if the helper failed, or there is none, do a default thing
322 if (!decl_printed) {
323 if (!typeName.Empty())
324 m_stream->Printf("(%s) ", typeName.GetData());
325 if (!varName.Empty())
326 m_stream->Printf("%s =", varName.GetData());
327 else if (ShouldShowName())
328 m_stream->Printf(" =");
329 }
330}
331
334 return true;
336}
337
339 if (!m_summary_formatter.second) {
340 TypeSummaryImpl *entry =
342 ? m_options.m_summary_sp.get()
344
346 entry = nullptr;
347 m_summary_formatter.first = entry;
348 m_summary_formatter.second = true;
349 }
350 if (m_options.m_omit_summary_depth > 0 && null_if_omitted)
351 return nullptr;
352 return m_summary_formatter.first;
353}
354
355static bool IsPointerValue(const CompilerType &type) {
356 Flags type_flags(type.GetTypeInfo());
357 if (type_flags.AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
358 return type_flags.AllClear(eTypeIsBuiltIn);
359 return false;
360}
361
363 std::string &summary,
364 std::string &error) {
367 // if I am printing synthetized elements, apply the format to those elements
368 // only
371 else if (format != eFormatDefault && format != valobj.GetFormat())
372 valobj.GetValueAsCString(format, value);
373 else {
374 const char *val_cstr = valobj.GetValueAsCString();
375 if (val_cstr)
376 value.assign(val_cstr);
377 }
378 const char *err_cstr = valobj.GetError().AsCString();
379 if (err_cstr)
380 error.assign(err_cstr);
381
383 return;
384
385 if (IsNil()) {
386 lldb::LanguageType lang_type =
390 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
391 summary.assign(lang_plugin->GetNilReferenceSummaryString().str());
392 } else {
393 // We treat C as the fallback language rather than as a separate Language
394 // plugin.
395 summary.assign("NULL");
396 }
397 } else if (IsUninitialized()) {
398 summary.assign("<uninitialized>");
399 } else if (m_options.m_omit_summary_depth == 0) {
401 if (entry) {
402 valobj.GetSummaryAsCString(entry, summary,
404 } else {
405 const char *sum_cstr =
407 if (sum_cstr)
408 summary.assign(sum_cstr);
409 }
410 }
411}
412
414 bool &summary_printed) {
415 bool error_printed = false;
417 if (!CheckScopeIfNeeded())
418 m_error.assign("out of scope");
419 if (m_error.empty()) {
421 }
422 if (m_error.size()) {
423 // we need to support scenarios in which it is actually fine for a value
424 // to have no type but - on the other hand - if we get an error *AND*
425 // have no type, we try to get out gracefully, since most often that
426 // combination means "could not resolve a type" and the default failure
427 // mode is quite ugly
428 if (!m_compiler_type.IsValid()) {
429 m_stream->Printf(" <could not resolve type>");
430 return false;
431 }
432
433 error_printed = true;
434 m_stream->Printf(" <%s>\n", m_error.c_str());
435 } else {
436 // Make sure we have a value and make sure the summary didn't specify
437 // that the value should not be printed - and do not print the value if
438 // this thing is nil (but show the value if the user passes a format
439 // explicitly)
442 const bool has_nil_or_uninitialized_summary =
443 (IsNil() || IsUninitialized()) && !m_summary.empty();
444 if (!has_nil_or_uninitialized_summary && !m_value.empty() &&
445 (entry == nullptr ||
446 (entry->DoesPrintValue(&valobj) ||
448 m_summary.empty()) &&
452 } else {
453 if (ShouldShowName())
454 m_stream->PutChar(' ');
456 value_printed = true;
457 }
458 }
459
460 if (m_summary.size()) {
461 if (ShouldShowName() || value_printed)
462 m_stream->PutChar(' ');
464 summary_printed = true;
465 }
466 }
467 }
468 return !error_printed;
469}
470
471llvm::Error
473 bool summary_printed) {
475 // let's avoid the overly verbose no description error for a nil thing
476 if (m_options.m_use_objc && !IsNil() && !IsUninitialized() &&
479 *m_stream << ' ';
480 llvm::Expected<std::string> object_desc =
481 (value_printed || summary_printed)
484 if (!object_desc) {
485 // If no value or summary was printed, surface the error.
486 if (!value_printed && !summary_printed)
487 return object_desc.takeError();
488 // Otherwise gently nudge the user that they should have used
489 // `p` instead of `po`. Unfortunately we cannot be more direct
490 // about this, because we don't actually know what the user did.
491 *m_stream << "warning: no object description available\n";
492 llvm::consumeError(object_desc.takeError());
493 } else {
494 *m_stream << *object_desc;
495 // If the description already ends with a \n don't add another one.
496 if (object_desc->empty() || object_desc->back() != '\n')
497 *m_stream << '\n';
498 }
499 return llvm::Error::success();
500 }
501 }
502 return llvm::Error::success();
503}
504
506 switch (m_mode) {
507 case Mode::Always:
508 case Mode::Default:
509 return m_count > 0;
510 case Mode::Never:
511 return false;
512 }
513 return false;
514}
515
517 DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
518 const bool is_ref = IsRef();
519 const bool is_ptr = IsPtr();
520 const bool is_uninit = IsUninitialized();
521
522 if (is_uninit)
523 return false;
524
525 // If we have reached the maximum depth we shouldn't print any more children.
526 if (HasReachedMaximumDepth())
527 return false;
528
529 // if the user has specified an element count, always print children as it is
530 // explicit user demand being honored
531 if (m_options.m_pointer_as_array)
532 return true;
533
534 if (m_options.m_use_objc)
535 return false;
536
537 bool print_children = true;
538 ValueObject &valobj = GetMostSpecializedValue();
539 if (TypeSummaryImpl *type_summary = GetSummaryFormatter())
540 print_children = type_summary->DoesPrintChildren(&valobj);
541
542 // We will show children for all concrete types. We won't show pointer
543 // contents unless a pointer depth has been specified. We won't reference
544 // contents unless the reference is the root object (depth of zero).
545
546 // Use a new temporary pointer depth in case we override the current
547 // pointer depth below...
548
549 if (is_ptr || is_ref) {
550 // We have a pointer or reference whose value is an address. Make sure
551 // that address is not NULL
552 AddressType ptr_address_type;
553 if (valobj.GetPointerValue(&ptr_address_type) == 0)
554 return false;
555
556 const bool is_root_level = m_curr_depth == 0;
557
558 if (is_ref && is_root_level && print_children) {
559 // If this is the root object (depth is zero) that we are showing and
560 // it is a reference, and no pointer depth has been supplied print out
561 // what it references. Don't do this at deeper depths otherwise we can
562 // end up with infinite recursion...
563 return true;
564 }
565
566 return curr_ptr_depth.CanAllowExpansion();
567 }
568
569 return print_children || m_summary.empty();
570}
571
573 TypeSummaryImpl *entry = GetSummaryFormatter();
574
575 if (!entry)
576 return true;
577
578 return entry->DoesPrintEmptyAggregates();
579}
580
582 return GetMostSpecializedValue();
583}
584
586 bool summary_printed) {
587 if (m_options.m_flat_output) {
588 if (ShouldPrintValueObject())
589 m_stream->EOL();
590 } else {
591 if (ShouldPrintValueObject()) {
592 if (IsRef()) {
593 m_stream->PutCString(": ");
594 } else if (value_printed || summary_printed || ShouldShowName()) {
595 m_stream->PutChar(' ');
596 }
597 m_stream->PutCString("{\n");
598 }
599 m_stream->IndentMore();
600 }
601}
602
604 ValueObjectSP child_sp,
605 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
606 const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
607 const bool does_consume_ptr_depth =
608 ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
609
610 DumpValueObjectOptions child_options(m_options);
611 child_options.SetFormat(m_options.m_format)
612 .SetSummary()
614 child_options.SetScopeChecked(true)
615 .SetHideName(m_options.m_hide_name)
616 .SetHideValue(m_options.m_hide_value)
618 ? child_options.m_omit_summary_depth -
619 consumed_summary_depth
620 : 0)
621 .SetElementCount(0);
622
623 if (child_sp.get()) {
624 auto ptr_depth = curr_ptr_depth;
625 if (does_consume_ptr_depth)
626 ptr_depth = curr_ptr_depth.Decremented();
627
628 ValueObjectPrinter child_printer(*(child_sp.get()), m_stream, child_options,
629 ptr_depth, m_curr_depth + 1,
630 m_printed_instance_pointers);
631 llvm::Error error = child_printer.PrintValueObject();
632 if (error) {
633 if (m_stream)
634 *m_stream << "error: " << toString(std::move(error));
635 else
636 llvm::consumeError(std::move(error));
637 }
638 }
639}
640
641llvm::Expected<uint32_t>
643 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
644
645 if (m_options.m_pointer_as_array)
646 return m_options.m_pointer_as_array.m_element_count;
647
648 const uint32_t max_num_children =
649 m_options.m_ignore_cap ? UINT32_MAX
650 : GetMostSpecializedValue()
651 .GetTargetSP()
652 ->GetMaximumNumberOfChildrenToDisplay();
653 // Ask for one more child than the maximum to see if we should print "...".
654 auto num_children_or_err = synth_valobj.GetNumChildren(
655 llvm::SaturatingAdd(max_num_children, uint32_t(1)));
656 if (!num_children_or_err)
657 return num_children_or_err;
658 if (*num_children_or_err > max_num_children) {
659 print_dotdotdot = true;
660 return max_num_children;
661 }
662 return num_children_or_err;
663}
664
666 if (!m_options.m_flat_output) {
667 if (print_dotdotdot) {
668 GetMostSpecializedValue()
669 .GetTargetSP()
670 ->GetDebugger()
671 .GetCommandInterpreter()
672 .ChildrenTruncated();
673 m_stream->Indent("...\n");
674 }
675 m_stream->IndentLess();
676 m_stream->Indent("}\n");
677 }
678}
679
681 bool summary_printed) {
682 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
683
684 if (!IsAggregate())
685 return false;
686
687 if (!m_options.m_reveal_empty_aggregates) {
688 if (value_printed || summary_printed)
689 return false;
690 }
691
692 if (synth_valobj.MightHaveChildren())
693 return true;
694
695 if (m_val_summary_ok)
696 return false;
697
698 return true;
699}
700
701static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride,
702 size_t logical) {
703 return base + logical * stride;
704}
705
707 size_t idx) {
708 if (m_options.m_pointer_as_array) {
709 // if generating pointer-as-array children, use GetSyntheticArrayMember
710 return synth_valobj.GetSyntheticArrayMember(
712 m_options.m_pointer_as_array.m_base_element,
713 m_options.m_pointer_as_array.m_stride, idx),
714 true);
715 } else {
716 // otherwise, do the usual thing
717 return synth_valobj.GetChildAtIndex(idx);
718 }
719}
720
722 bool value_printed, bool summary_printed,
723 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
724 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
725
726 bool print_dotdotdot = false;
727 auto num_children_or_err = GetMaxNumChildrenToPrint(print_dotdotdot);
728 if (!num_children_or_err) {
729 *m_stream << " <" << llvm::toString(num_children_or_err.takeError()) << '>';
730 return;
731 }
732 uint32_t num_children = *num_children_or_err;
733 if (num_children) {
734 bool any_children_printed = false;
735
736 for (size_t idx = 0; idx < num_children; ++idx) {
737 if (ValueObjectSP child_sp = GenerateChild(synth_valobj, idx)) {
738 if (m_options.m_child_printing_decider &&
739 !m_options.m_child_printing_decider(child_sp->GetName()))
740 continue;
741 if (!any_children_printed) {
742 PrintChildrenPreamble(value_printed, summary_printed);
743 any_children_printed = true;
744 }
745 PrintChild(child_sp, curr_ptr_depth);
746 }
747 }
748
749 if (any_children_printed)
750 PrintChildrenPostamble(print_dotdotdot);
751 else {
752 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
753 if (ShouldPrintValueObject())
754 m_stream->PutCString(" {}\n");
755 else
756 m_stream->EOL();
757 } else
758 m_stream->EOL();
759 }
760 } else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
761 // Aggregate, no children...
762 if (ShouldPrintValueObject()) {
763 // if it has a synthetic value, then don't print {}, the synthetic
764 // children are probably only being used to vend a value
765 if (GetMostSpecializedValue().DoesProvideSyntheticValue() ||
766 !ShouldExpandEmptyAggregates())
767 m_stream->PutCString("\n");
768 else
769 m_stream->PutCString(" {}\n");
770 }
771 } else {
772 if (ShouldPrintValueObject())
773 m_stream->EOL();
774 }
775}
776
778 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
779
780 bool print_dotdotdot = false;
781 auto num_children_or_err = GetMaxNumChildrenToPrint(print_dotdotdot);
782 if (!num_children_or_err) {
783 *m_stream << '<' << llvm::toString(num_children_or_err.takeError()) << '>';
784 return true;
785 }
786 uint32_t num_children = *num_children_or_err;
787
788 if (num_children) {
789 m_stream->PutChar('(');
790
791 bool did_print_children = false;
792 for (uint32_t idx = 0; idx < num_children; ++idx) {
793 lldb::ValueObjectSP child_sp(synth_valobj.GetChildAtIndex(idx));
794 if (child_sp)
795 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
796 m_options.m_use_dynamic, m_options.m_use_synthetic);
797 if (child_sp) {
798 if (m_options.m_child_printing_decider &&
799 !m_options.m_child_printing_decider(child_sp->GetName()))
800 continue;
801 if (idx && did_print_children)
802 m_stream->PutCString(", ");
803 did_print_children = true;
804 if (!hide_names) {
805 const char *name = child_sp.get()->GetName().AsCString();
806 if (name && *name) {
807 m_stream->PutCString(name);
808 m_stream->PutCString(" = ");
809 }
810 }
811 child_sp->DumpPrintableRepresentation(
813 m_options.m_format,
815 }
816 }
817
818 if (print_dotdotdot)
819 m_stream->PutCString(", ...)");
820 else
821 m_stream->PutChar(')');
822 }
823 return true;
824}
825
826llvm::Error ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
827 bool summary_printed) {
828 auto error = PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
829 if (error)
830 return error;
831
832 ValueObject &valobj = GetMostSpecializedValue();
833
834 DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth;
835 const bool print_children = ShouldPrintChildren(curr_ptr_depth);
836 const bool print_oneline =
837 (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
838 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
839 (m_options.m_pointer_as_array) || m_options.m_show_location)
840 ? false
842 if (print_children && IsInstancePointer()) {
843 uint64_t instance_ptr_value = valobj.GetValueAsUnsigned(0);
844 if (m_printed_instance_pointers->count(instance_ptr_value)) {
845 // We already printed this instance-is-pointer thing, so don't expand it.
846 m_stream->PutCString(" {...}\n");
847 return llvm::Error::success();
848 } else {
849 // Remember this guy for future reference.
850 m_printed_instance_pointers->emplace(instance_ptr_value);
851 }
852 }
853
854 if (print_children) {
855 if (print_oneline) {
856 m_stream->PutChar(' ');
857 PrintChildrenOneLiner(false);
858 m_stream->EOL();
859 } else
860 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
861 } else if (HasReachedMaximumDepth() && IsAggregate() &&
862 ShouldPrintValueObject()) {
863 m_stream->PutCString("{...}\n");
864 // The maximum child depth has been reached. If `m_max_depth` is the default
865 // (i.e. the user has _not_ customized it), then lldb presents a warning to
866 // the user. The warning tells the user that the limit has been reached, but
867 // more importantly tells them how to expand the limit if desired.
868 if (m_options.m_max_depth_is_default)
869 valobj.GetTargetSP()
870 ->GetDebugger()
871 .GetCommandInterpreter()
872 .SetReachedMaximumDepth();
873 } else
874 m_stream->EOL();
875 return llvm::Error::success();
876}
877
879 return m_curr_depth >= m_options.m_max_depth;
880}
881
883 if (m_curr_depth == 0)
884 return !m_options.m_hide_root_name && !m_options.m_hide_name;
885 return !m_options.m_hide_name;
886}
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.
Definition: CompilerType.h:36
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
static bool ShouldPrintAsOneLiner(ValueObject &valobj)
DumpValueObjectOptions & SetHideName(bool hide_name=false)
DumpValueObjectOptions & SetSummary(lldb::TypeSummaryImplSP summary=lldb::TypeSummaryImplSP())
DumpValueObjectOptions & SetOmitSummaryDepth(uint32_t depth=0)
DumpValueObjectOptions & SetRootValueObjectName(const char *name=nullptr)
DumpValueObjectOptions & SetFormat(lldb::Format format=lldb::eFormatDefault)
DumpValueObjectOptions & SetScopeChecked(bool check=true)
DumpValueObjectOptions & SetHideValue(bool hide_value=false)
DumpValueObjectOptions & SetElementCount(uint32_t element_count=0)
A class to manage flags.
Definition: Flags.h:22
bool AllClear(ValueType mask) const
Test if all bits in mask are clear.
Definition: Flags.h:103
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
bool AnySet(ValueType mask) const
Test one or more flags.
Definition: Flags.h:90
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:84
llvm::Error ToError() const
Definition: Status.cpp:89
bool Fail() const
Test for error condition.
Definition: Status.cpp:180
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:129
const char * GetData() const
Definition: StreamString.h:45
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
size_t PutChar(char ch)
Definition: Stream.cpp:131
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:155
virtual bool DoesPrintEmptyAggregates() const
Definition: TypeSummary.h:214
virtual bool DoesPrintValue(ValueObject *valobj) const
Definition: TypeSummary.h:218
llvm::Expected< std::string > GetDescriptionForDisplay()
void PrintChildrenPreamble(bool value_printed, bool summary_printed)
std::shared_ptr< InstancePointersSet > InstancePointersSetSP
ValueObjectPrinter(ValueObject &valobj, Stream *s)
The ValueObjectPrinter is a one-shot printer for ValueObjects.
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.
llvm::Error PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
bool ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
DumpValueObjectOptions::PointerDepth m_ptr_depth
void PrintChildrenPostamble(bool print_dotdotdot)
llvm::Error PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
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)
Ee should actually be using delegating constructors here but some versions of GCC still have trouble ...
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool PrintChildrenOneLiner(bool hide_names)
ValueObject * m_cached_valobj
Cache the current "most specialized" value.
std::set< uint64_t > InstancePointersSet
void GetValueSummaryError(std::string &value, std::string &summary, std::string &error)
bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed)
llvm::Expected< uint32_t > GetMaxNumChildrenToPrint(bool &print_dotdotdot)
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
lldb::TypeSummaryImplSP GetSummaryFormat()
Definition: ValueObject.h:788
virtual bool IsInScope()
Definition: ValueObject.h:420
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()
Definition: ValueObject.h:352
lldb::ValueObjectSP GetSyntheticValue()
lldb::Format GetFormat() const
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual bool IsDynamic()
Definition: ValueObject.h:683
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()
Definition: ValueObject.h:367
virtual bool IsBaseClass()
Definition: ValueObject.h:398
bool UpdateValueIfNeeded(bool update_format=true)
const Status & GetError()
lldb::TargetSP GetTargetSP() const
Definition: ValueObject.h:334
virtual const char * GetValueAsCString()
ConstString GetName() const
Definition: ValueObject.h:487
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:604
virtual ConstString GetQualifiedTypeName()
Definition: ValueObject.h:369
llvm::Expected< std::string > GetObjectDescription()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
Definition: ValueObject.h:606
const char * GetSummaryAsCString(lldb::LanguageType lang=lldb::eLanguageTypeUnknown)
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool IsSynthetic()
Definition: ValueObject.h:612
const Value & GetValue() const
Definition: ValueObject.h:511
virtual lldb::LanguageType GetPreferredDisplayLanguage()
const CompilerType & GetCompilerType()
Definition: Value.cpp:239
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
const char * toString(AppleArm64ExceptionClass EC)
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eNoDynamicValues
enum lldb_private::DumpValueObjectOptions::PointerDepth::Mode m_mode