diff options
author | Jim Ingham <jingham@apple.com> | 2014-10-25 00:33:55 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2014-10-25 00:33:55 +0000 |
commit | fa39bb4a56fd1cb035c8dd6bbf4623e5c68424d7 (patch) | |
tree | 773e64e53df928a69c35869ee2fa0887320ad7a3 /lldb | |
parent | d337a59db56d9f1f53d67257c6dcba7842d8738a (diff) | |
download | bcm5719-llvm-fa39bb4a56fd1cb035c8dd6bbf4623e5c68424d7.tar.gz bcm5719-llvm-fa39bb4a56fd1cb035c8dd6bbf4623e5c68424d7.zip |
Setting breakpoints with name mask eFunctionNameTypeBase was broken for straight C names by 220432. Get
that working again.
llvm-svn: 220602
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Target/CPPLanguageRuntime.h | 11 | ||||
-rw-r--r-- | lldb/source/Core/Module.cpp | 31 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Target/CPPLanguageRuntime.cpp | 18 |
4 files changed, 33 insertions, 37 deletions
diff --git a/lldb/include/lldb/Target/CPPLanguageRuntime.h b/lldb/include/lldb/Target/CPPLanguageRuntime.h index daf8a67d2a9..8be9f098add 100644 --- a/lldb/include/lldb/Target/CPPLanguageRuntime.h +++ b/lldb/include/lldb/Target/CPPLanguageRuntime.h @@ -132,9 +132,16 @@ public: static bool IsCPPMangledName(const char *name); - + + // Extract C++ context and identifier from a string using heuristic matching (as opposed to + // CPPLanguageRuntime::MethodName which has to have a fully qualified C++ name with parens and arguments. + // If the name is a lone C identifier (e.g. C) or a qualified C identifier (e.g. A::B::C) it will return true, + // and identifier will be the identifier (C and C respectively) and the context will be "" and "A::B::" respectively. + // If the name fails the heuristic matching for a qualified or unqualified C/C++ identifier, then it will return false + // and identifier and context will be unchanged. + static bool - StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end); + ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier); // in some cases, compilers will output different names for one same type. when that happens, it might be impossible // to construct SBType objects for a valid type, because the name that is available is not the same as the name that diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index f2755282c61..900eea2e041 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1710,8 +1710,9 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, const char *name_cstr = name.GetCString(); lookup_name_type_mask = eFunctionNameTypeNone; match_name_after_lookup = false; - const char *base_name_start = NULL; - const char *base_name_end = NULL; + + llvm::StringRef basename; + llvm::StringRef context; if (name_type_mask & eFunctionNameTypeAuto) { @@ -1725,18 +1726,16 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, lookup_name_type_mask |= eFunctionNameTypeSelector; CPPLanguageRuntime::MethodName cpp_method (name); - llvm::StringRef basename (cpp_method.GetBasename()); + basename = cpp_method.GetBasename(); if (basename.empty()) { - if (CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end)) + if (CPPLanguageRuntime::ExtractContextAndIdentifier (name_cstr, context, basename)) lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase); else lookup_name_type_mask = eFunctionNameTypeFull; } else { - base_name_start = basename.data(); - base_name_end = base_name_start + basename.size(); lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase); } } @@ -1751,9 +1750,7 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, CPPLanguageRuntime::MethodName cpp_method (name); if (cpp_method.IsValid()) { - llvm::StringRef basename (cpp_method.GetBasename()); - base_name_start = basename.data(); - base_name_end = base_name_start + basename.size(); + basename = cpp_method.GetBasename(); if (!cpp_method.GetQualifiers().empty()) { @@ -1766,12 +1763,9 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, } else { - if (!CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end)) - { - lookup_name_type_mask &= ~(eFunctionNameTypeMethod | eFunctionNameTypeBase); - if (lookup_name_type_mask == eFunctionNameTypeNone) - return; - } + // If the CPP method parser didn't manage to chop this up, try to fill in the base name if we can. + // If a::b::c is passed in, we need to just look up "c", and then we'll filter the result later. + CPPLanguageRuntime::ExtractContextAndIdentifier (name_cstr, context, basename); } } @@ -1786,16 +1780,13 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, } } - if (base_name_start && - base_name_end && - base_name_start != name_cstr && - base_name_start < base_name_end) + if (!basename.empty()) { // The name supplied was a partial C++ path like "a::count". In this case we want to do a // lookup on the basename "count" and then make sure any matching results contain "a::count" // so that it would match "b::a::count" and "a::count". This is why we set "match_name_after_lookup" // to true - lookup_name.SetCStringWithLength(base_name_start, base_name_end - base_name_start); + lookup_name.SetString(basename); match_name_after_lookup = true; } else diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 96efd337fa9..aee19529ca8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3197,13 +3197,13 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat if (m_apple_names_ap.get()) { const char *name_cstr = name.GetCString(); - const char *base_name_start; - const char *base_name_end = NULL; + llvm::StringRef basename; + llvm::StringRef context; - if (!CPPLanguageRuntime::StripNamespacesFromVariableName(name_cstr, base_name_start, base_name_end)) - base_name_start = name_cstr; + if (!CPPLanguageRuntime::ExtractContextAndIdentifier(name_cstr, context, basename)) + basename = name_cstr; - m_apple_names_ap->FindByName (base_name_start, die_offsets); + m_apple_names_ap->FindByName (basename.data(), die_offsets); } } else diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp index c928912ca76..082a485386c 100644 --- a/lldb/source/Target/CPPLanguageRuntime.cpp +++ b/lldb/source/Target/CPPLanguageRuntime.cpp @@ -11,6 +11,8 @@ #include <string.h> +#include "llvm/ADT/StringRef.h" + #include "lldb/Core/PluginManager.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Target/ExecutionContext.h" @@ -190,19 +192,15 @@ CPPLanguageRuntime::IsCPPMangledName (const char *name) } bool -CPPLanguageRuntime::StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end) +CPPLanguageRuntime::ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier) { - static RegularExpression g_basename_regex("([A-Za-z_][A-Za-z_0-9]*::)+([A-Za-z_][A-Za-z_0-9]*)$"); - RegularExpression::Match match(2); + static RegularExpression g_basename_regex("^(([A-Za-z_][A-Za-z_0-9]*::)*)([A-Za-z_][A-Za-z_0-9]*)$"); + RegularExpression::Match match(4); if (g_basename_regex.Execute (name, &match)) { - llvm::StringRef basename; - if (match.GetMatchAtIndex(name, 2, basename)) - { - base_name_start = basename.data(); - base_name_end = base_name_start + basename.size(); - return true; - } + match.GetMatchAtIndex(name, 1, context); + match.GetMatchAtIndex(name, 3, identifier); + return true; } return false; } |