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