diff options
Diffstat (limited to 'source/DataFormatters')
-rw-r--r-- | source/DataFormatters/DumpValueObjectOptions.cpp | 8 | ||||
-rw-r--r-- | source/DataFormatters/FormatCache.cpp | 30 | ||||
-rw-r--r-- | source/DataFormatters/FormatManager.cpp | 36 | ||||
-rw-r--r-- | source/DataFormatters/FormattersHelpers.cpp | 172 | ||||
-rw-r--r-- | source/DataFormatters/Makefile | 14 | ||||
-rw-r--r-- | source/DataFormatters/StringPrinter.cpp | 2 | ||||
-rw-r--r-- | source/DataFormatters/TypeCategory.cpp | 27 | ||||
-rw-r--r-- | source/DataFormatters/TypeCategoryMap.cpp | 65 | ||||
-rw-r--r-- | source/DataFormatters/TypeFormat.cpp | 4 | ||||
-rw-r--r-- | source/DataFormatters/TypeSummary.cpp | 21 | ||||
-rw-r--r-- | source/DataFormatters/TypeSynthetic.cpp | 9 | ||||
-rw-r--r-- | source/DataFormatters/ValueObjectPrinter.cpp | 50 |
12 files changed, 154 insertions, 284 deletions
diff --git a/source/DataFormatters/DumpValueObjectOptions.cpp b/source/DataFormatters/DumpValueObjectOptions.cpp index f3de1257bb80..e1f5320feee6 100644 --- a/source/DataFormatters/DumpValueObjectOptions.cpp +++ b/source/DataFormatters/DumpValueObjectOptions.cpp @@ -242,4 +242,10 @@ DumpValueObjectOptions::SetRevealEmptyAggregates (bool reveal) m_reveal_empty_aggregates = reveal; return *this; } - + +DumpValueObjectOptions& +DumpValueObjectOptions::SetElementCount (uint32_t element_count) +{ + m_element_count = element_count; + return *this; +} diff --git a/source/DataFormatters/FormatCache.cpp b/source/DataFormatters/FormatCache.cpp index 748c6d80fbd2..fc5becbf200d 100644 --- a/source/DataFormatters/FormatCache.cpp +++ b/source/DataFormatters/FormatCache.cpp @@ -158,11 +158,13 @@ FormatCache::Entry::SetValidator (lldb::TypeValidatorImplSP validator_sp) m_validator_sp = validator_sp; } -FormatCache::FormatCache () : -m_map(), -m_mutex (Mutex::eMutexTypeRecursive) +FormatCache::FormatCache() + : m_map(), + m_mutex() #ifdef LLDB_CONFIGURATION_DEBUG -,m_cache_hits(0),m_cache_misses(0) + , + m_cache_hits(0), + m_cache_misses(0) #endif { } @@ -181,9 +183,9 @@ FormatCache::GetEntry (const ConstString& type) bool FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); auto entry = GetEntry(type); - if (entry.IsSummaryCached()) + if (entry.IsFormatCached()) { #ifdef LLDB_CONFIGURATION_DEBUG m_cache_hits++; @@ -201,7 +203,7 @@ FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_s bool FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); auto entry = GetEntry(type); if (entry.IsSummaryCached()) { @@ -221,7 +223,7 @@ FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summar bool FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); auto entry = GetEntry(type); if (entry.IsSyntheticCached()) { @@ -241,7 +243,7 @@ FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& sy bool FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); auto entry = GetEntry(type); if (entry.IsValidatorCached()) { @@ -261,35 +263,35 @@ FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& va void FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); GetEntry(type).SetFormat(format_sp); } void FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); GetEntry(type).SetSummary(summary_sp); } void FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); GetEntry(type).SetSynthetic(synthetic_sp); } void FormatCache::SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); GetEntry(type).SetValidator(validator_sp); } void FormatCache::Clear () { - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); m_map.clear(); } diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp index 35a0468306fa..f51243f841e3 100644 --- a/source/DataFormatters/FormatManager.cpp +++ b/source/DataFormatters/FormatManager.cpp @@ -128,7 +128,7 @@ FormatManager::Changed () { ++m_last_revision; m_format_cache.Clear (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -181,7 +181,7 @@ void FormatManager::EnableAllCategories () { m_categories_map.EnableAllCategories (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -193,7 +193,7 @@ void FormatManager::DisableAllCategories () { m_categories_map.DisableAllCategories (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -502,7 +502,7 @@ void FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) { m_categories_map.ForEach(callback); - Mutex::Locker locker(m_language_categories_mutex); + std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex); for (const auto& entry : m_language_categories_map) { if (auto category_sp = entry.second->GetCategory()) @@ -712,7 +712,7 @@ FormatManager::GetCandidateLanguages (lldb::LanguageType lang_type) LanguageCategory* FormatManager::GetCategoryForLanguage (lldb::LanguageType lang_type) { - Mutex::Locker locker(m_language_categories_mutex); + std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex); auto iter = m_language_categories_map.find(lang_type), end = m_language_categories_map.end(); if (iter != end) return iter->second.get(); @@ -1055,22 +1055,22 @@ FormatManager::GetHardcodedValidator (FormattersMatchData& match_data) return retval_sp; } -FormatManager::FormatManager() : - m_last_revision(0), - m_format_cache(), - m_language_categories_mutex(Mutex::eMutexTypeRecursive), - m_language_categories_map(), - m_named_summaries_map(this), - m_categories_map(this), - m_default_category_name(ConstString("default")), - m_system_category_name(ConstString("system")), - m_vectortypes_category_name(ConstString("VectorTypes")) +FormatManager::FormatManager() + : m_last_revision(0), + m_format_cache(), + m_language_categories_mutex(), + m_language_categories_map(), + m_named_summaries_map(this), + m_categories_map(this), + m_default_category_name(ConstString("default")), + m_system_category_name(ConstString("system")), + m_vectortypes_category_name(ConstString("VectorTypes")) { LoadSystemFormatters(); LoadVectorFormatters(); - - EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); - EnableCategory(m_system_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); + + EnableCategory(m_vectortypes_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); + EnableCategory(m_system_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); } void diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp index 4b0e82e975e4..c4ff75cffdd1 100644 --- a/source/DataFormatters/FormattersHelpers.cpp +++ b/source/DataFormatters/FormattersHelpers.cpp @@ -133,178 +133,6 @@ lldb_private::formatters::AddFilter (TypeCategoryImpl::SharedPointer category_s } #endif -StackFrame* -lldb_private::formatters::GetViableFrame (ExecutionContext exe_ctx) -{ - StackFrame* frame = exe_ctx.GetFramePtr(); - if (frame) - return frame; - - Process* process = exe_ctx.GetProcessPtr(); - if (!process) - return nullptr; - - ThreadSP thread_sp(process->GetThreadList().GetSelectedThread()); - if (thread_sp) - return thread_sp->GetSelectedFrame().get(); - return nullptr; -} - -bool -lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj, - const char* target_type, - const char* selector, - uint64_t &value) -{ - if (!target_type || !*target_type) - return false; - if (!selector || !*selector) - return false; - StreamString expr; - expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector); - ExecutionContext exe_ctx (valobj.GetExecutionContextRef()); - lldb::ValueObjectSP result_sp; - Target* target = exe_ctx.GetTargetPtr(); - StackFrame* stack_frame = GetViableFrame(exe_ctx); - if (!target || !stack_frame) - return false; - - EvaluateExpressionOptions options; - options.SetCoerceToId(false); - options.SetUnwindOnError(true); - options.SetKeepInMemory(true); - options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus); - options.SetResultIsInternal(true); - options.SetUseDynamic(lldb::eDynamicCanRunTarget); - - target->EvaluateExpression(expr.GetData(), - stack_frame, - result_sp, - options); - if (!result_sp) - return false; - value = result_sp->GetValueAsUnsigned(0); - return true; -} - -bool -lldb_private::formatters::ExtractSummaryFromObjCExpression (ValueObject &valobj, - const char* target_type, - const char* selector, - Stream &stream, - lldb::LanguageType lang_type) -{ - if (!target_type || !*target_type) - return false; - if (!selector || !*selector) - return false; - StreamString expr; - expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector); - ExecutionContext exe_ctx (valobj.GetExecutionContextRef()); - lldb::ValueObjectSP result_sp; - Target* target = exe_ctx.GetTargetPtr(); - StackFrame* stack_frame = GetViableFrame(exe_ctx); - if (!target || !stack_frame) - return false; - - EvaluateExpressionOptions options; - options.SetCoerceToId(false); - options.SetUnwindOnError(true); - options.SetKeepInMemory(true); - options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus); - options.SetResultIsInternal(true); - options.SetUseDynamic(lldb::eDynamicCanRunTarget); - - target->EvaluateExpression(expr.GetData(), - stack_frame, - result_sp, - options); - if (!result_sp) - return false; - stream.Printf("%s",result_sp->GetSummaryAsCString(lang_type)); - return true; -} - -lldb::ValueObjectSP -lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj, - const char* return_type, - const char* selector, - uint64_t index) -{ - lldb::ValueObjectSP valobj_sp; - if (!return_type || !*return_type) - return valobj_sp; - if (!selector || !*selector) - return valobj_sp; - StreamString expr; - const char *colon = ""; - llvm::StringRef selector_sr(selector); - if (selector_sr.back() != ':') - colon = ":"; - expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%" PRId64 "]",return_type,valobj.GetPointerValue(),selector,colon,index); - ExecutionContext exe_ctx (valobj.GetExecutionContextRef()); - lldb::ValueObjectSP result_sp; - Target* target = exe_ctx.GetTargetPtr(); - StackFrame* stack_frame = GetViableFrame(exe_ctx); - if (!target || !stack_frame) - return valobj_sp; - - EvaluateExpressionOptions options; - options.SetCoerceToId(false); - options.SetUnwindOnError(true); - options.SetKeepInMemory(true); - options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus); - options.SetResultIsInternal(true); - options.SetUseDynamic(lldb::eDynamicCanRunTarget); - - target->EvaluateExpression(expr.GetData(), - stack_frame, - valobj_sp, - options); - return valobj_sp; -} - -lldb::ValueObjectSP -lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj, - const char* return_type, - const char* selector, - const char* key) -{ - lldb::ValueObjectSP valobj_sp; - if (!return_type || !*return_type) - return valobj_sp; - if (!selector || !*selector) - return valobj_sp; - if (!key || !*key) - return valobj_sp; - StreamString expr; - const char *colon = ""; - llvm::StringRef selector_sr(selector); - if (selector_sr.back() != ':') - colon = ":"; - expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%s]",return_type,valobj.GetPointerValue(),selector,colon,key); - ExecutionContext exe_ctx (valobj.GetExecutionContextRef()); - lldb::ValueObjectSP result_sp; - Target* target = exe_ctx.GetTargetPtr(); - StackFrame* stack_frame = GetViableFrame(exe_ctx); - if (!target || !stack_frame) - return valobj_sp; - - EvaluateExpressionOptions options; - options.SetCoerceToId(false); - options.SetUnwindOnError(true); - options.SetKeepInMemory(true); - options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus); - options.SetResultIsInternal(true); - options.SetUseDynamic(lldb::eDynamicCanRunTarget); - - target->EvaluateExpression(expr.GetData(), - stack_frame, - valobj_sp, - options); - return valobj_sp; -} - size_t lldb_private::formatters::ExtractIndexFromString (const char* item_name) { diff --git a/source/DataFormatters/Makefile b/source/DataFormatters/Makefile deleted file mode 100644 index 4eb3249e5a58..000000000000 --- a/source/DataFormatters/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -##===- source/DataFormatters/Makefile -------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LLDB_LEVEL := ../.. -LIBRARYNAME := lldbDataFormatters -BUILD_ARCHIVE = 1 - -include $(LLDB_LEVEL)/Makefile diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp index b114add50640..8cdbb53eaa85 100644 --- a/source/DataFormatters/StringPrinter.cpp +++ b/source/DataFormatters/StringPrinter.cpp @@ -207,7 +207,7 @@ GetPrintableImpl<StringPrinter::StringElementType::UTF8> (uint8_t* buffer, uint8 else { uint8_t* data = new uint8_t[11]; - sprintf((char*)data,"\\U%08x",codepoint); + sprintf((char *)data, "\\U%08x", (unsigned)codepoint); retval = { data,10,[] (const uint8_t* c) {delete[] c;} }; break; } diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp index 636d935b7625..9df3ec6721ff 100644 --- a/source/DataFormatters/TypeCategory.cpp +++ b/source/DataFormatters/TypeCategory.cpp @@ -18,21 +18,20 @@ using namespace lldb; using namespace lldb_private; -TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist, - ConstString name, - std::initializer_list<lldb::LanguageType> langs) : -m_format_cont("format","regex-format",clist), -m_summary_cont("summary","regex-summary",clist), -m_filter_cont("filter","regex-filter",clist), +TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist, ConstString name, + std::initializer_list<lldb::LanguageType> langs) + : m_format_cont("format", "regex-format", clist), + m_summary_cont("summary", "regex-summary", clist), + m_filter_cont("filter", "regex-filter", clist), #ifndef LLDB_DISABLE_PYTHON -m_synth_cont("synth","regex-synth",clist), + m_synth_cont("synth", "regex-synth", clist), #endif -m_validator_cont("validator","regex-validator",clist), -m_enabled(false), -m_change_listener(clist), -m_mutex(Mutex::eMutexTypeRecursive), -m_name(name), -m_languages() + m_validator_cont("validator", "regex-validator", clist), + m_enabled(false), + m_change_listener(clist), + m_mutex(), + m_name(name), + m_languages() { for (const lldb::LanguageType lang : langs) AddLanguage(lang); @@ -673,7 +672,7 @@ TypeCategoryImpl::GetTypeNameSpecifierForValidatorAtIndex (size_t index) void TypeCategoryImpl::Enable (bool value, uint32_t position) { - Mutex::Locker locker(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); if ( (m_enabled = value) ) m_enabled_position = position; if (m_change_listener) diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp index 58e4e2117bb6..984c7f213ded 100644 --- a/source/DataFormatters/TypeCategoryMap.cpp +++ b/source/DataFormatters/TypeCategoryMap.cpp @@ -20,22 +20,19 @@ using namespace lldb; using namespace lldb_private; -TypeCategoryMap::TypeCategoryMap (IFormatChangeListener* lst) : -m_map_mutex(Mutex::eMutexTypeRecursive), -listener(lst), -m_map(), -m_active_categories() +TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst) + : m_map_mutex(), listener(lst), m_map(), m_active_categories() { ConstString default_cs("default"); lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs)); - Add(default_cs,default_sp); - Enable(default_cs,First); + Add(default_cs, default_sp); + Enable(default_cs, First); } void TypeCategoryMap::Add (KeyType name, const ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); m_map[name] = entry; if (listener) listener->Changed(); @@ -44,7 +41,7 @@ TypeCategoryMap::Add (KeyType name, const ValueSP& entry) bool TypeCategoryMap::Delete (KeyType name) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; @@ -58,7 +55,7 @@ TypeCategoryMap::Delete (KeyType name) bool TypeCategoryMap::Enable (KeyType category_name, Position pos) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); ValueSP category; if (!Get(category_name,category)) return false; @@ -68,7 +65,7 @@ TypeCategoryMap::Enable (KeyType category_name, Position pos) bool TypeCategoryMap::Disable (KeyType category_name) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); ValueSP category; if (!Get(category_name,category)) return false; @@ -78,7 +75,7 @@ TypeCategoryMap::Disable (KeyType category_name) bool TypeCategoryMap::Enable (ValueSP category, Position pos) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); if (category.get()) { Position pos_w = pos; @@ -107,7 +104,7 @@ TypeCategoryMap::Enable (ValueSP category, Position pos) bool TypeCategoryMap::Disable (ValueSP category) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); if (category.get()) { m_active_categories.remove_if(delete_matching_categories(category)); @@ -120,7 +117,7 @@ TypeCategoryMap::Disable (ValueSP category) void TypeCategoryMap::EnableAllCategories () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP()); MapType::iterator iter = m_map.begin(), end = m_map.end(); for (; iter != end; ++iter) @@ -148,7 +145,7 @@ TypeCategoryMap::EnableAllCategories () void TypeCategoryMap::DisableAllCategories () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); Position p = First; for (; false == m_active_categories.empty(); p++) { @@ -160,7 +157,7 @@ TypeCategoryMap::DisableAllCategories () void TypeCategoryMap::Clear () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); m_map.clear(); m_active_categories.clear(); if (listener) @@ -170,7 +167,7 @@ TypeCategoryMap::Clear () bool TypeCategoryMap::Get (KeyType name, ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; @@ -181,7 +178,7 @@ TypeCategoryMap::Get (KeyType name, ValueSP& entry) bool TypeCategoryMap::Get (uint32_t pos, ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); MapIterator iter = m_map.begin(); MapIterator end = m_map.end(); while (pos > 0) @@ -202,8 +199,8 @@ TypeCategoryMap::AnyMatches (ConstString type_name, const char** matching_category, TypeCategoryImpl::FormatCategoryItems* matching_type) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + MapIterator pos, end = m_map.end(); for (pos = m_map.begin(); pos != end; pos++) { @@ -220,8 +217,8 @@ TypeCategoryMap::AnyMatches (ConstString type_name, lldb::TypeFormatImplSP TypeCategoryMap::GetFormat (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -231,7 +228,7 @@ TypeCategoryMap::GetFormat (FormattersMatchData& match_data) { for (auto match : match_data.GetMatchesVector()) { - log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32, + log->Printf("[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers", match.DidStripReference() ? "strip-reference" : "no-strip-reference", @@ -258,8 +255,8 @@ TypeCategoryMap::GetFormat (FormattersMatchData& match_data) lldb::TypeSummaryImplSP TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -297,8 +294,8 @@ TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data) lldb::SyntheticChildrenSP TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -309,7 +306,7 @@ TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) { for (auto match : match_data.GetMatchesVector()) { - log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32, + log->Printf("[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers", match.DidStripReference() ? "strip-reference" : "no-strip-reference", @@ -337,8 +334,8 @@ TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) lldb::TypeValidatorImplSP TypeCategoryMap::GetValidator (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -377,8 +374,8 @@ TypeCategoryMap::ForEach(ForEachCallback callback) { if (callback) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + // loop through enabled categories in respective order { ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -408,8 +405,8 @@ TypeCategoryMap::ForEach(ForEachCallback callback) TypeCategoryImplSP TypeCategoryMap::GetAtIndex (uint32_t index) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_map_mutex); + if (index < m_map.size()) { MapIterator pos, end = m_map.end(); diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp index 6ab8d298f94b..a810883b05e0 100644 --- a/source/DataFormatters/TypeFormat.cpp +++ b/source/DataFormatters/TypeFormat.cpp @@ -23,6 +23,7 @@ #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Target/Target.h" @@ -199,7 +200,8 @@ TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj, const ModuleList& images(target_sp->GetImages()); SymbolContext sc; TypeList types; - images.FindTypes(sc, m_enum_type, false, UINT32_MAX, types); + llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; + images.FindTypes(sc, m_enum_type, false, UINT32_MAX, searched_symbol_files, types); if (types.GetSize() == 0) return false; for (lldb::TypeSP type_sp : types.Types()) diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp index 2806ba20c6a9..dd4cd97f001b 100644 --- a/source/DataFormatters/TypeSummary.cpp +++ b/source/DataFormatters/TypeSummary.cpp @@ -256,14 +256,27 @@ std::string ScriptSummaryFormat::GetDescription () { StreamString sstr; - sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)", + sstr.Printf ("%s%s%s%s%s%s%s\n ", Cascades() ? "" : " (not cascading)", !DoesPrintChildren(nullptr) ? "" : " (show children)", !DoesPrintValue(nullptr) ? " (hide value)" : "", IsOneLiner() ? " (one-line printout)" : "", SkipsPointers() ? " (skip pointers)" : "", SkipsReferences() ? " (skip references)" : "", - HideNames(nullptr) ? " (hide member names)" : "", - m_python_script.c_str()); + HideNames(nullptr) ? " (hide member names)" : ""); + if (m_python_script.empty()) + { + if (m_function_name.empty()) + { + sstr.PutCString("no backing script"); + } + else + { + sstr.PutCString(m_function_name.c_str()); + } + } + else + { + sstr.PutCString(m_python_script.c_str()); + } return sstr.GetString(); - } diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp index e49cd99b02ea..c8de1759c91d 100644 --- a/source/DataFormatters/TypeSynthetic.cpp +++ b/source/DataFormatters/TypeSynthetic.cpp @@ -246,6 +246,15 @@ ScriptedSyntheticChildren::FrontEnd::GetSyntheticValue () return m_interpreter->GetSyntheticValue(m_wrapper_sp); } +ConstString +ScriptedSyntheticChildren::FrontEnd::GetSyntheticTypeName () +{ + if (!m_wrapper_sp || m_interpreter == NULL) + return ConstString(); + + return m_interpreter->GetSyntheticTypeName(m_wrapper_sp); +} + std::string ScriptedSyntheticChildren::GetDescription() { diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp index 04c291283546..167afca7fbb1 100644 --- a/source/DataFormatters/ValueObjectPrinter.cpp +++ b/source/DataFormatters/ValueObjectPrinter.cpp @@ -416,11 +416,12 @@ ValueObjectPrinter::GetValueSummaryError (std::string& value, std::string& summary, std::string& error) { - if (m_options.m_format != eFormatDefault && m_options.m_format != m_valobj->GetFormat()) - { - m_valobj->GetValueAsCString(m_options.m_format, - value); - } + lldb::Format format = m_options.m_format; + // if I am printing synthetized elements, apply the format to those elements only + if (m_options.m_element_count > 0) + m_valobj->GetValueAsCString(lldb::eFormatDefault, value); + else if (format != eFormatDefault && format != m_valobj->GetFormat()) + m_valobj->GetValueAsCString(format, value); else { const char* val_cstr = m_valobj->GetValueAsCString(); @@ -514,7 +515,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded (bool value_printed, if (ShouldPrintValueObject()) { // let's avoid the overly verbose no description error for a nil thing - if (m_options.m_use_objc && !IsNil() && !IsUninitialized()) + if (m_options.m_use_objc && !IsNil() && !IsUninitialized() && (m_options.m_element_count == 0)) { if (!m_options.m_hide_value || !m_options.m_hide_name) m_stream->Printf(" "); @@ -587,6 +588,11 @@ ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description, if (is_uninit) return false; + // if the user has specified an element count, always print children + // as it is explicit user demand being honored + if (m_options.m_element_count > 0) + return true; + TypeSummaryImpl* entry = GetSummaryFormatter(); if (m_options.m_use_objc) @@ -667,18 +673,22 @@ void ValueObjectPrinter::PrintChild (ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth& curr_ptr_depth) { + const uint32_t consumed_depth = (m_options.m_element_count == 0) ? 1 : 0; + const bool does_consume_ptr_depth = ((IsPtr() && m_options.m_element_count == 0) || IsRef()); + DumpValueObjectOptions child_options(m_options); child_options.SetFormat(m_options.m_format).SetSummary().SetRootValueObjectName(); child_options.SetScopeChecked(true).SetHideName(m_options.m_hide_name).SetHideValue(m_options.m_hide_value) - .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0); + .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - consumed_depth : 0) + .SetElementCount(0); if (child_sp.get()) { ValueObjectPrinter child_printer(child_sp.get(), m_stream, child_options, - (IsPtr() || IsRef()) ? --curr_ptr_depth : curr_ptr_depth, - m_curr_depth + 1, + does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth, + m_curr_depth + consumed_depth, m_printed_instance_pointers); child_printer.PrintValueObject(); } @@ -689,6 +699,9 @@ ValueObjectPrinter::GetMaxNumChildrenToPrint (bool& print_dotdotdot) { ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration(); + if (m_options.m_element_count > 0) + return m_options.m_element_count; + size_t num_children = synth_m_valobj->GetNumChildren(); print_dotdotdot = false; if (num_children) @@ -743,6 +756,21 @@ ValueObjectPrinter::ShouldPrintEmptyBrackets (bool value_printed, return true; } +ValueObjectSP +ValueObjectPrinter::GenerateChild (ValueObject* synth_valobj, size_t idx) +{ + if (m_options.m_element_count > 0) + { + // if generating pointer-as-array children, use GetSyntheticArrayMember + return synth_valobj->GetSyntheticArrayMember(idx, true); + } + else + { + // otherwise, do the usual thing + return synth_valobj->GetChildAtIndex(idx, true); + } +} + void ValueObjectPrinter::PrintChildren (bool value_printed, bool summary_printed, @@ -758,8 +786,7 @@ ValueObjectPrinter::PrintChildren (bool value_printed, for (size_t idx=0; idx<num_children; ++idx) { - ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true)); - if (child_sp) + if (ValueObjectSP child_sp = GenerateChild(synth_m_valobj, idx)) { if (!any_children_printed) { @@ -866,6 +893,7 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed, m_options.m_show_types || !m_options.m_allow_oneliner_mode || m_options.m_flat_output || + (m_options.m_element_count > 0) || m_options.m_show_location) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj); bool is_instance_ptr = IsInstancePointer(); uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS; |