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)41 DumpValueObjectOptions::SetMaximumDepth(uint32_t depth) {
42 m_max_depth = depth;
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
SetShowTypes(bool show)52 DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
53 m_show_types = show;
54 return *this;
55 }
56
SetShowLocation(bool show)57 DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
58 m_show_location = show;
59 return *this;
60 }
61
SetUseObjectiveC(bool use)62 DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
63 m_use_objc = use;
64 return *this;
65 }
66
SetShowSummary(bool show)67 DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
68 if (!show)
69 SetOmitSummaryDepth(UINT32_MAX);
70 else
71 SetOmitSummaryDepth(0);
72 return *this;
73 }
74
75 DumpValueObjectOptions &
SetUseDynamicType(lldb::DynamicValueType dyn)76 DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
77 m_use_dynamic = dyn;
78 return *this;
79 }
80
81 DumpValueObjectOptions &
SetUseSyntheticValue(bool use_synthetic)82 DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
83 m_use_synthetic = use_synthetic;
84 return *this;
85 }
86
SetScopeChecked(bool check)87 DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
88 m_scope_already_checked = check;
89 return *this;
90 }
91
SetFlatOutput(bool flat)92 DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
93 m_flat_output = flat;
94 return *this;
95 }
96
97 DumpValueObjectOptions &
SetOmitSummaryDepth(uint32_t depth)98 DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
99 m_omit_summary_depth = depth;
100 return *this;
101 }
102
SetIgnoreCap(bool ignore)103 DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
104 m_ignore_cap = ignore;
105 return *this;
106 }
107
SetRawDisplay()108 DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
109 SetUseSyntheticValue(false);
110 SetOmitSummaryDepth(UINT32_MAX);
111 SetIgnoreCap(true);
112 SetHideName(false);
113 SetHideValue(false);
114 SetUseTypeDisplayName(false);
115 SetAllowOnelinerMode(false);
116 return *this;
117 }
118
SetFormat(lldb::Format format)119 DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
120 m_format = format;
121 return *this;
122 }
123
124 DumpValueObjectOptions &
SetSummary(lldb::TypeSummaryImplSP summary)125 DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
126 m_summary_sp = summary;
127 return *this;
128 }
129
130 DumpValueObjectOptions &
SetRootValueObjectName(const char * name)131 DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
132 if (name)
133 m_root_valobj_name.assign(name);
134 else
135 m_root_valobj_name.clear();
136 return *this;
137 }
138
139 DumpValueObjectOptions &
SetHideRootType(bool hide_root_type)140 DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
141 m_hide_root_type = hide_root_type;
142 return *this;
143 }
144
SetHideName(bool hide_name)145 DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
146 m_hide_name = hide_name;
147 return *this;
148 }
149
SetHideValue(bool hide_value)150 DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
151 m_hide_value = hide_value;
152 return *this;
153 }
154
SetHidePointerValue(bool hide)155 DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
156 m_hide_pointer_value = hide;
157 return *this;
158 }
159
160 DumpValueObjectOptions &
SetVariableFormatDisplayLanguage(lldb::LanguageType lang)161 DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
162 lldb::LanguageType lang) {
163 m_varformat_language = lang;
164 return *this;
165 }
166
SetRunValidator(bool run)167 DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
168 m_run_validator = run;
169 return *this;
170 }
171
172 DumpValueObjectOptions &
SetUseTypeDisplayName(bool dis)173 DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
174 m_use_type_display_name = dis;
175 return *this;
176 }
177
178 DumpValueObjectOptions &
SetAllowOnelinerMode(bool oneliner)179 DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
180 m_allow_oneliner_mode = oneliner;
181 return *this;
182 }
183
184 DumpValueObjectOptions &
SetRevealEmptyAggregates(bool reveal)185 DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
186 m_reveal_empty_aggregates = reveal;
187 return *this;
188 }
189
190 DumpValueObjectOptions &
SetElementCount(uint32_t element_count)191 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
192 m_pointer_as_array = PointerAsArraySettings(element_count);
193 return *this;
194 }
195
SetPointerAsArray(const PointerAsArraySettings & ptr_array)196 DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
197 const PointerAsArraySettings &ptr_array) {
198 m_pointer_as_array = ptr_array;
199 return *this;
200 }
201