Skip to content

Commit a29be9f

Browse files
Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (llvm#134995)
Reverts llvm#132274 Broke a test on LLDB Widows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/7726 ``` FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf) <...> self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Command 'expression -- foo()' did not return successfully Error output: error: Couldn't look up symbols: int foo(void) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ```
1 parent 258aa65 commit a29be9f

17 files changed

+267
-286
lines changed

lldb/include/lldb/Core/Mangled.h

-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ class Mangled {
246246
/// for s, otherwise the enumerator for the mangling scheme detected.
247247
static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
248248

249-
static bool IsMangledName(llvm::StringRef name);
250-
251249
/// Decode a serialized version of this object from data.
252250
///
253251
/// \param data

lldb/include/lldb/Core/RichManglingContext.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "lldb/lldb-forward.h"
1313
#include "lldb/lldb-private.h"
1414

15-
#include "lldb/Target/Language.h"
1615
#include "lldb/Utility/ConstString.h"
1716

1817
#include "llvm/ADT/Any.h"
@@ -68,7 +67,11 @@ class RichManglingContext {
6867
char *m_ipd_buf;
6968
size_t m_ipd_buf_size = 2048;
7069

71-
std::unique_ptr<Language::MethodName> m_cxx_method_parser;
70+
/// Members for PluginCxxLanguage
71+
/// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The
72+
/// respective header is in Plugins and including it from here causes cyclic
73+
/// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
74+
llvm::Any m_cxx_method_parser;
7275

7376
/// Clean up memory when using PluginCxxLanguage
7477
void ResetCxxMethodParser();
@@ -78,6 +81,15 @@ class RichManglingContext {
7881

7982
/// Uniform handling of string buffers for ItaniumPartialDemangler.
8083
llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len);
84+
85+
/// Cast the given parser to the given type. Ideally we would have a type
86+
/// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we
87+
/// can't access CPlusPlusLanguage::MethodName from within the header.
88+
template <class ParserT> static ParserT *get(llvm::Any parser) {
89+
assert(parser.has_value());
90+
assert(llvm::any_cast<ParserT *>(&parser));
91+
return *llvm::any_cast<ParserT *>(&parser);
92+
}
8193
};
8294

8395
} // namespace lldb_private

lldb/include/lldb/Target/Language.h

-98
Original file line numberDiff line numberDiff line change
@@ -214,104 +214,6 @@ class Language : public PluginInterface {
214214
return std::vector<Language::MethodNameVariant>();
215215
};
216216

217-
class MethodName {
218-
public:
219-
MethodName() {}
220-
221-
MethodName(ConstString full)
222-
: m_full(full), m_basename(), m_context(), m_arguments(),
223-
m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false),
224-
m_parse_error(false) {}
225-
226-
virtual ~MethodName() {};
227-
228-
void Clear() {
229-
m_full.Clear();
230-
m_basename = llvm::StringRef();
231-
m_context = llvm::StringRef();
232-
m_arguments = llvm::StringRef();
233-
m_qualifiers = llvm::StringRef();
234-
m_return_type = llvm::StringRef();
235-
m_scope_qualified.clear();
236-
m_parsed = false;
237-
m_parse_error = false;
238-
}
239-
240-
bool IsValid() {
241-
if (!m_parsed)
242-
Parse();
243-
if (m_parse_error)
244-
return false;
245-
return (bool)m_full;
246-
}
247-
248-
ConstString GetFullName() const { return m_full; }
249-
250-
llvm::StringRef GetBasename() {
251-
if (!m_parsed)
252-
Parse();
253-
return m_basename;
254-
}
255-
256-
llvm::StringRef GetContext() {
257-
if (!m_parsed)
258-
Parse();
259-
return m_context;
260-
}
261-
262-
llvm::StringRef GetArguments() {
263-
if (!m_parsed)
264-
Parse();
265-
return m_arguments;
266-
}
267-
268-
llvm::StringRef GetQualifiers() {
269-
if (!m_parsed)
270-
Parse();
271-
return m_qualifiers;
272-
}
273-
274-
llvm::StringRef GetReturnType() {
275-
if (!m_parsed)
276-
Parse();
277-
return m_return_type;
278-
}
279-
280-
std::string GetScopeQualifiedName() {
281-
if (!m_parsed)
282-
Parse();
283-
return m_scope_qualified;
284-
}
285-
286-
protected:
287-
virtual void Parse() {
288-
m_parsed = true;
289-
m_parse_error = true;
290-
}
291-
292-
ConstString m_full; // Full name:
293-
// "size_t lldb::SBTarget::GetBreakpointAtIndex(unsigned
294-
// int) const"
295-
llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
296-
llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
297-
llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
298-
llvm::StringRef m_qualifiers; // Qualifiers: "const"
299-
llvm::StringRef m_return_type; // Return type: "size_t"
300-
std::string m_scope_qualified;
301-
bool m_parsed = false;
302-
bool m_parse_error = false;
303-
};
304-
305-
virtual std::unique_ptr<Language::MethodName>
306-
GetMethodName(ConstString name) const {
307-
return std::make_unique<Language::MethodName>(name);
308-
};
309-
310-
virtual std::pair<lldb::FunctionNameType, llvm::StringRef>
311-
GetFunctionNameInfo(ConstString name) const {
312-
return std::pair{lldb::eFunctionNameTypeNone, llvm::StringRef()};
313-
};
314-
315217
/// Returns true iff the given symbol name is compatible with the mangling
316218
/// scheme of this language.
317219
///

lldb/source/Core/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ if (LLDB_ENABLE_CURSES)
1616
endif()
1717
endif()
1818

19-
add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
19+
# TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore
20+
add_lldb_library(lldbCore
2021
Address.cpp
2122
AddressRange.cpp
2223
AddressRangeListImpl.cpp
@@ -70,6 +71,8 @@ add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
7071
lldbUtility
7172
lldbValueObject
7273
lldbVersion
74+
lldbPluginCPlusPlusLanguage
75+
lldbPluginObjCLanguage
7376
${LLDB_CURSES_LIBS}
7477

7578
CLANG_LIBS

lldb/source/Core/Mangled.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
#include <cstring>
3434
using namespace lldb_private;
3535

36-
#pragma mark Mangled
37-
38-
bool Mangled::IsMangledName(llvm::StringRef name) {
39-
return Mangled::GetManglingScheme(name) != Mangled::eManglingSchemeNone;
36+
static inline bool cstring_is_mangled(llvm::StringRef s) {
37+
return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
4038
}
4139

40+
#pragma mark Mangled
41+
4242
Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
4343
if (name.empty())
4444
return Mangled::eManglingSchemeNone;
@@ -121,7 +121,7 @@ int Mangled::Compare(const Mangled &a, const Mangled &b) {
121121

122122
void Mangled::SetValue(ConstString name) {
123123
if (name) {
124-
if (IsMangledName(name.GetStringRef())) {
124+
if (cstring_is_mangled(name.GetStringRef())) {
125125
m_demangled.Clear();
126126
m_mangled = name;
127127
} else {

0 commit comments

Comments
 (0)