Author: Michael Buch Date: 2022-07-26T15:47:35+01:00 New Revision: 0a412b3505f42558573e0d9005d4fe7c6102d8c9
URL: https://github.com/llvm/llvm-project/commit/0a412b3505f42558573e0d9005d4fe7c6102d8c9 DIFF: https://github.com/llvm/llvm-project/commit/0a412b3505f42558573e0d9005d4fe7c6102d8c9.diff LOG: [LLDB][ClangExpression] Prevent nullptr namespace map access during logging Some codepaths lead to `namespace_map == nullptr` when we get to `ClangASTSource::FindCompleteType`. This occurred while debugging an lldb session that had `settings set target.import-std-module true`. In that case, with `LLDBLog::Expressions` logging enabled, we would dereference a `nullptr` and crash. This commit moves the logging until after we check for `nullptr`. **Testing** * Fixed the specific crash I was seeing while debugging an `lldb` session with `import-std-module` enabled. Differential Revision: https://reviews.llvm.org/D130561 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 26775e72669f8..71242925862b3 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -191,12 +191,12 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) { ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp->GetNamespaceMap(namespace_context); - LLDB_LOGV(log, " CTD Inspecting namespace map{0} ({1} entries)", - namespace_map.get(), namespace_map->size()); - if (!namespace_map) return nullptr; + LLDB_LOGV(log, " CTD Inspecting namespace map{0} ({1} entries)", + namespace_map.get(), namespace_map->size()); + for (const ClangASTImporter::NamespaceMapItem &item : *namespace_map) { LLDB_LOG(log, " CTD Searching namespace {0} in module {1}", item.second.GetName(), item.first->GetFileSpec().GetFilename()); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits