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