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
18using namespace lldb;
19using namespace lldb_private;
20
22 : m_orig_valobj(valobj) {
23 DumpValueObjectOptions options(valobj);
24 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
25}
26
28 const DumpValueObjectOptions &options)
29 : m_orig_valobj(valobj) {
30 Init(valobj, s, options, m_options.m_max_ptr_depth, 0, nullptr);
31}
32
34 ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options,
35 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
36 InstancePointersSetSP printed_instance_pointers)
37 : m_orig_valobj(valobj) {
38 Init(valobj, s, options, ptr_depth, curr_depth, printed_instance_pointers);
39}
40
42 ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options,
43 const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth,
44 InstancePointersSetSP printed_instance_pointers) {
45 m_cached_valobj = nullptr;
46 m_stream = s;
47 m_options = options;
48 m_ptr_depth = ptr_depth;
49 m_curr_depth = curr_depth;
50 assert(m_stream && "cannot print to a NULL Stream");
58 m_summary_formatter = {nullptr, false};
59 m_value.assign("");
60 m_summary.assign("");
61 m_error.assign("");
62 m_val_summary_ok = false;
64 printed_instance_pointers
65 ? printed_instance_pointers
68}
69
71 // If the incoming ValueObject is in an error state, the best we're going to
72 // get out of it is its type. But if we don't even have that, just print
73 // the error and exit early.
74 if (m_orig_valobj.GetError().Fail() &&
76 m_stream->Printf("Error: '%s'", m_orig_valobj.GetError().AsCString());
77 return true;
78 }
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 PrintChildrenIfNeeded(value_printed, summary_printed);
95 else
96 m_stream->EOL();
97
98 return true;
99}
100
102 assert(m_cached_valobj && "ValueObjectPrinter must have a valid ValueObject");
103 return *m_cached_valobj;
104}
105
107 bool update_success = m_orig_valobj.UpdateValueIfNeeded(true);
108 // If we can't find anything better, we'll fall back on the original
109 // ValueObject.
111 if (update_success) {
112 if (m_orig_valobj.IsDynamic()) {
114 ValueObject *static_value = m_orig_valobj.GetStaticValue().get();
115 if (static_value)
116 m_cached_valobj = static_value;
117 }
118 } else {
120 ValueObject *dynamic_value =
122 if (dynamic_value)
123 m_cached_valobj = dynamic_value;
124 }
125 }
126
129 ValueObject *non_synthetic =
131 if (non_synthetic)
132 m_cached_valobj = non_synthetic;
133 }
134 } else {
136 ValueObject *synthetic = m_cached_valobj->GetSyntheticValue().get();
137 if (synthetic)
138 m_cached_valobj = synthetic;
139 }
140 }
141 }
144 assert(m_cached_valobj &&
145 "SetupMostSpecialized value must compute a valid ValueObject");
146}
147
150 const char *str = valobj.GetObjectDescription();
151 if (!str)
152 str = valobj.GetSummaryAsCString();
153 if (!str)
154 str = valobj.GetValueAsCString();
155 return str;
156}
157
159 const char *root_valobj_name =
163 return root_valobj_name ? root_valobj_name : "";
164}
165
169 (!m_options.m_flat_output || m_type_flags.Test(eTypeHasValue))
171 : eLazyBoolNo;
173}
174
177 m_is_nil =
179 return m_is_nil == eLazyBoolYes;
180}
181
186 : eLazyBoolNo;
187 return m_is_uninit == eLazyBoolYes;
188}
189
192 m_is_ptr = m_type_flags.Test(eTypeIsPointer) ? eLazyBoolYes : eLazyBoolNo;
193 return m_is_ptr == eLazyBoolYes;
194}
195
198 m_is_ref = m_type_flags.Test(eTypeIsReference) ? eLazyBoolYes : eLazyBoolNo;
199 return m_is_ref == eLazyBoolYes;
200}
201
205 m_type_flags.Test(eTypeHasChildren) ? eLazyBoolYes : eLazyBoolNo;
207}
208
210 // you need to do this check on the value's clang type
214 eTypeInstanceIsPointer) != 0
216 : eLazyBoolNo;
217 if ((eLazyBoolYes == m_is_instance_ptr) && valobj.IsBaseClass())
220}
221
224 m_stream->Printf("%s: ", GetMostSpecializedValue().GetLocationAsCString());
225 return true;
226 }
227 return false;
228}
229
231 bool show_type = true;
232 // if we are at the root-level and been asked to hide the root's type, then
233 // hide it
235 show_type = false;
236 else
237 // otherwise decide according to the usual rules (asked to show types -
238 // always at the root level)
239 show_type = m_options.m_show_types ||
241
242 StreamString typeName;
243 // Figure out which ValueObject we're acting on
245
246 // always show the type at the root level if it is invalid
247 if (show_type) {
248 // Some ValueObjects don't have types (like registers sets). Only print the
249 // type if there is one to print
250 ConstString type_name;
251 if (m_compiler_type.IsValid()) {
253 ? valobj.GetDisplayTypeName()
254 : valobj.GetQualifiedTypeName();
255 } else {
256 // only show an invalid type name if the user explicitly triggered
257 // show_type
259 type_name = ConstString("<invalid type>");
260 }
261
262 if (type_name) {
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);
268 }
269 }
270 typeName << type_name_str.c_str();
271 }
272 }
273
274 StreamString varName;
275
276 if (ShouldShowName()) {
278 valobj.GetExpressionPath(varName);
279 else
280 varName << GetRootNameForDisplay();
281 }
282
283 bool decl_printed = false;
285 // if the user didn't give us a custom helper, pick one based upon the
286 // language, either the one that this printer is bound to, or the preferred
287 // one for the ValueObject
288 lldb::LanguageType lang_type =
292 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
293 m_options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
294 }
295 }
296
298 ConstString type_name_cstr(typeName.GetString());
299 ConstString var_name_cstr(varName.GetString());
300
301 DumpValueObjectOptions decl_print_options = m_options;
302 // Pass printing helpers an option object that indicates whether the name
303 // should be shown or hidden.
304 decl_print_options.SetHideName(!ShouldShowName());
305
306 StreamString dest_stream;
307 if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr,
308 decl_print_options, dest_stream)) {
309 decl_printed = true;
310 m_stream->PutCString(dest_stream.GetString());
311 }
312 }
313
314 // if the helper failed, or there is none, do a default thing
315 if (!decl_printed) {
316 if (!typeName.Empty())
317 m_stream->Printf("(%s) ", typeName.GetData());
318 if (!varName.Empty())
319 m_stream->Printf("%s =", varName.GetData());
320 else if (ShouldShowName())
321 m_stream->Printf(" =");
322 }
323}
324
327 return true;
329}
330
332 if (!m_summary_formatter.second) {
333 TypeSummaryImpl *entry =
335 ? m_options.m_summary_sp.get()
337
339 entry = nullptr;
340 m_summary_formatter.first = entry;
341 m_summary_formatter.second = true;
342 }
343 if (m_options.m_omit_summary_depth > 0 && null_if_omitted)
344 return nullptr;
345 return m_summary_formatter.first;
346}
347
348static bool IsPointerValue(const CompilerType &type) {
349 Flags type_flags(type.GetTypeInfo());
350 if (type_flags.AnySet(eTypeInstanceIsPointer | eTypeIsPointer))
351 return type_flags.AllClear(eTypeIsBuiltIn);
352 return false;
353}
354
356 std::string &summary,
357 std::string &error) {
360 // if I am printing synthetized elements, apply the format to those elements
361 // only
364 else if (format != eFormatDefault && format != valobj.GetFormat())
365 valobj.GetValueAsCString(format, value);
366 else {
367 const char *val_cstr = valobj.GetValueAsCString();
368 if (val_cstr)
369 value.assign(val_cstr);
370 }
371 const char *err_cstr = valobj.GetError().AsCString();
372 if (err_cstr)
373 error.assign(err_cstr);
374
376 return;
377
378 if (IsNil()) {
379 lldb::LanguageType lang_type =
383 if (Language *lang_plugin = Language::FindPlugin(lang_type)) {
384 summary.assign(lang_plugin->GetNilReferenceSummaryString().str());
385 } else {
386 // We treat C as the fallback language rather than as a separate Language
387 // plugin.
388 summary.assign("NULL");
389 }
390 } else if (IsUninitialized()) {
391 summary.assign("<uninitialized>");
392 } else if (m_options.m_omit_summary_depth == 0) {
394 if (entry) {
395 valobj.GetSummaryAsCString(entry, summary,
397 } else {
398 const char *sum_cstr =
400 if (sum_cstr)
401 summary.assign(sum_cstr);
402 }
403 }
404}
405
407 bool &summary_printed) {
408 bool error_printed = false;
410 if (!CheckScopeIfNeeded())
411 m_error.assign("out of scope");
412 if (m_error.empty()) {
414 }
415 if (m_error.size()) {
416 // we need to support scenarios in which it is actually fine for a value
417 // to have no type but - on the other hand - if we get an error *AND*
418 // have no type, we try to get out gracefully, since most often that
419 // combination means "could not resolve a type" and the default failure
420 // mode is quite ugly
421 if (!m_compiler_type.IsValid()) {
422 m_stream->Printf(" <could not resolve type>");
423 return false;
424 }
425
426 error_printed = true;
427 m_stream->Printf(" <%s>\n", m_error.c_str());
428 } else {
429 // Make sure we have a value and make sure the summary didn't specify
430 // that the value should not be printed - and do not print the value if
431 // this thing is nil (but show the value if the user passes a format
432 // explicitly)
435 const bool has_nil_or_uninitialized_summary =
436 (IsNil() || IsUninitialized()) && !m_summary.empty();
437 if (!has_nil_or_uninitialized_summary && !m_value.empty() &&
438 (entry == nullptr ||
439 (entry->DoesPrintValue(&valobj) ||
441 m_summary.empty()) &&
445 } else {
446 if (ShouldShowName())
447 m_stream->PutChar(' ');
449 value_printed = true;
450 }
451 }
452
453 if (m_summary.size()) {
454 if (ShouldShowName() || value_printed)
455 m_stream->PutChar(' ');
457 summary_printed = true;
458 }
459 }
460 }
461 return !error_printed;
462}
463
465 bool summary_printed) {
467 // let's avoid the overly verbose no description error for a nil thing
468 if (m_options.m_use_objc && !IsNil() && !IsUninitialized() &&
471 m_stream->Printf(" ");
472 const char *object_desc = nullptr;
473 if (value_printed || summary_printed)
475 else
476 object_desc = GetDescriptionForDisplay();
477 if (object_desc && *object_desc) {
478 // If the description already ends with a \n don't add another one.
479 size_t object_end = strlen(object_desc) - 1;
480 if (object_desc[object_end] == '\n')
481 m_stream->Printf("%s", object_desc);
482 else
483 m_stream->Printf("%s\n", object_desc);
484 return true;
485 } else if (!value_printed && !summary_printed)
486 return true;
487 else
488 return false;
489 }
490 }
491 return true;
492}
493
495 switch (m_mode) {
496 case Mode::Always:
497 case Mode::Default:
498 return m_count > 0;
499 case Mode::Never:
500 return false;
501 }
502 return false;
503}
504
506 DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
507 const bool is_ref = IsRef();
508 const bool is_ptr = IsPtr();
509 const bool is_uninit = IsUninitialized();
510
511 if (is_uninit)
512 return false;
513
514 // If we have reached the maximum depth we shouldn't print any more children.
515 if (HasReachedMaximumDepth())
516 return false;
517
518 // if the user has specified an element count, always print children as it is
519 // explicit user demand being honored
520 if (m_options.m_pointer_as_array)
521 return true;
522
523 if (m_options.m_use_objc)
524 return false;
525
526 bool print_children = true;
527 ValueObject &valobj = GetMostSpecializedValue();
528 if (TypeSummaryImpl *type_summary = GetSummaryFormatter())
529 print_children = type_summary->DoesPrintChildren(&valobj);
530
531 // We will show children for all concrete types. We won't show pointer
532 // contents unless a pointer depth has been specified. We won't reference
533 // contents unless the reference is the root object (depth of zero).
534
535 // Use a new temporary pointer depth in case we override the current
536 // pointer depth below...
537
538 if (is_ptr || is_ref) {
539 // We have a pointer or reference whose value is an address. Make sure
540 // that address is not NULL
541 AddressType ptr_address_type;
542 if (valobj.GetPointerValue(&ptr_address_type) == 0)
543 return false;
544
545 const bool is_root_level = m_curr_depth == 0;
546
547 if (is_ref && is_root_level && print_children) {
548 // If this is the root object (depth is zero) that we are showing and
549 // it is a reference, and no pointer depth has been supplied print out
550 // what it references. Don't do this at deeper depths otherwise we can
551 // end up with infinite recursion...
552 return true;
553 }
554
555 return curr_ptr_depth.CanAllowExpansion();
556 }
557
558 return print_children || m_summary.empty();
559}
560
562 TypeSummaryImpl *entry = GetSummaryFormatter();
563
564 if (!entry)
565 return true;
566
567 return entry->DoesPrintEmptyAggregates();
568}
569
571 return GetMostSpecializedValue();
572}
573
575 bool summary_printed) {
576 if (m_options.m_flat_output) {
577 if (ShouldPrintValueObject())
578 m_stream->EOL();
579 } else {
580 if (ShouldPrintValueObject()) {
581 if (IsRef()) {
582 m_stream->PutCString(": ");
583 } else if (value_printed || summary_printed || ShouldShowName()) {
584 m_stream->PutChar(' ');
585 }
586 m_stream->PutCString("{\n");
587 }
588 m_stream->IndentMore();
589 }
590}
591
593 ValueObjectSP child_sp,
594 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
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());
598
599 DumpValueObjectOptions child_options(m_options);
600 child_options.SetFormat(m_options.m_format)
601 .SetSummary()
603 child_options.SetScopeChecked(true)
604 .SetHideName(m_options.m_hide_name)
605 .SetHideValue(m_options.m_hide_value)
607 ? child_options.m_omit_summary_depth -
608 consumed_summary_depth
609 : 0)
610 .SetElementCount(0);
611
612 if (child_sp.get()) {
613 auto ptr_depth = curr_ptr_depth;
614 if (does_consume_ptr_depth)
615 ptr_depth = curr_ptr_depth.Decremented();
616
617 ValueObjectPrinter child_printer(*(child_sp.get()), m_stream, child_options,
618 ptr_depth, m_curr_depth + 1,
619 m_printed_instance_pointers);
620 child_printer.PrintValueObject();
621 }
622}
623
624llvm::Expected<uint32_t>
626 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
627
628 if (m_options.m_pointer_as_array)
629 return m_options.m_pointer_as_array.m_element_count;
630
631 auto num_children_or_err = synth_valobj.GetNumChildren();
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;
636 if (num_children) {
637 const size_t max_num_children = GetMostSpecializedValue()
638 .GetTargetSP()
639 ->GetMaximumNumberOfChildrenToDisplay();
640
641 if (num_children > max_num_children && !m_options.m_ignore_cap) {
642 print_dotdotdot = true;
643 return max_num_children;
644 }
645 }
646 return num_children;
647}
648
650 if (!m_options.m_flat_output) {
651 if (print_dotdotdot) {
652 GetMostSpecializedValue()
653 .GetTargetSP()
654 ->GetDebugger()
655 .GetCommandInterpreter()
656 .ChildrenTruncated();
657 m_stream->Indent("...\n");
658 }
659 m_stream->IndentLess();
660 m_stream->Indent("}\n");
661 }
662}
663
665 bool summary_printed) {
666 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
667
668 if (!IsAggregate())
669 return false;
670
671 if (!m_options.m_reveal_empty_aggregates) {
672 if (value_printed || summary_printed)
673 return false;
674 }
675
676 if (synth_valobj.MightHaveChildren())
677 return true;
678
679 if (m_val_summary_ok)
680 return false;
681
682 return true;
683}
684
685static constexpr size_t PhysicalIndexForLogicalIndex(size_t base, size_t stride,
686 size_t logical) {
687 return base + logical * stride;
688}
689
691 size_t idx) {
692 if (m_options.m_pointer_as_array) {
693 // if generating pointer-as-array children, use GetSyntheticArrayMember
694 return synth_valobj.GetSyntheticArrayMember(
696 m_options.m_pointer_as_array.m_base_element,
697 m_options.m_pointer_as_array.m_stride, idx),
698 true);
699 } else {
700 // otherwise, do the usual thing
701 return synth_valobj.GetChildAtIndex(idx);
702 }
703}
704
706 bool value_printed, bool summary_printed,
707 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
708 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
709
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()) << '>';
714 return;
715 }
716 uint32_t num_children = *num_children_or_err;
717 if (num_children) {
718 bool any_children_printed = false;
719
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()))
724 continue;
725 if (!any_children_printed) {
726 PrintChildrenPreamble(value_printed, summary_printed);
727 any_children_printed = true;
728 }
729 PrintChild(child_sp, curr_ptr_depth);
730 }
731 }
732
733 if (any_children_printed)
734 PrintChildrenPostamble(print_dotdotdot);
735 else {
736 if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
737 if (ShouldPrintValueObject())
738 m_stream->PutCString(" {}\n");
739 else
740 m_stream->EOL();
741 } else
742 m_stream->EOL();
743 }
744 } else if (ShouldPrintEmptyBrackets(value_printed, summary_printed)) {
745 // Aggregate, no children...
746 if (ShouldPrintValueObject()) {
747 // if it has a synthetic value, then don't print {}, the synthetic
748 // children are probably only being used to vend a value
749 if (GetMostSpecializedValue().DoesProvideSyntheticValue() ||
750 !ShouldExpandEmptyAggregates())
751 m_stream->PutCString("\n");
752 else
753 m_stream->PutCString(" {}\n");
754 }
755 } else {
756 if (ShouldPrintValueObject())
757 m_stream->EOL();
758 }
759}
760
762 ValueObject &synth_valobj = GetValueObjectForChildrenGeneration();
763
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()) << '>';
768 return true;
769 }
770 uint32_t num_children = *num_children_or_err;
771
772 if (num_children) {
773 m_stream->PutChar('(');
774
775 bool did_print_children = false;
776 for (uint32_t idx = 0; idx < num_children; ++idx) {
777 lldb::ValueObjectSP child_sp(synth_valobj.GetChildAtIndex(idx));
778 if (child_sp)
779 child_sp = child_sp->GetQualifiedRepresentationIfAvailable(
780 m_options.m_use_dynamic, m_options.m_use_synthetic);
781 if (child_sp) {
782 if (m_options.m_child_printing_decider &&
783 !m_options.m_child_printing_decider(child_sp->GetName()))
784 continue;
785 if (idx && did_print_children)
786 m_stream->PutCString(", ");
787 did_print_children = true;
788 if (!hide_names) {
789 const char *name = child_sp.get()->GetName().AsCString();
790 if (name && *name) {
791 m_stream->PutCString(name);
792 m_stream->PutCString(" = ");
793 }
794 }
795 child_sp->DumpPrintableRepresentation(
797 m_options.m_format,
799 }
800 }
801
802 if (print_dotdotdot)
803 m_stream->PutCString(", ...)");
804 else
805 m_stream->PutChar(')');
806 }
807 return true;
808}
809
811 bool summary_printed) {
812 PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
813 ValueObject &valobj = GetMostSpecializedValue();
814
815 DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth;
816 const bool print_children = ShouldPrintChildren(curr_ptr_depth);
817 const bool print_oneline =
818 (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
819 !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
820 (m_options.m_pointer_as_array) || m_options.m_show_location)
821 ? false
823 if (print_children && IsInstancePointer()) {
824 uint64_t instance_ptr_value = valobj.GetValueAsUnsigned(0);
825 if (m_printed_instance_pointers->count(instance_ptr_value)) {
826 // We already printed this instance-is-pointer thing, so don't expand it.
827 m_stream->PutCString(" {...}\n");
828 return;
829 } else {
830 // Remember this guy for future reference.
831 m_printed_instance_pointers->emplace(instance_ptr_value);
832 }
833 }
834
835 if (print_children) {
836 if (print_oneline) {
837 m_stream->PutChar(' ');
838 PrintChildrenOneLiner(false);
839 m_stream->EOL();
840 } else
841 PrintChildren(value_printed, summary_printed, curr_ptr_depth);
842 } else if (HasReachedMaximumDepth() && IsAggregate() &&
843 ShouldPrintValueObject()) {
844 m_stream->PutCString("{...}\n");
845 // The maximum child depth has been reached. If `m_max_depth` is the default
846 // (i.e. the user has _not_ customized it), then lldb presents a warning to
847 // the user. The warning tells the user that the limit has been reached, but
848 // more importantly tells them how to expand the limit if desired.
849 if (m_options.m_max_depth_is_default)
850 valobj.GetTargetSP()
851 ->GetDebugger()
852 .GetCommandInterpreter()
853 .SetReachedMaximumDepth();
854 } else
855 m_stream->EOL();
856}
857
859 return m_curr_depth >= m_options.m_max_depth;
860}
861
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;
866}
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:214
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:83
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
const char * GetData() const
Definition: StreamString.h:43
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
bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
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.
void PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
Stream * m_stream
Cache the current "most specialized" value.
bool ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
DumpValueObjectOptions::PointerDepth m_ptr_depth
void PrintChildrenPostamble(bool print_dotdotdot)
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)
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool PrintChildrenOneLiner(bool hide_names)
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:712
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:633
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:463
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:580
virtual ConstString GetQualifiedTypeName()
Definition: ValueObject.h:369
const char * GetObjectDescription()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
Definition: ValueObject.h:582
const char * GetSummaryAsCString(lldb::LanguageType lang=lldb::eLanguageTypeUnknown)
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create)
virtual bool IsSynthetic()
Definition: ValueObject.h:588
const Value & GetValue() const
Definition: ValueObject.h:487
virtual lldb::LanguageType GetPreferredDisplayLanguage()
const CompilerType & GetCompilerType()
Definition: Value.cpp:239
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eNoDynamicValues
enum lldb_private::DumpValueObjectOptions::PointerDepth::Mode m_mode