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