blob: 84f21696e0548319ff1645f80f6af49d3a444e87 [file] [log] [blame]
Kate Stoneb9c1b512016-09-06 20:57:50 +00001//===-- DumpValueObjectOptions.cpp -----------------------------------*- C++
2//-*-===//
Enrico Granatac8e76492015-10-19 22:04:25 +00003//
Chandler Carruth2946cd72019-01-19 08:50:56 +00004// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Enrico Granatac8e76492015-10-19 22:04:25 +00007//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/DataFormatters/DumpValueObjectOptions.h"
11
Enrico Granatac8e76492015-10-19 22:04:25 +000012#include "lldb/Core/ValueObject.h"
13
14using namespace lldb;
15using namespace lldb_private;
16
Kate Stoneb9c1b512016-09-06 20:57:50 +000017DumpValueObjectOptions::DumpValueObjectOptions()
18 : m_summary_sp(), m_root_valobj_name(),
19 m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
Enrico Granata9ac0dac2016-11-04 18:15:39 +000020 m_decl_printing_helper(), m_pointer_as_array(), m_use_synthetic(true),
Kate Stoneb9c1b512016-09-06 20:57:50 +000021 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_name(false), m_hide_value(false),
24 m_run_validator(false), m_use_type_display_name(true),
25 m_allow_oneliner_mode(true), m_hide_pointer_value(false),
26 m_reveal_empty_aggregates(true) {}
Enrico Granatac8e76492015-10-19 22:04:25 +000027
Kate Stoneb9c1b512016-09-06 20:57:50 +000028DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
29 : DumpValueObjectOptions() {
30 m_use_dynamic = valobj.GetDynamicValueType();
31 m_use_synthetic = valobj.IsSynthetic();
32 m_varformat_language = valobj.GetPreferredDisplayLanguage();
Enrico Granatac8e76492015-10-19 22:04:25 +000033}
34
Kate Stoneb9c1b512016-09-06 20:57:50 +000035DumpValueObjectOptions &
36DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
37 m_max_ptr_depth = depth;
38 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000039}
40
Kate Stoneb9c1b512016-09-06 20:57:50 +000041DumpValueObjectOptions &
42DumpValueObjectOptions::SetMaximumDepth(uint32_t depth) {
43 m_max_depth = depth;
44 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000045}
46
Kate Stoneb9c1b512016-09-06 20:57:50 +000047DumpValueObjectOptions &
48DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
49 m_decl_printing_helper = helper;
50 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000051}
52
Kate Stoneb9c1b512016-09-06 20:57:50 +000053DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
54 m_show_types = show;
55 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000056}
57
Kate Stoneb9c1b512016-09-06 20:57:50 +000058DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
59 m_show_location = show;
60 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000061}
62
Kate Stoneb9c1b512016-09-06 20:57:50 +000063DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
64 m_use_objc = use;
65 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000066}
67
Kate Stoneb9c1b512016-09-06 20:57:50 +000068DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
Jonas Devliegherea6682a42018-12-15 00:15:33 +000069 if (!show)
Enrico Granatac8e76492015-10-19 22:04:25 +000070 SetOmitSummaryDepth(UINT32_MAX);
Kate Stoneb9c1b512016-09-06 20:57:50 +000071 else
72 SetOmitSummaryDepth(0);
73 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000074}
75
Kate Stoneb9c1b512016-09-06 20:57:50 +000076DumpValueObjectOptions &
77DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
78 m_use_dynamic = dyn;
79 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000080}
81
Kate Stoneb9c1b512016-09-06 20:57:50 +000082DumpValueObjectOptions &
83DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
84 m_use_synthetic = use_synthetic;
85 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000086}
87
Kate Stoneb9c1b512016-09-06 20:57:50 +000088DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
89 m_scope_already_checked = check;
90 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000091}
92
Kate Stoneb9c1b512016-09-06 20:57:50 +000093DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
94 m_flat_output = flat;
95 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +000096}
97
Kate Stoneb9c1b512016-09-06 20:57:50 +000098DumpValueObjectOptions &
99DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
100 m_omit_summary_depth = depth;
101 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000102}
103
Kate Stoneb9c1b512016-09-06 20:57:50 +0000104DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
105 m_ignore_cap = ignore;
106 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000107}
108
Kate Stoneb9c1b512016-09-06 20:57:50 +0000109DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
110 SetUseSyntheticValue(false);
111 SetOmitSummaryDepth(UINT32_MAX);
112 SetIgnoreCap(true);
113 SetHideName(false);
114 SetHideValue(false);
115 SetUseTypeDisplayName(false);
116 SetAllowOnelinerMode(false);
117 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000118}
119
Kate Stoneb9c1b512016-09-06 20:57:50 +0000120DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
121 m_format = format;
122 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000123}
124
Kate Stoneb9c1b512016-09-06 20:57:50 +0000125DumpValueObjectOptions &
126DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
127 m_summary_sp = summary;
128 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000129}
130
Kate Stoneb9c1b512016-09-06 20:57:50 +0000131DumpValueObjectOptions &
132DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
133 if (name)
134 m_root_valobj_name.assign(name);
135 else
136 m_root_valobj_name.clear();
137 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000138}
139
Kate Stoneb9c1b512016-09-06 20:57:50 +0000140DumpValueObjectOptions &
141DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
142 m_hide_root_type = hide_root_type;
143 return *this;
Enrico Granatac8e76492015-10-19 22:04:25 +0000144}
Enrico Granata8cf44d92015-11-10 19:07:58 +0000145
Kate Stoneb9c1b512016-09-06 20:57:50 +0000146DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
147 m_hide_name = hide_name;
148 return *this;
Enrico Granata8cf44d92015-11-10 19:07:58 +0000149}
Enrico Granata520a4222016-04-25 00:52:47 +0000150
Kate Stoneb9c1b512016-09-06 20:57:50 +0000151DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
152 m_hide_value = hide_value;
153 return *this;
154}
155
156DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
157 m_hide_pointer_value = hide;
158 return *this;
159}
160
161DumpValueObjectOptions &
162DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
163 lldb::LanguageType lang) {
164 m_varformat_language = lang;
165 return *this;
166}
167
168DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
169 m_run_validator = run;
170 return *this;
171}
172
173DumpValueObjectOptions &
174DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
175 m_use_type_display_name = dis;
176 return *this;
177}
178
179DumpValueObjectOptions &
180DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
181 m_allow_oneliner_mode = oneliner;
182 return *this;
183}
184
185DumpValueObjectOptions &
186DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
187 m_reveal_empty_aggregates = reveal;
188 return *this;
189}
190
191DumpValueObjectOptions &
192DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
Enrico Granata9ac0dac2016-11-04 18:15:39 +0000193 m_pointer_as_array = PointerAsArraySettings(element_count);
194 return *this;
195}
196
197DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
198 const PointerAsArraySettings &ptr_array) {
199 m_pointer_as_array = ptr_array;
Kate Stoneb9c1b512016-09-06 20:57:50 +0000200 return *this;
Enrico Granata520a4222016-04-25 00:52:47 +0000201}