1435933ddSDimitry Andric //===-- DumpValueObjectOptions.cpp -----------------------------------*- C++
2435933ddSDimitry Andric //-*-===//
39f2f44ceSEd Maste //
49f2f44ceSEd Maste //                     The LLVM Compiler Infrastructure
59f2f44ceSEd Maste //
69f2f44ceSEd Maste // This file is distributed under the University of Illinois Open Source
79f2f44ceSEd Maste // License. See LICENSE.TXT for details.
89f2f44ceSEd Maste //
99f2f44ceSEd Maste //===----------------------------------------------------------------------===//
109f2f44ceSEd Maste 
119f2f44ceSEd Maste #include "lldb/DataFormatters/DumpValueObjectOptions.h"
129f2f44ceSEd Maste 
139f2f44ceSEd Maste #include "lldb/Core/ValueObject.h"
149f2f44ceSEd Maste 
159f2f44ceSEd Maste using namespace lldb;
169f2f44ceSEd Maste using namespace lldb_private;
179f2f44ceSEd Maste 
DumpValueObjectOptions()18435933ddSDimitry Andric DumpValueObjectOptions::DumpValueObjectOptions()
19435933ddSDimitry Andric     : m_summary_sp(), m_root_valobj_name(),
209f2f44ceSEd Maste       m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
21435933ddSDimitry Andric       m_decl_printing_helper(), m_pointer_as_array(), m_use_synthetic(true),
22435933ddSDimitry Andric       m_scope_already_checked(false), m_flat_output(false), m_ignore_cap(false),
23435933ddSDimitry Andric       m_show_types(false), m_show_location(false), m_use_objc(false),
24435933ddSDimitry Andric       m_hide_root_type(false), m_hide_name(false), m_hide_value(false),
25435933ddSDimitry Andric       m_run_validator(false), m_use_type_display_name(true),
26435933ddSDimitry Andric       m_allow_oneliner_mode(true), m_hide_pointer_value(false),
27435933ddSDimitry Andric       m_reveal_empty_aggregates(true) {}
289f2f44ceSEd Maste 
DumpValueObjectOptions(ValueObject & valobj)29435933ddSDimitry Andric DumpValueObjectOptions::DumpValueObjectOptions(ValueObject &valobj)
30435933ddSDimitry Andric     : DumpValueObjectOptions() {
319f2f44ceSEd Maste   m_use_dynamic = valobj.GetDynamicValueType();
329f2f44ceSEd Maste   m_use_synthetic = valobj.IsSynthetic();
339f2f44ceSEd Maste   m_varformat_language = valobj.GetPreferredDisplayLanguage();
349f2f44ceSEd Maste }
359f2f44ceSEd Maste 
369f2f44ceSEd Maste DumpValueObjectOptions &
SetMaximumPointerDepth(PointerDepth depth)37435933ddSDimitry Andric DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
389f2f44ceSEd Maste   m_max_ptr_depth = depth;
399f2f44ceSEd Maste   return *this;
409f2f44ceSEd Maste }
419f2f44ceSEd Maste 
429f2f44ceSEd Maste DumpValueObjectOptions &
SetMaximumDepth(uint32_t depth)43435933ddSDimitry Andric DumpValueObjectOptions::SetMaximumDepth(uint32_t depth) {
449f2f44ceSEd Maste   m_max_depth = depth;
459f2f44ceSEd Maste   return *this;
469f2f44ceSEd Maste }
479f2f44ceSEd Maste 
489f2f44ceSEd Maste DumpValueObjectOptions &
SetDeclPrintingHelper(DeclPrintingHelper helper)49435933ddSDimitry Andric DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper) {
509f2f44ceSEd Maste   m_decl_printing_helper = helper;
519f2f44ceSEd Maste   return *this;
529f2f44ceSEd Maste }
539f2f44ceSEd Maste 
SetShowTypes(bool show)54435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowTypes(bool show) {
559f2f44ceSEd Maste   m_show_types = show;
569f2f44ceSEd Maste   return *this;
579f2f44ceSEd Maste }
589f2f44ceSEd Maste 
SetShowLocation(bool show)59435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowLocation(bool show) {
609f2f44ceSEd Maste   m_show_location = show;
619f2f44ceSEd Maste   return *this;
629f2f44ceSEd Maste }
639f2f44ceSEd Maste 
SetUseObjectiveC(bool use)64435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) {
659f2f44ceSEd Maste   m_use_objc = use;
669f2f44ceSEd Maste   return *this;
679f2f44ceSEd Maste }
689f2f44ceSEd Maste 
SetShowSummary(bool show)69435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) {
70*b5893f02SDimitry Andric   if (!show)
719f2f44ceSEd Maste     SetOmitSummaryDepth(UINT32_MAX);
729f2f44ceSEd Maste   else
739f2f44ceSEd Maste     SetOmitSummaryDepth(0);
749f2f44ceSEd Maste   return *this;
759f2f44ceSEd Maste }
769f2f44ceSEd Maste 
779f2f44ceSEd Maste DumpValueObjectOptions &
SetUseDynamicType(lldb::DynamicValueType dyn)78435933ddSDimitry Andric DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn) {
799f2f44ceSEd Maste   m_use_dynamic = dyn;
809f2f44ceSEd Maste   return *this;
819f2f44ceSEd Maste }
829f2f44ceSEd Maste 
839f2f44ceSEd Maste DumpValueObjectOptions &
SetUseSyntheticValue(bool use_synthetic)84435933ddSDimitry Andric DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic) {
859f2f44ceSEd Maste   m_use_synthetic = use_synthetic;
869f2f44ceSEd Maste   return *this;
879f2f44ceSEd Maste }
889f2f44ceSEd Maste 
SetScopeChecked(bool check)89435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetScopeChecked(bool check) {
909f2f44ceSEd Maste   m_scope_already_checked = check;
919f2f44ceSEd Maste   return *this;
929f2f44ceSEd Maste }
939f2f44ceSEd Maste 
SetFlatOutput(bool flat)94435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetFlatOutput(bool flat) {
959f2f44ceSEd Maste   m_flat_output = flat;
969f2f44ceSEd Maste   return *this;
979f2f44ceSEd Maste }
989f2f44ceSEd Maste 
999f2f44ceSEd Maste DumpValueObjectOptions &
SetOmitSummaryDepth(uint32_t depth)100435933ddSDimitry Andric DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth) {
1019f2f44ceSEd Maste   m_omit_summary_depth = depth;
1029f2f44ceSEd Maste   return *this;
1039f2f44ceSEd Maste }
1049f2f44ceSEd Maste 
SetIgnoreCap(bool ignore)105435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetIgnoreCap(bool ignore) {
1069f2f44ceSEd Maste   m_ignore_cap = ignore;
1079f2f44ceSEd Maste   return *this;
1089f2f44ceSEd Maste }
1099f2f44ceSEd Maste 
SetRawDisplay()110435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetRawDisplay() {
1119f2f44ceSEd Maste   SetUseSyntheticValue(false);
1129f2f44ceSEd Maste   SetOmitSummaryDepth(UINT32_MAX);
1139f2f44ceSEd Maste   SetIgnoreCap(true);
1149f2f44ceSEd Maste   SetHideName(false);
1159f2f44ceSEd Maste   SetHideValue(false);
1169f2f44ceSEd Maste   SetUseTypeDisplayName(false);
1179f2f44ceSEd Maste   SetAllowOnelinerMode(false);
1189f2f44ceSEd Maste   return *this;
1199f2f44ceSEd Maste }
1209f2f44ceSEd Maste 
SetFormat(lldb::Format format)121435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetFormat(lldb::Format format) {
1229f2f44ceSEd Maste   m_format = format;
1239f2f44ceSEd Maste   return *this;
1249f2f44ceSEd Maste }
1259f2f44ceSEd Maste 
1269f2f44ceSEd Maste DumpValueObjectOptions &
SetSummary(lldb::TypeSummaryImplSP summary)127435933ddSDimitry Andric DumpValueObjectOptions::SetSummary(lldb::TypeSummaryImplSP summary) {
1289f2f44ceSEd Maste   m_summary_sp = summary;
1299f2f44ceSEd Maste   return *this;
1309f2f44ceSEd Maste }
1319f2f44ceSEd Maste 
1329f2f44ceSEd Maste DumpValueObjectOptions &
SetRootValueObjectName(const char * name)133435933ddSDimitry Andric DumpValueObjectOptions::SetRootValueObjectName(const char *name) {
1349f2f44ceSEd Maste   if (name)
1359f2f44ceSEd Maste     m_root_valobj_name.assign(name);
1369f2f44ceSEd Maste   else
1379f2f44ceSEd Maste     m_root_valobj_name.clear();
1389f2f44ceSEd Maste   return *this;
1399f2f44ceSEd Maste }
1409f2f44ceSEd Maste 
1419f2f44ceSEd Maste DumpValueObjectOptions &
SetHideRootType(bool hide_root_type)142435933ddSDimitry Andric DumpValueObjectOptions::SetHideRootType(bool hide_root_type) {
1439f2f44ceSEd Maste   m_hide_root_type = hide_root_type;
1449f2f44ceSEd Maste   return *this;
1459f2f44ceSEd Maste }
1469f2f44ceSEd Maste 
SetHideName(bool hide_name)147435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHideName(bool hide_name) {
1489f2f44ceSEd Maste   m_hide_name = hide_name;
1499f2f44ceSEd Maste   return *this;
1509f2f44ceSEd Maste }
1519f2f44ceSEd Maste 
SetHideValue(bool hide_value)152435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHideValue(bool hide_value) {
1539f2f44ceSEd Maste   m_hide_value = hide_value;
1549f2f44ceSEd Maste   return *this;
1559f2f44ceSEd Maste }
1569f2f44ceSEd Maste 
SetHidePointerValue(bool hide)157435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetHidePointerValue(bool hide) {
1589f2f44ceSEd Maste   m_hide_pointer_value = hide;
1599f2f44ceSEd Maste   return *this;
1609f2f44ceSEd Maste }
1619f2f44ceSEd Maste 
1629f2f44ceSEd Maste DumpValueObjectOptions &
SetVariableFormatDisplayLanguage(lldb::LanguageType lang)163435933ddSDimitry Andric DumpValueObjectOptions::SetVariableFormatDisplayLanguage(
164435933ddSDimitry Andric     lldb::LanguageType lang) {
1659f2f44ceSEd Maste   m_varformat_language = lang;
1669f2f44ceSEd Maste   return *this;
1679f2f44ceSEd Maste }
1689f2f44ceSEd Maste 
SetRunValidator(bool run)169435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetRunValidator(bool run) {
1709f2f44ceSEd Maste   m_run_validator = run;
1719f2f44ceSEd Maste   return *this;
1729f2f44ceSEd Maste }
1739f2f44ceSEd Maste 
1749f2f44ceSEd Maste DumpValueObjectOptions &
SetUseTypeDisplayName(bool dis)175435933ddSDimitry Andric DumpValueObjectOptions::SetUseTypeDisplayName(bool dis) {
1769f2f44ceSEd Maste   m_use_type_display_name = dis;
1779f2f44ceSEd Maste   return *this;
1789f2f44ceSEd Maste }
1799f2f44ceSEd Maste 
1809f2f44ceSEd Maste DumpValueObjectOptions &
SetAllowOnelinerMode(bool oneliner)181435933ddSDimitry Andric DumpValueObjectOptions::SetAllowOnelinerMode(bool oneliner) {
1829f2f44ceSEd Maste   m_allow_oneliner_mode = oneliner;
1839f2f44ceSEd Maste   return *this;
1849f2f44ceSEd Maste }
1859f2f44ceSEd Maste 
1869f2f44ceSEd Maste DumpValueObjectOptions &
SetRevealEmptyAggregates(bool reveal)187435933ddSDimitry Andric DumpValueObjectOptions::SetRevealEmptyAggregates(bool reveal) {
1889f2f44ceSEd Maste   m_reveal_empty_aggregates = reveal;
1899f2f44ceSEd Maste   return *this;
1909f2f44ceSEd Maste }
1919f2f44ceSEd Maste 
1924bb0738eSEd Maste DumpValueObjectOptions &
SetElementCount(uint32_t element_count)193435933ddSDimitry Andric DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
194435933ddSDimitry Andric   m_pointer_as_array = PointerAsArraySettings(element_count);
195435933ddSDimitry Andric   return *this;
196435933ddSDimitry Andric }
197435933ddSDimitry Andric 
SetPointerAsArray(const PointerAsArraySettings & ptr_array)198435933ddSDimitry Andric DumpValueObjectOptions &DumpValueObjectOptions::SetPointerAsArray(
199435933ddSDimitry Andric     const PointerAsArraySettings &ptr_array) {
200435933ddSDimitry Andric   m_pointer_as_array = ptr_array;
2014bb0738eSEd Maste   return *this;
2024bb0738eSEd Maste }
203