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

source code of lldb/source/DataFormatters/DumpValueObjectOptions.cpp