1 //===-- DumpValueObjectOptions.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 
9 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
10 
11 #include "lldb/Core/ValueObject.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
DumpValueObjectOptions()16 DumpValueObjectOptions::DumpValueObjectOptions()
17     : m_summary_sp(), m_root_valobj_name(),
18       m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
19       m_decl_printing_helper(), m_pointer_as_array(), m_use_synthetic(true),
20       m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
21       m_show_types(false), m_show_location(false), m_use_objc(false),
22       m_hide_root_type(false), m_hide_name(false), m_hide_value(false),
23       m_run_validator(false), m_use_type_display_name(true),
24       m_allow_oneliner_mode(true), m_hide_pointer_value(false),
25       m_reveal_empty_aggregates(true) {}
26 
DumpValueObjectOptions(ValueObject & valobj)27 DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
28     : DumpValueObjectOptions() {
29   m_use_dynamic = valobj.GetDynamicValueType();
30   m_use_synthetic = valobj.IsSynthetic();
31   m_varformat_language = valobj.GetPreferredDisplayLanguage();
32 }
33 
34 DumpValueObjectOptions &
SetMaximumPointerDepth(PointerDepth depth)35 DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
36   m_max_ptr_depth = depth;
37   return *this;
38 }
39 
40 DumpValueObjectOptions &
SetMaximumDepth(uint32_t depth,bool is_default)41 DumpValueObjectOptions::SetMaximumDepth(uint32_t depth, bool is_default) {
42   m_max_depth = depth;
43   m_max_depth_is_default = is_default;
44   return *this;
45 }
46 
47 DumpValueObjectOptions &
SetDeclPrintingHelper(DeclPrintingHelper helper)48 DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
49   m_decl_printing_helper = helper;
50   return *this;
51 }
52 
SetShowTypes(bool show)53 DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
54   m_show_types = show;
55   return *this;
56 }
57 
SetShowLocation(bool show)58 DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
59   m_show_location = show;
60   return *this;
61 }
62 
SetUseObjectiveC(bool use)63 DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
64   m_use_objc = use;
65   return *this;
66 }
67 
SetShowSummary(bool show)68 DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
69   if (!show)
70     SetOmitSummaryDepth(UINT32_MAX);
71   else
72     SetOmitSummaryDepth(0);
73   return *this;
74 }
75 
76 DumpValueObjectOptions &
SetUseDynamicType(lldb::DynamicValueType dyn)77 DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
78   m_use_dynamic = dyn;
79   return *this;
80 }
81 
82 DumpValueObjectOptions &
SetUseSyntheticValue(bool use_synthetic)83 DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
84   m_use_synthetic = use_synthetic;
85   return *this;
86 }
87 
SetScopeChecked(bool check)88 DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
89   m_scope_already_checked = check;
90   return *this;
91 }
92 
SetFlatOutput(bool flat)93 DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
94   m_flat_output = flat;
95   return *this;
96 }
97 
98 DumpValueObjectOptions &
SetOmitSummaryDepth(uint32_t depth)99 DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
100   m_omit_summary_depth = depth;
101   return *this;
102 }
103 
SetIgnoreCap(bool ignore)104 DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
105   m_ignore_cap = ignore;
106   return *this;
107 }
108 
SetRawDisplay()109 DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
110   SetUseSyntheticValue(false);
111   SetOmitSummaryDepth(UINT32_MAX);
112   SetIgnoreCap(true);
113   SetHideName(false);
114   SetHideValue(false);
115   SetUseTypeDisplayName(false);
116   SetAllowOnelinerMode(false);
117   return *this;
118 }
119 
SetFormat(lldb::Format format)120 DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
121   m_format = format;
122   return *this;
123 }
124 
125 DumpValueObjectOptions &
SetSummary(lldb::TypeSummaryImplSP summary)126 DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
127   m_summary_sp = summary;
128   return *this;
129 }
130 
131 DumpValueObjectOptions &
SetRootValueObjectName(const char * name)132 DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
133   if (name)
134     m_root_valobj_name.assign(name);
135   else
136     m_root_valobj_name.clear();
137   return *this;
138 }
139 
140 DumpValueObjectOptions &
SetHideRootType(bool hide_root_type)141 DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
142   m_hide_root_type = hide_root_type;
143   return *this;
144 }
145 
SetHideName(bool hide_name)146 DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
147   m_hide_name = hide_name;
148   return *this;
149 }
150 
SetHideValue(bool hide_value)151 DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
152   m_hide_value = hide_value;
153   return *this;
154 }
155 
SetHidePointerValue(bool hide)156 DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
157   m_hide_pointer_value = hide;
158   return *this;
159 }
160 
161 DumpValueObjectOptions &
SetVariableFormatDisplayLanguage(lldb::LanguageType lang)162 DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
163     lldb::LanguageType lang) {
164   m_varformat_language = lang;
165   return *this;
166 }
167 
SetRunValidator(bool run)168 DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
169   m_run_validator = run;
170   return *this;
171 }
172 
173 DumpValueObjectOptions &
SetUseTypeDisplayName(bool dis)174 DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
175   m_use_type_display_name = dis;
176   return *this;
177 }
178 
179 DumpValueObjectOptions &
SetAllowOnelinerMode(bool oneliner)180 DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
181   m_allow_oneliner_mode = oneliner;
182   return *this;
183 }
184 
185 DumpValueObjectOptions &
SetRevealEmptyAggregates(bool reveal)186 DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
187   m_reveal_empty_aggregates = reveal;
188   return *this;
189 }
190 
191 DumpValueObjectOptions &
SetElementCount(uint32_t element_count)192 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
193   m_pointer_as_array = PointerAsArraySettings(element_count);
194   return *this;
195 }
196 
SetPointerAsArray(const PointerAsArraySettings & ptr_array)197 DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
198     const PointerAsArraySettings &ptr_array) {
199   m_pointer_as_array = ptr_array;
200   return *this;
201 }
202