xref: /openbsd-src/gnu/llvm/lldb/source/DataFormatters/DumpValueObjectOptions.cpp (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1dda28197Spatrick //===-- DumpValueObjectOptions.cpp ----------------------------------------===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9061da546Spatrick #include "lldb/DataFormatters/DumpValueObjectOptions.h"
10061da546Spatrick 
11061da546Spatrick #include "lldb/Core/ValueObject.h"
12061da546Spatrick 
13061da546Spatrick using namespace lldb;
14061da546Spatrick using namespace lldb_private;
15061da546Spatrick 
DumpValueObjectOptions()16061da546Spatrick DumpValueObjectOptions::DumpValueObjectOptions()
17061da546Spatrick     : m_summary_sp(), m_root_valobj_name(),
18061da546Spatrick       m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
19061da546Spatrick       m_decl_printing_helper(), m_pointer_as_array(), m_use_synthetic(true),
20061da546Spatrick       m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
21061da546Spatrick       m_show_types(false), m_show_location(false), m_use_objc(false),
22061da546Spatrick       m_hide_root_type(false), m_hide_name(false), m_hide_value(false),
23061da546Spatrick       m_run_validator(false), m_use_type_display_name(true),
24061da546Spatrick       m_allow_oneliner_mode(true), m_hide_pointer_value(false),
25061da546Spatrick       m_reveal_empty_aggregates(true) {}
26061da546Spatrick 
DumpValueObjectOptions(ValueObject & valobj)27061da546Spatrick DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
28061da546Spatrick     : DumpValueObjectOptions() {
29061da546Spatrick   m_use_dynamic = valobj.GetDynamicValueType();
30061da546Spatrick   m_use_synthetic = valobj.IsSynthetic();
31061da546Spatrick   m_varformat_language = valobj.GetPreferredDisplayLanguage();
32061da546Spatrick }
33061da546Spatrick 
34061da546Spatrick DumpValueObjectOptions &
SetMaximumPointerDepth(PointerDepth depth)35061da546Spatrick DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
36061da546Spatrick   m_max_ptr_depth = depth;
37061da546Spatrick   return *this;
38061da546Spatrick }
39061da546Spatrick 
40061da546Spatrick DumpValueObjectOptions &
SetMaximumDepth(uint32_t depth,bool is_default)41*f6aab3d8Srobert DumpValueObjectOptions::SetMaximumDepth(uint32_t depth, bool is_default) {
42061da546Spatrick   m_max_depth = depth;
43*f6aab3d8Srobert   m_max_depth_is_default = is_default;
44061da546Spatrick   return *this;
45061da546Spatrick }
46061da546Spatrick 
47061da546Spatrick DumpValueObjectOptions &
SetDeclPrintingHelper(DeclPrintingHelper helper)48061da546Spatrick DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
49061da546Spatrick   m_decl_printing_helper = helper;
50061da546Spatrick   return *this;
51061da546Spatrick }
52061da546Spatrick 
SetShowTypes(bool show)53061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
54061da546Spatrick   m_show_types = show;
55061da546Spatrick   return *this;
56061da546Spatrick }
57061da546Spatrick 
SetShowLocation(bool show)58061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
59061da546Spatrick   m_show_location = show;
60061da546Spatrick   return *this;
61061da546Spatrick }
62061da546Spatrick 
SetUseObjectiveC(bool use)63061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
64061da546Spatrick   m_use_objc = use;
65061da546Spatrick   return *this;
66061da546Spatrick }
67061da546Spatrick 
SetShowSummary(bool show)68061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
69061da546Spatrick   if (!show)
70061da546Spatrick     SetOmitSummaryDepth(UINT32_MAX);
71061da546Spatrick   else
72061da546Spatrick     SetOmitSummaryDepth(0);
73061da546Spatrick   return *this;
74061da546Spatrick }
75061da546Spatrick 
76061da546Spatrick DumpValueObjectOptions &
SetUseDynamicType(lldb::DynamicValueType dyn)77061da546Spatrick DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
78061da546Spatrick   m_use_dynamic = dyn;
79061da546Spatrick   return *this;
80061da546Spatrick }
81061da546Spatrick 
82061da546Spatrick DumpValueObjectOptions &
SetUseSyntheticValue(bool use_synthetic)83061da546Spatrick DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
84061da546Spatrick   m_use_synthetic = use_synthetic;
85061da546Spatrick   return *this;
86061da546Spatrick }
87061da546Spatrick 
SetScopeChecked(bool check)88061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
89061da546Spatrick   m_scope_already_checked = check;
90061da546Spatrick   return *this;
91061da546Spatrick }
92061da546Spatrick 
SetFlatOutput(bool flat)93061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
94061da546Spatrick   m_flat_output = flat;
95061da546Spatrick   return *this;
96061da546Spatrick }
97061da546Spatrick 
98061da546Spatrick DumpValueObjectOptions &
SetOmitSummaryDepth(uint32_t depth)99061da546Spatrick DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
100061da546Spatrick   m_omit_summary_depth = depth;
101061da546Spatrick   return *this;
102061da546Spatrick }
103061da546Spatrick 
SetIgnoreCap(bool ignore)104061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
105061da546Spatrick   m_ignore_cap = ignore;
106061da546Spatrick   return *this;
107061da546Spatrick }
108061da546Spatrick 
SetRawDisplay()109061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
110061da546Spatrick   SetUseSyntheticValue(false);
111061da546Spatrick   SetOmitSummaryDepth(UINT32_MAX);
112061da546Spatrick   SetIgnoreCap(true);
113061da546Spatrick   SetHideName(false);
114061da546Spatrick   SetHideValue(false);
115061da546Spatrick   SetUseTypeDisplayName(false);
116061da546Spatrick   SetAllowOnelinerMode(false);
117061da546Spatrick   return *this;
118061da546Spatrick }
119061da546Spatrick 
SetFormat(lldb::Format format)120061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
121061da546Spatrick   m_format = format;
122061da546Spatrick   return *this;
123061da546Spatrick }
124061da546Spatrick 
125061da546Spatrick DumpValueObjectOptions &
SetSummary(lldb::TypeSummaryImplSP summary)126061da546Spatrick DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
127061da546Spatrick   m_summary_sp = summary;
128061da546Spatrick   return *this;
129061da546Spatrick }
130061da546Spatrick 
131061da546Spatrick DumpValueObjectOptions &
SetRootValueObjectName(const char * name)132061da546Spatrick DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
133061da546Spatrick   if (name)
134061da546Spatrick     m_root_valobj_name.assign(name);
135061da546Spatrick   else
136061da546Spatrick     m_root_valobj_name.clear();
137061da546Spatrick   return *this;
138061da546Spatrick }
139061da546Spatrick 
140061da546Spatrick DumpValueObjectOptions &
SetHideRootType(bool hide_root_type)141061da546Spatrick DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
142061da546Spatrick   m_hide_root_type = hide_root_type;
143061da546Spatrick   return *this;
144061da546Spatrick }
145061da546Spatrick 
SetHideName(bool hide_name)146061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
147061da546Spatrick   m_hide_name = hide_name;
148061da546Spatrick   return *this;
149061da546Spatrick }
150061da546Spatrick 
SetHideValue(bool hide_value)151061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
152061da546Spatrick   m_hide_value = hide_value;
153061da546Spatrick   return *this;
154061da546Spatrick }
155061da546Spatrick 
SetHidePointerValue(bool hide)156061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
157061da546Spatrick   m_hide_pointer_value = hide;
158061da546Spatrick   return *this;
159061da546Spatrick }
160061da546Spatrick 
161061da546Spatrick DumpValueObjectOptions &
SetVariableFormatDisplayLanguage(lldb::LanguageType lang)162061da546Spatrick DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
163061da546Spatrick     lldb::LanguageType lang) {
164061da546Spatrick   m_varformat_language = lang;
165061da546Spatrick   return *this;
166061da546Spatrick }
167061da546Spatrick 
SetRunValidator(bool run)168061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
169061da546Spatrick   m_run_validator = run;
170061da546Spatrick   return *this;
171061da546Spatrick }
172061da546Spatrick 
173061da546Spatrick DumpValueObjectOptions &
SetUseTypeDisplayName(bool dis)174061da546Spatrick DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
175061da546Spatrick   m_use_type_display_name = dis;
176061da546Spatrick   return *this;
177061da546Spatrick }
178061da546Spatrick 
179061da546Spatrick DumpValueObjectOptions &
SetAllowOnelinerMode(bool oneliner)180061da546Spatrick DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
181061da546Spatrick   m_allow_oneliner_mode = oneliner;
182061da546Spatrick   return *this;
183061da546Spatrick }
184061da546Spatrick 
185061da546Spatrick DumpValueObjectOptions &
SetRevealEmptyAggregates(bool reveal)186061da546Spatrick DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
187061da546Spatrick   m_reveal_empty_aggregates = reveal;
188061da546Spatrick   return *this;
189061da546Spatrick }
190061da546Spatrick 
191061da546Spatrick DumpValueObjectOptions &
SetElementCount(uint32_t element_count)192061da546Spatrick DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
193061da546Spatrick   m_pointer_as_array = PointerAsArraySettings(element_count);
194061da546Spatrick   return *this;
195061da546Spatrick }
196061da546Spatrick 
SetPointerAsArray(const PointerAsArraySettings & ptr_array)197061da546Spatrick DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
198061da546Spatrick     const PointerAsArraySettings &ptr_array) {
199061da546Spatrick   m_pointer_as_array = ptr_array;
200061da546Spatrick   return *this;
201061da546Spatrick }
202