1 //===-- DumpValueObjectOptions.h --------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H 10 #define LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H 11 12 #include <string> 13 14 #include "lldb/lldb-private.h" 15 #include "lldb/lldb-public.h" 16 17 #include <functional> 18 #include <string> 19 20 namespace lldb_private { 21 22 class DumpValueObjectOptions { 23 public: 24 struct PointerDepth { 25 uint32_t m_count = 0; 26 27 PointerDepth Decremented() const { 28 if (m_count > 0) 29 return {m_count - 1}; 30 return *this; 31 } 32 33 bool CanAllowExpansion() const; 34 }; 35 36 struct PointerAsArraySettings { 37 size_t m_element_count = 0; 38 size_t m_base_element = 0; 39 size_t m_stride = 0; 40 41 PointerAsArraySettings() = default; 42 43 PointerAsArraySettings(size_t elem_count, size_t base_elem = 0, 44 size_t stride = 1) 45 : m_element_count(elem_count), m_base_element(base_elem), 46 m_stride(stride) {} 47 48 operator bool() { return m_element_count > 0; } 49 }; 50 51 typedef std::function<bool(ConstString, ConstString, 52 const DumpValueObjectOptions &, Stream &)> 53 DeclPrintingHelper; 54 55 typedef std::function<bool(ConstString)> ChildPrintingDecider; 56 57 static const DumpValueObjectOptions DefaultOptions() { 58 static DumpValueObjectOptions g_default_options; 59 60 return g_default_options; 61 } 62 63 DumpValueObjectOptions(); 64 65 DumpValueObjectOptions(ValueObject &valobj); 66 67 DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth); 68 69 DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default); 70 71 DumpValueObjectOptions &SetDeclPrintingHelper(DeclPrintingHelper helper); 72 73 DumpValueObjectOptions &SetChildPrintingDecider(ChildPrintingDecider decider); 74 75 DumpValueObjectOptions &SetShowTypes(bool show = false); 76 77 DumpValueObjectOptions &SetShowLocation(bool show = false); 78 79 DumpValueObjectOptions &SetUseObjectiveC(bool use = false); 80 81 DumpValueObjectOptions &SetShowSummary(bool show = true); 82 83 DumpValueObjectOptions & 84 SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues); 85 86 DumpValueObjectOptions &SetUseSyntheticValue(bool use_synthetic = true); 87 88 DumpValueObjectOptions &SetScopeChecked(bool check = true); 89 90 DumpValueObjectOptions &SetFlatOutput(bool flat = false); 91 92 DumpValueObjectOptions &SetOmitSummaryDepth(uint32_t depth = 0); 93 94 DumpValueObjectOptions &SetIgnoreCap(bool ignore = false); 95 96 DumpValueObjectOptions &SetRawDisplay(); 97 98 DumpValueObjectOptions &SetFormat(lldb::Format format = lldb::eFormatDefault); 99 100 DumpValueObjectOptions & 101 SetSummary(lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()); 102 103 DumpValueObjectOptions &SetRootValueObjectName(const char *name = nullptr); 104 105 DumpValueObjectOptions &SetHideRootType(bool hide_root_type = false); 106 107 DumpValueObjectOptions &SetHideRootName(bool hide_root_name); 108 109 DumpValueObjectOptions &SetHideName(bool hide_name = false); 110 111 DumpValueObjectOptions &SetHideValue(bool hide_value = false); 112 113 DumpValueObjectOptions &SetHidePointerValue(bool hide = false); 114 115 DumpValueObjectOptions &SetVariableFormatDisplayLanguage( 116 lldb::LanguageType lang = lldb::eLanguageTypeUnknown); 117 118 DumpValueObjectOptions &SetRunValidator(bool run = true); 119 120 DumpValueObjectOptions &SetUseTypeDisplayName(bool dis = false); 121 122 DumpValueObjectOptions &SetAllowOnelinerMode(bool oneliner = false); 123 124 DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true); 125 126 DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0); 127 128 DumpValueObjectOptions & 129 SetPointerAsArray(const PointerAsArraySettings &ptr_array); 130 131 uint32_t m_max_depth = UINT32_MAX; 132 bool m_max_depth_is_default = true; 133 lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; 134 uint32_t m_omit_summary_depth = 0; 135 lldb::Format m_format = lldb::eFormatDefault; 136 lldb::TypeSummaryImplSP m_summary_sp; 137 std::string m_root_valobj_name; 138 lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown; 139 PointerDepth m_max_ptr_depth; 140 DeclPrintingHelper m_decl_printing_helper; 141 ChildPrintingDecider m_child_printing_decider; 142 PointerAsArraySettings m_pointer_as_array; 143 bool m_use_synthetic : 1; 144 bool m_scope_already_checked : 1; 145 bool m_flat_output : 1; 146 bool m_ignore_cap : 1; 147 bool m_show_types : 1; 148 bool m_show_location : 1; 149 bool m_use_objc : 1; 150 bool m_hide_root_type : 1; 151 bool m_hide_root_name : 1; 152 bool m_hide_name : 1; 153 bool m_hide_value : 1; 154 bool m_run_validator : 1; 155 bool m_use_type_display_name : 1; 156 bool m_allow_oneliner_mode : 1; 157 bool m_hide_pointer_value : 1; 158 bool m_reveal_empty_aggregates : 1; 159 }; 160 161 } // namespace lldb_private 162 163 #endif // LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H 164