lassefolger updated this revision to Diff 406355.
lassefolger marked 2 inline comments as done.
lassefolger added a comment.
update according to comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114627/new/
https://reviews.llvm.org/D114627
Files:
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/Core/Module.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Symbol/SymbolFile.cpp
Index: lldb/source/Symbol/SymbolFile.cpp
===================================================================
--- lldb/source/Symbol/SymbolFile.cpp
+++ lldb/source/Symbol/SymbolFile.cpp
@@ -18,6 +18,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private.h"
+#include "llvm/ADT/StringRef.h"
#include <future>
@@ -133,6 +134,18 @@
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {}
+void SymbolFile::FindTypes(
+ ConstString basename, llvm::StringRef scope,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types) {
+ FindTypes(basename, parent_decl_ctx, max_matches, searched_symbol_files,
+ types);
+ TypeClass type_class = eTypeClassAny;
+ types.RemoveMismatchedTypes(std::string(basename.GetCString()), scope.str(),
+ type_class, scope.startswith("::"));
+}
+
void SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Threading.h"
#include "lldb/Core/UniqueCStringMap.h"
@@ -191,6 +192,13 @@
const std::string &scope_qualified_name,
std::vector<lldb_private::ConstString> &mangled_names) override;
+ void
+ FindTypes(lldb_private::ConstString name, llvm::StringRef scope,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
+ uint32_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ lldb_private::TypeMap &types) override;
+
void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -9,6 +9,7 @@
#include "SymbolFileDWARF.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Threading.h"
@@ -21,6 +22,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
@@ -2409,6 +2411,15 @@
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
+ FindTypes(name, llvm::StringRef(), parent_decl_ctx, max_matches,
+ searched_symbol_files, types);
+}
+
+void SymbolFileDWARF::FindTypes(
+ ConstString name, llvm::StringRef scope,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Make sure we haven't already searched this SymbolFile before.
if (!searched_symbol_files.insert(this).second)
@@ -2435,10 +2446,24 @@
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return;
+ // prepare string to check against in case this is a fully qualified search
+ bool has_scope = !scope.empty();
+ if (scope.size() != 2) {
+ // DWARFDIE prefixes only variables in global scope with '::'
+ scope.consume_front("::");
+ }
+
m_index->GetTypes(name, [&](DWARFDIE die) {
if (!DIEInDeclContext(parent_decl_ctx, die))
return true; // The containing decl contexts don't match
+ if (has_scope) {
+ std::string storage;
+ die.GetQualifiedName(storage);
+ if (!storage.empty() && !llvm::StringRef(storage).startswith(scope))
+ return true;
+ }
+
Type *matching_type = ResolveType(die, true, true);
if (!matching_type)
return true;
Index: lldb/source/Core/Module.cpp
===================================================================
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -46,6 +46,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/ADT/StringRef.h"
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h"
@@ -947,6 +948,17 @@
searched_symbol_files, types);
}
+void Module::FindTypes_Impl(
+ ConstString name, llvm::StringRef scope,
+ const CompilerDeclContext &parent_decl_ctx, size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types) {
+ LLDB_SCOPED_TIMER();
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->FindTypes(name, scope, parent_decl_ctx, max_matches,
+ searched_symbol_files, types);
+}
+
void Module::FindTypesInNamespace(ConstString type_name,
const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, TypeList &type_list) {
@@ -983,15 +995,16 @@
if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
type_class)) {
+
+ ConstString type_basename_const_str(type_basename);
+ FindTypes_Impl(type_basename_const_str, type_scope, CompilerDeclContext(),
+ max_matches, searched_symbol_files, typesmap);
+
// Check if "name" starts with "::" which means the qualified type starts
// from the root namespace and implies and exact match. The typenames we
// get back from clang do not start with "::" so we need to strip this off
// in order to get the qualified names to match
exact_match = type_scope.consume_front("::");
-
- ConstString type_basename_const_str(type_basename);
- FindTypes_Impl(type_basename_const_str, CompilerDeclContext(), max_matches,
- searched_symbol_files, typesmap);
if (typesmap.GetSize())
typesmap.RemoveMismatchedTypes(std::string(type_scope),
std::string(type_basename), type_class,
Index: lldb/include/lldb/Symbol/SymbolFile.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -234,6 +234,15 @@
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
+ /// Find types in a specific scope.
+ /// \param scope
+ /// Must be either the scope prefix (with leading ::) or empty
+ virtual void
+ FindTypes(ConstString name, llvm::StringRef scope,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
+
/// Find types specified by a CompilerContextPattern.
/// \param languages
/// Only return results in these languages.
Index: lldb/include/lldb/Core/Module.h
===================================================================
--- lldb/include/lldb/Core/Module.h
+++ lldb/include/lldb/Core/Module.h
@@ -1113,6 +1113,12 @@
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
+ void FindTypes_Impl(
+ ConstString name, llvm::StringRef scope,
+ const CompilerDeclContext &parent_decl_ctx, size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
+
Module(const Module &) = delete;
const Module &operator=(const Module &) = delete;
};
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits