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