Enrico Granata | 0a97614 | 2011-08-22 22:03:47 +0000 | [diff] [blame] | 1 | //===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Core/DataVisualization.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | |
| 17 | #include "lldb/Core/Debugger.h" |
| 18 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
| 21 | |
| 22 | static FormatManager& |
| 23 | GetFormatManager() |
| 24 | { |
| 25 | static FormatManager g_format_manager; |
| 26 | return g_format_manager; |
| 27 | } |
| 28 | |
| 29 | void |
| 30 | DataVisualization::ForceUpdate() |
| 31 | { |
| 32 | GetFormatManager().Changed(); |
| 33 | } |
| 34 | |
| 35 | uint32_t |
| 36 | DataVisualization::GetCurrentRevision () |
| 37 | { |
| 38 | return GetFormatManager().GetCurrentRevision(); |
| 39 | } |
| 40 | |
| 41 | bool |
| 42 | DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) |
| 43 | { |
| 44 | return GetFormatManager().GetValueNavigator().Get(valobj,entry, use_dynamic); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) |
| 49 | { |
| 50 | GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry); |
| 51 | } |
| 52 | |
| 53 | bool |
| 54 | DataVisualization::ValueFormats::Delete(const ConstString &type) |
| 55 | { |
| 56 | return GetFormatManager().GetValueNavigator().Delete(type); |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | DataVisualization::ValueFormats::Clear() |
| 61 | { |
| 62 | GetFormatManager().GetValueNavigator().Clear(); |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | DataVisualization::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) |
| 67 | { |
| 68 | GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton); |
| 69 | } |
| 70 | |
| 71 | uint32_t |
| 72 | DataVisualization::ValueFormats::GetCount() |
| 73 | { |
| 74 | return GetFormatManager().GetValueNavigator().GetCount(); |
| 75 | } |
| 76 | |
| 77 | bool |
| 78 | DataVisualization::GetSummaryFormat(ValueObject& valobj, |
| 79 | lldb::DynamicValueType use_dynamic, |
| 80 | lldb::SummaryFormatSP& entry) |
| 81 | { |
| 82 | return GetFormatManager().Get(valobj, entry, use_dynamic); |
| 83 | } |
| 84 | bool |
| 85 | DataVisualization::GetSyntheticChildren(ValueObject& valobj, |
| 86 | lldb::DynamicValueType use_dynamic, |
| 87 | lldb::SyntheticChildrenSP& entry) |
| 88 | { |
| 89 | return GetFormatManager().Get(valobj, entry, use_dynamic); |
| 90 | } |
| 91 | |
| 92 | bool |
| 93 | DataVisualization::AnyMatches(ConstString type_name, |
| 94 | FormatCategory::FormatCategoryItems items, |
| 95 | bool only_enabled, |
| 96 | const char** matching_category, |
| 97 | FormatCategory::FormatCategoryItems* matching_type) |
| 98 | { |
| 99 | return GetFormatManager().AnyMatches(type_name, |
| 100 | items, |
| 101 | only_enabled, |
| 102 | matching_category, |
| 103 | matching_type); |
| 104 | } |
| 105 | |
| 106 | bool |
| 107 | DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) |
| 108 | { |
| 109 | entry = GetFormatManager().Category(category); |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | void |
| 114 | DataVisualization::Categories::Add(const ConstString &category) |
| 115 | { |
| 116 | GetFormatManager().Category(category); |
| 117 | } |
| 118 | |
| 119 | bool |
| 120 | DataVisualization::Categories::Delete(const ConstString &category) |
| 121 | { |
| 122 | GetFormatManager().DisableCategory(category); |
| 123 | return GetFormatManager().GetCategories().Delete(category); |
| 124 | } |
| 125 | |
| 126 | void |
| 127 | DataVisualization::Categories::Clear() |
| 128 | { |
| 129 | GetFormatManager().GetCategories().Clear(); |
| 130 | } |
| 131 | |
| 132 | void |
| 133 | DataVisualization::Categories::Clear(ConstString &category) |
| 134 | { |
| 135 | GetFormatManager().Category(category)->ClearSummaries(); |
| 136 | } |
| 137 | |
| 138 | void |
| 139 | DataVisualization::Categories::Enable(ConstString& category) |
| 140 | { |
| 141 | if (GetFormatManager().Category(category)->IsEnabled() == false) |
| 142 | GetFormatManager().EnableCategory(category); |
| 143 | else |
| 144 | { |
| 145 | GetFormatManager().DisableCategory(category); |
| 146 | GetFormatManager().EnableCategory(category); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | DataVisualization::Categories::Disable(ConstString& category) |
| 152 | { |
| 153 | if (GetFormatManager().Category(category)->IsEnabled() == true) |
| 154 | GetFormatManager().DisableCategory(category); |
| 155 | } |
| 156 | |
| 157 | void |
| 158 | DataVisualization::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) |
| 159 | { |
| 160 | GetFormatManager().LoopThroughCategories(callback, callback_baton); |
| 161 | } |
| 162 | |
| 163 | uint32_t |
| 164 | DataVisualization::Categories::GetCount() |
| 165 | { |
| 166 | return GetFormatManager().GetCategories().GetCount(); |
| 167 | } |
| 168 | |
| 169 | bool |
| 170 | DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry) |
| 171 | { |
| 172 | return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry); |
| 173 | } |
| 174 | |
| 175 | void |
| 176 | DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) |
| 177 | { |
| 178 | GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry); |
| 179 | } |
| 180 | |
| 181 | bool |
| 182 | DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) |
| 183 | { |
| 184 | return GetFormatManager().GetNamedSummaryNavigator().Delete(type); |
| 185 | } |
| 186 | |
| 187 | void |
| 188 | DataVisualization::NamedSummaryFormats::Clear() |
| 189 | { |
| 190 | GetFormatManager().GetNamedSummaryNavigator().Clear(); |
| 191 | } |
| 192 | |
| 193 | void |
| 194 | DataVisualization::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) |
| 195 | { |
| 196 | GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton); |
| 197 | } |
| 198 | |
| 199 | uint32_t |
| 200 | DataVisualization::NamedSummaryFormats::GetCount() |
| 201 | { |
| 202 | return GetFormatManager().GetNamedSummaryNavigator().GetCount(); |
| 203 | } |