diff options
-rw-r--r-- | lldb/include/lldb/Core/DataVisualization.h | 15 | ||||
-rw-r--r-- | lldb/include/lldb/Core/FormatManager.h | 30 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 56 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectType.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Core/DataVisualization.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 54 |
7 files changed, 120 insertions, 90 deletions
diff --git a/lldb/include/lldb/Core/DataVisualization.h b/lldb/include/lldb/Core/DataVisualization.h index 78d7b7dfd5b..9965eb5be34 100644 --- a/lldb/include/lldb/Core/DataVisualization.h +++ b/lldb/include/lldb/Core/DataVisualization.h @@ -48,8 +48,8 @@ public: class ValueFormats { public: - static bool - Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry); + static lldb::ValueFormatSP + Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic); static void Add (const ConstString &type, const lldb::ValueFormatSP &entry); @@ -67,14 +67,13 @@ public: GetCount (); }; - static bool + static lldb::SummaryFormatSP GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry); - static bool + lldb::DynamicValueType use_dynamic); + + static lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry); + lldb::DynamicValueType use_dynamic); static bool AnyMatches(ConstString type_name, diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h index afe587a15b2..05d525d1a08 100644 --- a/lldb/include/lldb/Core/FormatManager.h +++ b/lldb/include/lldb/Core/FormatManager.h @@ -299,15 +299,13 @@ public: return m_map.size(); } - bool - Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, + lldb::SummaryFormatSP + GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); - bool - Get (ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic); + lldb::SyntheticChildrenSP + GetSyntheticChildren (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); private: @@ -422,20 +420,18 @@ public: GetCategory (const ConstString& category_name, bool can_create = true); - bool - Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic) + lldb::SummaryFormatSP + GetSummaryFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic) { - return m_categories_map.Get(valobj, entry, use_dynamic); + return m_categories_map.GetSummaryFormat(valobj, use_dynamic); } - bool - Get (ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic) + lldb::SyntheticChildrenSP + GetSyntheticChildren (ValueObject& valobj, + lldb::DynamicValueType use_dynamic) { - return m_categories_map.Get(valobj, entry, use_dynamic); + return m_categories_map.GetSyntheticChildren(valobj, use_dynamic); } bool diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index afdb0e7f19e..1c003efa0da 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -920,6 +920,7 @@ public: m_forced_summary_format = format; m_user_id_of_forced_summary = m_update_point.GetModID(); m_summary_str.clear(); + m_trying_summary_already = false; } lldb::SummaryFormatSP @@ -949,6 +950,42 @@ public: return m_forced_summary_format; return m_last_summary_format; } + + void + SetSummaryFormat(lldb::SummaryFormatSP format) + { + m_last_summary_format = format; + m_summary_str.clear(); + m_trying_summary_already = false; + } + + void + SetValueFormat(lldb::ValueFormatSP format) + { + m_last_value_format = format; + m_value_str.clear(); + } + + lldb::ValueFormatSP + GetValueFormat() + { + UpdateFormatsIfNeeded(m_last_format_mgr_dynamic); + return m_last_value_format; + } + + void + SetSyntheticChildren(lldb::SyntheticChildrenSP synth) + { + m_last_synthetic_filter = synth; + m_synthetic_value = NULL; + } + + lldb::SyntheticChildrenSP + GetSyntheticChildren() + { + UpdateFormatsIfNeeded(m_last_format_mgr_dynamic); + return m_last_synthetic_filter; + } // Use GetParent for display purposes, but if you want to tell the parent to update itself // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for @@ -1012,13 +1049,15 @@ protected: // as a shared pointer to any of them has been handed out. Shared pointers to // value objects must always be made with the GetSP method. - std::vector<ValueObject *> m_children; + std::vector<ValueObject *> m_children; std::map<ConstString, ValueObject *> m_synthetic_children; - ValueObject *m_dynamic_value; - ValueObject *m_synthetic_value; + + ValueObject* m_dynamic_value; + ValueObject* m_synthetic_value; + ValueObject* m_deref_valobj; + lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created // as an independent ValueObjectConstResult, which isn't managed by us. - ValueObject *m_deref_valobj; lldb::Format m_format; uint32_t m_last_format_mgr_revision; @@ -1028,6 +1067,7 @@ protected: lldb::ValueFormatSP m_last_value_format; lldb::SyntheticChildrenSP m_last_synthetic_filter; ProcessModID m_user_id_of_forced_summary; + AddressType m_address_type_of_ptr_or_ref_children; bool m_value_is_valid:1, m_value_did_change:1, @@ -1037,12 +1077,8 @@ protected: m_is_array_item_for_pointer:1, m_is_bitfield_for_scalar:1, m_is_expression_path_child:1, - m_is_child_at_offset:1; - - // used to prevent endless looping into GetPrintableRepresentation() - uint32_t m_dump_printable_counter; - - AddressType m_address_type_of_ptr_or_ref_children; + m_is_child_at_offset:1, + m_trying_summary_already:1; // used to prevent endless recursion in printing summaries friend class ClangExpressionDeclMap; // For GetValue friend class ClangExpressionVariable; // For SetName diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 2e82df060c6..cfdfc98f900 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -873,6 +873,14 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn const char* format_cstr = (m_options.m_one_liner ? "" : m_options.m_format_string.c_str()); + // ${var%S} is an endless recursion, prevent it + if (strcmp(format_cstr, "${var%S}") == 0) + { + result.AppendError("recursive summary not allowed"); + result.SetStatus(eReturnStatusFailed); + return false; + } + Error error; lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_cascade, diff --git a/lldb/source/Core/DataVisualization.cpp b/lldb/source/Core/DataVisualization.cpp index 7c326ed6ec0..3b310ebf0df 100644 --- a/lldb/source/Core/DataVisualization.cpp +++ b/lldb/source/Core/DataVisualization.cpp @@ -38,10 +38,12 @@ DataVisualization::GetCurrentRevision () return GetFormatManager().GetCurrentRevision(); } -bool -DataVisualization::ValueFormats::Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) +lldb::ValueFormatSP +DataVisualization::ValueFormats::Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { - return GetFormatManager().GetValueNavigator().Get(valobj,entry, use_dynamic); + lldb::ValueFormatSP entry; + GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic); + return entry; } void @@ -74,19 +76,18 @@ DataVisualization::ValueFormats::GetCount () return GetFormatManager().GetValueNavigator().GetCount(); } -bool +lldb::SummaryFormatSP DataVisualization::GetSummaryFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry) + lldb::DynamicValueType use_dynamic) { - return GetFormatManager().Get(valobj, entry, use_dynamic); + return GetFormatManager().GetSummaryFormat(valobj, use_dynamic); } -bool + +lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildren (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry) + lldb::DynamicValueType use_dynamic) { - return GetFormatManager().Get(valobj, entry, use_dynamic); + return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic); } bool diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index f9bb3e1a6e9..1321998ff22 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -402,10 +402,9 @@ CategoryMap::AnyMatches (ConstString type_name, return false; } -bool -CategoryMap::Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic) +lldb::SummaryFormatSP +CategoryMap::GetSummaryFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic) { Mutex::Locker(m_map_mutex); @@ -418,16 +417,14 @@ CategoryMap::Get (ValueObject& valobj, lldb::SummaryFormatSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; - entry = current_format; - return true; + return current_format; } - return false; + return lldb::SummaryFormatSP(); } -bool -CategoryMap::Get (ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic) +lldb::SyntheticChildrenSP +CategoryMap::GetSyntheticChildren (ValueObject& valobj, + lldb::DynamicValueType use_dynamic) { Mutex::Locker(m_map_mutex); @@ -441,10 +438,9 @@ CategoryMap::Get (ValueObject& valobj, lldb::SyntheticChildrenSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; - entry = current_format; - return true; + return current_format; } - return false; + return lldb::SyntheticChildrenSP(); } void diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 78e18ac9f3d..eba5edc95bb 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -94,8 +94,8 @@ ValueObject::ValueObject (ValueObject &parent) : m_is_bitfield_for_scalar(false), m_is_expression_path_child(false), m_is_child_at_offset(false), - m_dump_printable_counter(0), - m_address_type_of_ptr_or_ref_children(eAddressTypeInvalid) + m_address_type_of_ptr_or_ref_children(eAddressTypeInvalid), + m_trying_summary_already(false) { m_manager->ManageObject(this); } @@ -140,8 +140,8 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope, m_is_bitfield_for_scalar(false), m_is_expression_path_child(false), m_is_child_at_offset(false), - m_dump_printable_counter(0), - m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type) + m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type), + m_trying_summary_already(false) { m_manager = new ValueObjectManager(); m_manager->ManageObject (this); @@ -241,30 +241,21 @@ ValueObject::UpdateFormatsIfNeeded(DynamicValueType use_dynamic) if (HasCustomSummaryFormat() && m_update_point.GetModID() != m_user_id_of_forced_summary) { ClearCustomSummaryFormat(); - m_summary_str.clear(); + any_change = true; } + if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) || m_last_format_mgr_dynamic != use_dynamic) { - if (m_last_summary_format.get()) - m_last_summary_format.reset((StringSummaryFormat*)NULL); - if (m_last_value_format.get()) - m_last_value_format.reset(/*(ValueFormat*)NULL*/); - if (m_last_synthetic_filter.get()) - m_last_synthetic_filter.reset(/*(SyntheticFilter*)NULL*/); - - m_synthetic_value = NULL; - - any_change = true; - DataVisualization::ValueFormats::Get(*this, eNoDynamicValues, m_last_value_format); - DataVisualization::GetSummaryFormat(*this, use_dynamic, m_last_summary_format); - DataVisualization::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter); + SetValueFormat(DataVisualization::ValueFormats::Get(*this, eNoDynamicValues)); + SetSummaryFormat(DataVisualization::GetSummaryFormat(*this, use_dynamic)); + SetSyntheticChildren(DataVisualization::GetSyntheticChildren(*this, use_dynamic)); m_last_format_mgr_revision = DataVisualization::GetCurrentRevision(); m_last_format_mgr_dynamic = use_dynamic; - - ClearUserVisibleData(); + + any_change = true; } return any_change; @@ -1122,8 +1113,6 @@ ValueObject::GetPrintableRepresentation(Stream& s, Format custom_format) { - RefCounter ref(&m_dump_printable_counter); - if (custom_format != eFormatInvalid) SetFormat(custom_format); @@ -1136,8 +1125,15 @@ ValueObject::GetPrintableRepresentation(Stream& s, return_value = GetValueAsCString(); break; case eDisplaySummary: - return_value = GetSummaryAsCString(); - break; + if (m_trying_summary_already) + return_value = NULL; + else + { + m_trying_summary_already = true; + return_value = GetSummaryAsCString(); + m_trying_summary_already = false; + break; + } case eDisplayLanguageSpecific: return_value = GetObjectDescription(); break; @@ -1159,20 +1155,17 @@ ValueObject::GetPrintableRepresentation(Stream& s, break; } - // this code snippet might lead to endless recursion, thus we use a RefCounter here to - // check that we are not looping endlessly - if (!return_value && (m_dump_printable_counter < 3)) + if (!return_value) { - // try to pick the other choice if (val_obj_display == eDisplayValue) - return_value = GetSummaryAsCString(); + return_value = GetSummaryAsCString(); else if (val_obj_display == eDisplaySummary) { if (ClangASTContext::IsAggregateType (GetClangType()) == true) { // this thing has no value, and it seems to have no summary // some combination of unitialized data and other factors can also - // raise this condition, so let's print a nice generic error message + // raise this condition, so let's print a nice generic description { alloc_mem.resize(684); return_value = &alloc_mem[0]; @@ -3704,6 +3697,7 @@ ValueObject::ClearUserVisibleData() m_value_str.clear(); m_summary_str.clear(); m_object_desc_str.clear(); + m_trying_summary_already = false; } SymbolContextScope * |