15ffd83dbSDimitry Andric //===-- DumpValueObjectOptions.cpp ----------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "lldb/DataFormatters/DumpValueObjectOptions.h"
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #include "lldb/Core/ValueObject.h"
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric using namespace lldb;
140b57cec5SDimitry Andric using namespace lldb_private;
150b57cec5SDimitry Andric 
DumpValueObjectOptions()160b57cec5SDimitry Andric DumpValueObjectOptions::DumpValueObjectOptions()
170b57cec5SDimitry Andric     : m_summary_sp(), m_root_valobj_name(),
180b57cec5SDimitry Andric       m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
1906c3fb27SDimitry Andric       m_decl_printing_helper(), m_child_printing_decider(),
2006c3fb27SDimitry Andric       m_pointer_as_array(), m_use_synthetic(true),
210b57cec5SDimitry Andric       m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
220b57cec5SDimitry Andric       m_show_types(false), m_show_location(false), m_use_objc(false),
2306c3fb27SDimitry Andric       m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
2406c3fb27SDimitry Andric       m_hide_value(false), m_run_validator(false),
2506c3fb27SDimitry Andric       m_use_type_display_name(true), m_allow_oneliner_mode(true),
2606c3fb27SDimitry Andric       m_hide_pointer_value(false), m_reveal_empty_aggregates(true) {}
270b57cec5SDimitry Andric 
DumpValueObjectOptions(ValueObject & valobj)280b57cec5SDimitry Andric DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
290b57cec5SDimitry Andric     : DumpValueObjectOptions() {
300b57cec5SDimitry Andric   m_use_dynamic = valobj.GetDynamicValueType();
310b57cec5SDimitry Andric   m_use_synthetic = valobj.IsSynthetic();
320b57cec5SDimitry Andric   m_varformat_language = valobj.GetPreferredDisplayLanguage();
330b57cec5SDimitry Andric }
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric DumpValueObjectOptions &
SetMaximumPointerDepth(PointerDepth depth)360b57cec5SDimitry Andric DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
370b57cec5SDimitry Andric   m_max_ptr_depth = depth;
380b57cec5SDimitry Andric   return *this;
390b57cec5SDimitry Andric }
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric DumpValueObjectOptions &
SetMaximumDepth(uint32_t depth,bool is_default)4281ad6265SDimitry Andric DumpValueObjectOptions::SetMaximumDepth(uint32_t depth, bool is_default) {
430b57cec5SDimitry Andric   m_max_depth = depth;
4481ad6265SDimitry Andric   m_max_depth_is_default = is_default;
450b57cec5SDimitry Andric   return *this;
460b57cec5SDimitry Andric }
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric DumpValueObjectOptions &
SetDeclPrintingHelper(DeclPrintingHelper helper)490b57cec5SDimitry Andric DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
500b57cec5SDimitry Andric   m_decl_printing_helper = helper;
510b57cec5SDimitry Andric   return *this;
520b57cec5SDimitry Andric }
530b57cec5SDimitry Andric 
5406c3fb27SDimitry Andric DumpValueObjectOptions &
SetChildPrintingDecider(ChildPrintingDecider decider)5506c3fb27SDimitry Andric DumpValueObjectOptions::SetChildPrintingDecider(ChildPrintingDecider decider) {
5606c3fb27SDimitry Andric   m_child_printing_decider = decider;
5706c3fb27SDimitry Andric   return *this;
5806c3fb27SDimitry Andric }
5906c3fb27SDimitry Andric 
SetShowTypes(bool show)600b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
610b57cec5SDimitry Andric   m_show_types = show;
620b57cec5SDimitry Andric   return *this;
630b57cec5SDimitry Andric }
640b57cec5SDimitry Andric 
SetShowLocation(bool show)650b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
660b57cec5SDimitry Andric   m_show_location = show;
670b57cec5SDimitry Andric   return *this;
680b57cec5SDimitry Andric }
690b57cec5SDimitry Andric 
SetUseObjectiveC(bool use)700b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
710b57cec5SDimitry Andric   m_use_objc = use;
720b57cec5SDimitry Andric   return *this;
730b57cec5SDimitry Andric }
740b57cec5SDimitry Andric 
SetShowSummary(bool show)750b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
760b57cec5SDimitry Andric   if (!show)
770b57cec5SDimitry Andric     SetOmitSummaryDepth(UINT32_MAX);
780b57cec5SDimitry Andric   else
790b57cec5SDimitry Andric     SetOmitSummaryDepth(0);
800b57cec5SDimitry Andric   return *this;
810b57cec5SDimitry Andric }
820b57cec5SDimitry Andric 
830b57cec5SDimitry Andric DumpValueObjectOptions &
SetUseDynamicType(lldb::DynamicValueType dyn)840b57cec5SDimitry Andric DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
850b57cec5SDimitry Andric   m_use_dynamic = dyn;
860b57cec5SDimitry Andric   return *this;
870b57cec5SDimitry Andric }
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric DumpValueObjectOptions &
SetUseSyntheticValue(bool use_synthetic)900b57cec5SDimitry Andric DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
910b57cec5SDimitry Andric   m_use_synthetic = use_synthetic;
920b57cec5SDimitry Andric   return *this;
930b57cec5SDimitry Andric }
940b57cec5SDimitry Andric 
SetScopeChecked(bool check)950b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
960b57cec5SDimitry Andric   m_scope_already_checked = check;
970b57cec5SDimitry Andric   return *this;
980b57cec5SDimitry Andric }
990b57cec5SDimitry Andric 
SetFlatOutput(bool flat)1000b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
1010b57cec5SDimitry Andric   m_flat_output = flat;
1020b57cec5SDimitry Andric   return *this;
1030b57cec5SDimitry Andric }
1040b57cec5SDimitry Andric 
1050b57cec5SDimitry Andric DumpValueObjectOptions &
SetOmitSummaryDepth(uint32_t depth)1060b57cec5SDimitry Andric DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
1070b57cec5SDimitry Andric   m_omit_summary_depth = depth;
1080b57cec5SDimitry Andric   return *this;
1090b57cec5SDimitry Andric }
1100b57cec5SDimitry Andric 
SetIgnoreCap(bool ignore)1110b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
1120b57cec5SDimitry Andric   m_ignore_cap = ignore;
1130b57cec5SDimitry Andric   return *this;
1140b57cec5SDimitry Andric }
1150b57cec5SDimitry Andric 
SetRawDisplay()1160b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
1170b57cec5SDimitry Andric   SetUseSyntheticValue(false);
1180b57cec5SDimitry Andric   SetOmitSummaryDepth(UINT32_MAX);
1190b57cec5SDimitry Andric   SetIgnoreCap(true);
1200b57cec5SDimitry Andric   SetHideName(false);
1210b57cec5SDimitry Andric   SetHideValue(false);
1220b57cec5SDimitry Andric   SetUseTypeDisplayName(false);
1230b57cec5SDimitry Andric   SetAllowOnelinerMode(false);
1240b57cec5SDimitry Andric   return *this;
1250b57cec5SDimitry Andric }
1260b57cec5SDimitry Andric 
SetFormat(lldb::Format format)1270b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
1280b57cec5SDimitry Andric   m_format = format;
1290b57cec5SDimitry Andric   return *this;
1300b57cec5SDimitry Andric }
1310b57cec5SDimitry Andric 
1320b57cec5SDimitry Andric DumpValueObjectOptions &
SetSummary(lldb::TypeSummaryImplSP summary)1330b57cec5SDimitry Andric DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
1340b57cec5SDimitry Andric   m_summary_sp = summary;
1350b57cec5SDimitry Andric   return *this;
1360b57cec5SDimitry Andric }
1370b57cec5SDimitry Andric 
1380b57cec5SDimitry Andric DumpValueObjectOptions &
SetRootValueObjectName(const char * name)1390b57cec5SDimitry Andric DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
1400b57cec5SDimitry Andric   if (name)
1410b57cec5SDimitry Andric     m_root_valobj_name.assign(name);
1420b57cec5SDimitry Andric   else
1430b57cec5SDimitry Andric     m_root_valobj_name.clear();
1440b57cec5SDimitry Andric   return *this;
1450b57cec5SDimitry Andric }
1460b57cec5SDimitry Andric 
1470b57cec5SDimitry Andric DumpValueObjectOptions &
SetHideRootType(bool hide_root_type)1480b57cec5SDimitry Andric DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
1490b57cec5SDimitry Andric   m_hide_root_type = hide_root_type;
1500b57cec5SDimitry Andric   return *this;
1510b57cec5SDimitry Andric }
1520b57cec5SDimitry Andric 
15306c3fb27SDimitry Andric DumpValueObjectOptions &
SetHideRootName(bool hide_root_name)15406c3fb27SDimitry Andric DumpValueObjectOptions::SetHideRootName(bool hide_root_name) {
15506c3fb27SDimitry Andric   m_hide_root_name = hide_root_name;
15606c3fb27SDimitry Andric   return *this;
15706c3fb27SDimitry Andric }
15806c3fb27SDimitry Andric 
SetHideName(bool hide_name)1590b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
1600b57cec5SDimitry Andric   m_hide_name = hide_name;
1610b57cec5SDimitry Andric   return *this;
1620b57cec5SDimitry Andric }
1630b57cec5SDimitry Andric 
SetHideValue(bool hide_value)1640b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
1650b57cec5SDimitry Andric   m_hide_value = hide_value;
1660b57cec5SDimitry Andric   return *this;
1670b57cec5SDimitry Andric }
1680b57cec5SDimitry Andric 
SetHidePointerValue(bool hide)1690b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
1700b57cec5SDimitry Andric   m_hide_pointer_value = hide;
1710b57cec5SDimitry Andric   return *this;
1720b57cec5SDimitry Andric }
1730b57cec5SDimitry Andric 
1740b57cec5SDimitry Andric DumpValueObjectOptions &
SetVariableFormatDisplayLanguage(lldb::LanguageType lang)1750b57cec5SDimitry Andric DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
1760b57cec5SDimitry Andric     lldb::LanguageType lang) {
1770b57cec5SDimitry Andric   m_varformat_language = lang;
1780b57cec5SDimitry Andric   return *this;
1790b57cec5SDimitry Andric }
1800b57cec5SDimitry Andric 
SetRunValidator(bool run)1810b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
1820b57cec5SDimitry Andric   m_run_validator = run;
1830b57cec5SDimitry Andric   return *this;
1840b57cec5SDimitry Andric }
1850b57cec5SDimitry Andric 
1860b57cec5SDimitry Andric DumpValueObjectOptions &
SetUseTypeDisplayName(bool dis)1870b57cec5SDimitry Andric DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
1880b57cec5SDimitry Andric   m_use_type_display_name = dis;
1890b57cec5SDimitry Andric   return *this;
1900b57cec5SDimitry Andric }
1910b57cec5SDimitry Andric 
1920b57cec5SDimitry Andric DumpValueObjectOptions &
SetAllowOnelinerMode(bool oneliner)1930b57cec5SDimitry Andric DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
1940b57cec5SDimitry Andric   m_allow_oneliner_mode = oneliner;
1950b57cec5SDimitry Andric   return *this;
1960b57cec5SDimitry Andric }
1970b57cec5SDimitry Andric 
1980b57cec5SDimitry Andric DumpValueObjectOptions &
SetRevealEmptyAggregates(bool reveal)1990b57cec5SDimitry Andric DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
2000b57cec5SDimitry Andric   m_reveal_empty_aggregates = reveal;
2010b57cec5SDimitry Andric   return *this;
2020b57cec5SDimitry Andric }
2030b57cec5SDimitry Andric 
2040b57cec5SDimitry Andric DumpValueObjectOptions &
SetElementCount(uint32_t element_count)2050b57cec5SDimitry Andric DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
2060b57cec5SDimitry Andric   m_pointer_as_array = PointerAsArraySettings(element_count);
2070b57cec5SDimitry Andric   return *this;
2080b57cec5SDimitry Andric }
2090b57cec5SDimitry Andric 
SetPointerAsArray(const PointerAsArraySettings & ptr_array)2100b57cec5SDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
2110b57cec5SDimitry Andric     const PointerAsArraySettings &ptr_array) {
2120b57cec5SDimitry Andric   m_pointer_as_array = ptr_array;
2130b57cec5SDimitry Andric   return *this;
2140b57cec5SDimitry Andric }
215