[Lldb-commits] [lldb] [LLDB] Move Itanium language runtime to C++ language runtime (PR #169225)
via lldb-commits
lldb-commits at lists.llvm.org
Sun Nov 23 08:58:06 PST 2025
https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/169225
None
>From cb2d9f8efd550d74fc6dc11234eebbf60d64cea4 Mon Sep 17 00:00:00 2001
From: Nerixyz <nerixdev at outlook.de>
Date: Sat, 22 Nov 2025 20:41:44 +0100
Subject: [PATCH] [LLDB] Move Itanium language runtime to C++ language runtime
---
.../LanguageRuntime/CPlusPlus/CMakeLists.txt | 11 +-
.../CPlusPlus/CPPLanguageRuntime.cpp | 185 ++++++++++
.../CPlusPlus/CPPLanguageRuntime.h | 60 ++-
.../CPlusPlus/CommandObjectCPlusPlus.cpp | 68 ++++
.../CPlusPlus/CommandObjectCPlusPlus.h | 30 ++
.../CPlusPlus/ItaniumABI/CMakeLists.txt | 13 -
.../ItaniumABI/ItaniumABILanguageRuntime.h | 127 -------
...guageRuntime.cpp => ItaniumABIRuntime.cpp} | 348 +++---------------
.../CPlusPlus/ItaniumABIRuntime.h | 64 ++++
lldb/source/Plugins/REPL/Clang/CMakeLists.txt | 1 -
10 files changed, 465 insertions(+), 442 deletions(-)
create mode 100644 lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.cpp
create mode 100644 lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.h
delete mode 100644 lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
delete mode 100644 lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
rename lldb/source/Plugins/LanguageRuntime/CPlusPlus/{ItaniumABI/ItaniumABILanguageRuntime.cpp => ItaniumABIRuntime.cpp} (56%)
create mode 100644 lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
index 727c8290bceb4..ca54601d99cff 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
@@ -1,14 +1,17 @@
-add_lldb_library(lldbPluginCPPRuntime
+add_lldb_library(lldbPluginCPPRuntime PLUGIN
+ CommandObjectCPlusPlus.cpp
CPPLanguageRuntime.cpp
+ ItaniumABIRuntime.cpp
VerboseTrapFrameRecognizer.cpp
LINK_LIBS
+ lldbBreakpoint
lldbCore
+ lldbInterpreter
+ lldbPluginTypeSystemClang
lldbSymbol
lldbTarget
+ lldbValueObject
CLANG_LIBS
clangCodeGen
)
-
-add_subdirectory(ItaniumABI)
-#add_subdirectory(MicrosoftABI)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 913678b629f2f..3c127616f2d24 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -12,6 +12,7 @@
#include <memory>
#include "CPPLanguageRuntime.h"
+#include "CommandObjectCPlusPlus.h"
#include "VerboseTrapFrameRecognizer.h"
#include "llvm/ADT/StringRef.h"
@@ -36,6 +37,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(CPPLanguageRuntime, CPPRuntime)
+
static ConstString g_this = ConstString("this");
// Artificial coroutine-related variables emitted by clang.
static ConstString g_promise = ConstString("__promise");
@@ -491,3 +494,185 @@ bool CPPLanguageRuntime::IsSymbolARuntimeThunk(const Symbol &symbol) {
return mangled_name.starts_with("_ZTh") || mangled_name.starts_with("_ZTv") ||
mangled_name.starts_with("_ZTc");
}
+
+bool CPPLanguageRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
+ const bool check_cxx = true;
+ const bool check_objc = false;
+ return in_value.GetCompilerType().IsPossibleDynamicType(nullptr, check_cxx,
+ check_objc);
+}
+
+bool CPPLanguageRuntime::GetDynamicTypeAndAddress(
+ ValueObject &in_value, lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name, Address &dynamic_address,
+ Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
+ class_type_or_name.Clear();
+ value_type = Value::ValueType::Scalar;
+
+ if (!CouldHaveDynamicValue(in_value))
+ return false;
+
+ return m_itanium_runtime.GetDynamicTypeAndAddress(
+ in_value, use_dynamic, class_type_or_name, dynamic_address, value_type,
+ *m_process);
+}
+
+TypeAndOrName
+CPPLanguageRuntime::FixUpDynamicType(const TypeAndOrName &type_and_or_name,
+ ValueObject &static_value) {
+ CompilerType static_type(static_value.GetCompilerType());
+ Flags static_type_flags(static_type.GetTypeInfo());
+
+ TypeAndOrName ret(type_and_or_name);
+ if (type_and_or_name.HasType()) {
+ // The type will always be the type of the dynamic object. If our parent's
+ // type was a pointer, then our type should be a pointer to the type of the
+ // dynamic object. If a reference, then the original type should be
+ // okay...
+ CompilerType orig_type = type_and_or_name.GetCompilerType();
+ CompilerType corrected_type = orig_type;
+ if (static_type_flags.AllSet(eTypeIsPointer))
+ corrected_type = orig_type.GetPointerType();
+ else if (static_type_flags.AllSet(eTypeIsReference))
+ corrected_type = orig_type.GetLValueReferenceType();
+ ret.SetCompilerType(corrected_type);
+ } else {
+ // If we are here we need to adjust our dynamic type name to include the
+ // correct & or * symbol
+ std::string corrected_name(type_and_or_name.GetName().GetCString());
+ if (static_type_flags.AllSet(eTypeIsPointer))
+ corrected_name.append(" *");
+ else if (static_type_flags.AllSet(eTypeIsReference))
+ corrected_name.append(" &");
+ // the parent type should be a correctly pointer'ed or referenc'ed type
+ ret.SetCompilerType(static_type);
+ ret.SetName(corrected_name.c_str());
+ }
+ return ret;
+}
+
+LanguageRuntime *
+CPPLanguageRuntime::CreateInstance(Process *process,
+ lldb::LanguageType language) {
+ if (language == eLanguageTypeC_plus_plus ||
+ language == eLanguageTypeC_plus_plus_03 ||
+ language == eLanguageTypeC_plus_plus_11 ||
+ language == eLanguageTypeC_plus_plus_14)
+ return new CPPLanguageRuntime(process);
+ else
+ return nullptr;
+}
+
+void CPPLanguageRuntime::Initialize() {
+ PluginManager::RegisterPlugin(
+ GetPluginNameStatic(), "C++ language runtime", CreateInstance,
+ [](CommandInterpreter &interpreter) -> lldb::CommandObjectSP {
+ return CommandObjectSP(new CommandObjectCPlusPlus(interpreter));
+ });
+}
+
+void CPPLanguageRuntime::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+llvm::Expected<LanguageRuntime::VTableInfo>
+CPPLanguageRuntime::GetVTableInfo(ValueObject &in_value, bool check_type) {
+ return m_itanium_runtime.GetVTableInfo(in_value, check_type);
+}
+
+BreakpointResolverSP
+CPPLanguageRuntime::CreateExceptionResolver(const BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) {
+ return CreateExceptionResolver(bkpt, catch_bp, throw_bp, false);
+}
+
+BreakpointResolverSP
+CPPLanguageRuntime::CreateExceptionResolver(const BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp,
+ bool for_expressions) {
+ std::vector<const char *> exception_names;
+ m_itanium_runtime.AppendExceptionBreakpointFunctions(
+ exception_names, catch_bp, throw_bp, for_expressions);
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverName(
+ bkpt, exception_names.data(), exception_names.size(),
+ eFunctionNameTypeBase, eLanguageTypeUnknown, 0, eLazyBoolNo));
+
+ return resolver_sp;
+}
+
+lldb::SearchFilterSP CPPLanguageRuntime::CreateExceptionSearchFilter() {
+ Target &target = m_process->GetTarget();
+
+ FileSpecList filter_modules;
+ m_itanium_runtime.AppendExceptionBreakpointFilterModules(filter_modules,
+ target);
+ return target.GetSearchFilterForModuleList(&filter_modules);
+}
+
+lldb::BreakpointSP CPPLanguageRuntime::CreateExceptionBreakpoint(
+ bool catch_bp, bool throw_bp, bool for_expressions, bool is_internal) {
+ Target &target = m_process->GetTarget();
+ FileSpecList filter_modules;
+ BreakpointResolverSP exception_resolver_sp =
+ CreateExceptionResolver(nullptr, catch_bp, throw_bp, for_expressions);
+ SearchFilterSP filter_sp(CreateExceptionSearchFilter());
+ const bool hardware = false;
+ const bool resolve_indirect_functions = false;
+ return target.CreateBreakpoint(filter_sp, exception_resolver_sp, is_internal,
+ hardware, resolve_indirect_functions);
+}
+
+void CPPLanguageRuntime::SetExceptionBreakpoints() {
+ if (!m_process)
+ return;
+
+ const bool catch_bp = false;
+ const bool throw_bp = true;
+ const bool is_internal = true;
+ const bool for_expressions = true;
+
+ // For the exception breakpoints set by the Expression parser, we'll be a
+ // little more aggressive and stop at exception allocation as well.
+
+ if (m_cxx_exception_bp_sp) {
+ m_cxx_exception_bp_sp->SetEnabled(true);
+ } else {
+ m_cxx_exception_bp_sp = CreateExceptionBreakpoint(
+ catch_bp, throw_bp, for_expressions, is_internal);
+ if (m_cxx_exception_bp_sp)
+ m_cxx_exception_bp_sp->SetBreakpointKind("c++ exception");
+ }
+}
+
+void CPPLanguageRuntime::ClearExceptionBreakpoints() {
+ if (!m_process)
+ return;
+
+ if (m_cxx_exception_bp_sp) {
+ m_cxx_exception_bp_sp->SetEnabled(false);
+ }
+}
+
+bool CPPLanguageRuntime::ExceptionBreakpointsAreSet() {
+ return m_cxx_exception_bp_sp && m_cxx_exception_bp_sp->IsEnabled();
+}
+
+bool CPPLanguageRuntime::ExceptionBreakpointsExplainStop(
+ lldb::StopInfoSP stop_reason) {
+ if (!m_process)
+ return false;
+
+ if (!stop_reason || stop_reason->GetStopReason() != eStopReasonBreakpoint)
+ return false;
+
+ uint64_t break_site_id = stop_reason->GetValue();
+ return m_process->GetBreakpointSiteList().StopPointSiteContainsBreakpoint(
+ break_site_id, m_cxx_exception_bp_sp->GetID());
+}
+
+lldb::ValueObjectSP
+CPPLanguageRuntime::GetExceptionObjectForThread(lldb::ThreadSP thread_sp) {
+ return m_itanium_runtime.GetExceptionObjectForThread(std::move(thread_sp),
+ *m_process);
+}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
index 05639e9798917..7c3dade76d703 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringMap.h"
+#include "ItaniumABIRuntime.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/lldb-private.h"
@@ -42,6 +43,19 @@ class CPPLanguageRuntime : public LanguageRuntime {
static char ID;
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::LanguageRuntime *
+ CreateInstance(Process *process, lldb::LanguageType language);
+
+ static llvm::StringRef GetPluginNameStatic() {
+ return "cpp-language-runtime";
+ }
+
+ llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
bool isA(const void *ClassID) const override {
return ClassID == &ID || LanguageRuntime::isA(ClassID);
}
@@ -81,15 +95,55 @@ class CPPLanguageRuntime : public LanguageRuntime {
bool IsSymbolARuntimeThunk(const Symbol &symbol) override;
-protected:
- // Classes that inherit from CPPLanguageRuntime can see and modify these
- CPPLanguageRuntime(Process *process);
+ llvm::Expected<LanguageRuntime::VTableInfo>
+ GetVTableInfo(ValueObject &in_value, bool check_type) override;
+
+ bool GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &address, Value::ValueType &value_type,
+ llvm::ArrayRef<uint8_t> &local_buffer) override;
+
+ TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
+ ValueObject &static_value) override;
+
+ bool CouldHaveDynamicValue(ValueObject &in_value) override;
+
+ void SetExceptionBreakpoints() override;
+
+ void ClearExceptionBreakpoints() override;
+
+ bool ExceptionBreakpointsAreSet() override;
+
+ bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
+
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp,
+ bool throw_bp) override;
+
+ lldb::SearchFilterSP CreateExceptionSearchFilter() override;
+
+ lldb::ValueObjectSP
+ GetExceptionObjectForThread(lldb::ThreadSP thread_sp) override;
private:
+ CPPLanguageRuntime(Process *process);
+
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp,
+ bool throw_bp, bool for_expressions);
+
+ lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp,
+ bool for_expressions,
+ bool is_internal);
+
using OperatorStringToCallableInfoMap =
llvm::StringMap<CPPLanguageRuntime::LibCppStdFunctionCallableInfo>;
OperatorStringToCallableInfoMap CallableLookupCache;
+
+ lldb::BreakpointSP m_cxx_exception_bp_sp;
+ ItaniumABIRuntime m_itanium_runtime;
};
} // namespace lldb_private
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.cpp
new file mode 100644
index 0000000000000..9d6903f0903cf
--- /dev/null
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CommandObjectCPlusPlus.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+CommandObjectCPlusPlusDemangle::CommandObjectCPlusPlusDemangle(
+ CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "demangle",
+ "Demangle a C++ mangled name.",
+ "language cplusplus demangle [<mangled-name> ...]") {
+ AddSimpleArgumentList(eArgTypeSymbol, eArgRepeatPlus);
+}
+
+void CommandObjectCPlusPlusDemangle::DoExecute(Args &command,
+ CommandReturnObject &result) {
+ bool demangled_any = false;
+ bool error_any = false;
+ for (auto &entry : command.entries()) {
+ if (entry.ref().empty())
+ continue;
+
+ // the actual Mangled class should be strict about this, but on the
+ // command line if you're copying mangled names out of 'nm' on Darwin,
+ // they will come out with an extra underscore - be willing to strip this
+ // on behalf of the user. This is the moral equivalent of the -_/-n
+ // options to c++filt
+ auto name = entry.ref();
+ if (name.starts_with("__Z"))
+ name = name.drop_front();
+
+ Mangled mangled(name);
+ if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus) {
+ ConstString demangled(mangled.GetDisplayDemangledName());
+ demangled_any = true;
+ result.AppendMessageWithFormat("%s ---> %s\n", entry.c_str(),
+ demangled.GetCString());
+ } else {
+ error_any = true;
+ result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n",
+ entry.ref().str().c_str());
+ }
+ }
+
+ result.SetStatus(
+ error_any ? lldb::eReturnStatusFailed
+ : (demangled_any ? lldb::eReturnStatusSuccessFinishResult
+ : lldb::eReturnStatusSuccessFinishNoResult));
+}
+
+CommandObjectCPlusPlus::CommandObjectCPlusPlus(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(
+ interpreter, "cplusplus",
+ "Commands for operating on the C++ language runtime.",
+ "cplusplus <subcommand> [<subcommand-options>]") {
+ LoadSubCommand("demangle", CommandObjectSP(new CommandObjectCPlusPlusDemangle(
+ interpreter)));
+}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.h
new file mode 100644
index 0000000000000..f95bf7ae85389
--- /dev/null
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CommandObjectCPlusPlus.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_COMMANDOBJECTCPLUSPLUS_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_COMMANDOBJECTCPLUSPLUS_H
+
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+namespace lldb_private {
+
+class CommandObjectCPlusPlusDemangle : public CommandObjectParsed {
+public:
+ CommandObjectCPlusPlusDemangle(CommandInterpreter &interpreter);
+
+protected:
+ void DoExecute(Args &command, CommandReturnObject &result) override;
+};
+
+class CommandObjectCPlusPlus : public CommandObjectMultiword {
+public:
+ CommandObjectCPlusPlus(CommandInterpreter &interpreter);
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
deleted file mode 100644
index a5406c73be933..0000000000000
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_lldb_library(lldbPluginCXXItaniumABI PLUGIN
- ItaniumABILanguageRuntime.cpp
-
- LINK_LIBS
- lldbBreakpoint
- lldbCore
- lldbInterpreter
- lldbSymbol
- lldbTarget
- lldbValueObject
- lldbPluginCPPRuntime
- lldbPluginTypeSystemClang
- )
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
deleted file mode 100644
index 7abf2f8547cd5..0000000000000
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
+++ /dev/null
@@ -1,127 +0,0 @@
-//===-- ItaniumABILanguageRuntime.h -----------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
-#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
-
-#include <map>
-#include <mutex>
-#include <vector>
-
-#include "lldb/Breakpoint/BreakpointResolver.h"
-#include "lldb/Core/Value.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/lldb-private.h"
-
-#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
-
-namespace lldb_private {
-
-class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime {
-public:
- ~ItaniumABILanguageRuntime() override = default;
-
- // Static Functions
- static void Initialize();
-
- static void Terminate();
-
- static lldb_private::LanguageRuntime *
- CreateInstance(Process *process, lldb::LanguageType language);
-
- static llvm::StringRef GetPluginNameStatic() { return "itanium"; }
-
- static char ID;
-
- bool isA(const void *ClassID) const override {
- return ClassID == &ID || CPPLanguageRuntime::isA(ClassID);
- }
-
- static bool classof(const LanguageRuntime *runtime) {
- return runtime->isA(&ID);
- }
-
-
- llvm::Expected<LanguageRuntime::VTableInfo>
- GetVTableInfo(ValueObject &in_value, bool check_type) override;
-
- bool GetDynamicTypeAndAddress(ValueObject &in_value,
- lldb::DynamicValueType use_dynamic,
- TypeAndOrName &class_type_or_name,
- Address &address, Value::ValueType &value_type,
- llvm::ArrayRef<uint8_t> &local_buffer) override;
-
- TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
- ValueObject &static_value) override;
-
- bool CouldHaveDynamicValue(ValueObject &in_value) override;
-
- void SetExceptionBreakpoints() override;
-
- void ClearExceptionBreakpoints() override;
-
- bool ExceptionBreakpointsAreSet() override;
-
- bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
-
- lldb::BreakpointResolverSP
- CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
- bool catch_bp, bool throw_bp) override;
-
- lldb::SearchFilterSP CreateExceptionSearchFilter() override;
-
- lldb::ValueObjectSP GetExceptionObjectForThread(
- lldb::ThreadSP thread_sp) override;
-
- // PluginInterface protocol
- llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
-
-protected:
- lldb::BreakpointResolverSP
- CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
- bool catch_bp, bool throw_bp, bool for_expressions);
-
- lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp,
- bool for_expressions,
- bool is_internal);
-
-private:
- typedef std::map<lldb_private::Address, TypeAndOrName> DynamicTypeCache;
- typedef std::map<lldb_private::Address, VTableInfo> VTableInfoCache;
-
- ItaniumABILanguageRuntime(Process *process)
- : // Call CreateInstance instead.
- lldb_private::CPPLanguageRuntime(process) {}
-
- lldb::BreakpointSP m_cxx_exception_bp_sp;
- DynamicTypeCache m_dynamic_type_map;
- VTableInfoCache m_vtable_info_map;
- std::mutex m_mutex;
-
- TypeAndOrName GetTypeInfo(ValueObject &in_value,
- const VTableInfo &vtable_info);
-
- TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr);
-
- void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr,
- const TypeAndOrName &type_info);
-
- // Check if a compiler type has a vtable.
- //
- // If the compiler type is a pointer or a reference, this function will check
- // if the pointee type has a vtable, else it will check the type passed in.
- //
- // Returns an error if the type of the value doesn't have a vtable with an
- // explanation why, or returns an Error::success() if the type has a vtable.
- llvm::Error TypeHasVTable(CompilerType compiler_type);
-};
-
-} // namespace lldb_private
-
-#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
similarity index 56%
rename from lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
rename to lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
index 75b00518aac53..2ea1452214d5b 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- ItaniumABILanguageRuntime.cpp -------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,56 +6,23 @@
//
//===----------------------------------------------------------------------===//
-#include "ItaniumABILanguageRuntime.h"
+#include "ItaniumABIRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Mangled.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Interpreter/CommandObject.h"
-#include "lldb/Interpreter/CommandObjectMultiword.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Symbol/Symbol.h"
-#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/TypeList.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/SectionLoadList.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/Status.h"
-#include "lldb/ValueObject/ValueObject.h"
-#include "lldb/ValueObject/ValueObjectMemory.h"
-
-#include <vector>
using namespace lldb;
using namespace lldb_private;
-LLDB_PLUGIN_DEFINE_ADV(ItaniumABILanguageRuntime, CXXItaniumABI)
-
static const char *vtable_demangled_prefix = "vtable for ";
-char ItaniumABILanguageRuntime::ID = 0;
-
-bool ItaniumABILanguageRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
- const bool check_cxx = true;
- const bool check_objc = false;
- return in_value.GetCompilerType().IsPossibleDynamicType(nullptr, check_cxx,
- check_objc);
-}
-
-TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfo(
- ValueObject &in_value, const VTableInfo &vtable_info) {
+TypeAndOrName
+ItaniumABIRuntime::GetTypeInfo(ValueObject &in_value,
+ const LanguageRuntime::VTableInfo &vtable_info,
+ Process &process) {
if (vtable_info.addr.IsSectionOffset()) {
// See if we have cached info for this type already
TypeAndOrName type_info = GetDynamicTypeInfo(vtable_info.addr);
@@ -102,7 +69,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfo(
// list in the target and get as many unique matches as possible
if (class_types.Empty()) {
query.SetFindOne(false);
- m_process->GetTarget().GetImages().FindTypes(nullptr, query, results);
+ process.GetTarget().GetImages().FindTypes(nullptr, query, results);
for (const auto &type_sp : results.GetTypeMap().Types())
class_types.Insert(type_sp);
}
@@ -179,7 +146,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfo(
return TypeAndOrName();
}
-llvm::Error ItaniumABILanguageRuntime::TypeHasVTable(CompilerType type) {
+llvm::Error ItaniumABIRuntime::TypeHasVTable(CompilerType type) {
// Check to make sure the class has a vtable.
CompilerType original_type = type;
if (type.IsPointerOrReferenceType()) {
@@ -191,7 +158,8 @@ llvm::Error ItaniumABILanguageRuntime::TypeHasVTable(CompilerType type) {
// Make sure this is a class or a struct first by checking the type class
// bitfield that gets returned.
if ((type.GetTypeClass() & (eTypeClassStruct | eTypeClassClass)) == 0) {
- return llvm::createStringError(std::errc::invalid_argument,
+ return llvm::createStringError(
+ std::errc::invalid_argument,
"type \"%s\" is not a class or struct or a pointer to one",
original_type.GetTypeName().AsCString("<invalid>"));
}
@@ -199,8 +167,8 @@ llvm::Error ItaniumABILanguageRuntime::TypeHasVTable(CompilerType type) {
// Check if the type has virtual functions by asking it if it is polymorphic.
if (!type.IsPolymorphicClass()) {
return llvm::createStringError(std::errc::invalid_argument,
- "type \"%s\" doesn't have a vtable",
- type.GetTypeName().AsCString("<invalid>"));
+ "type \"%s\" doesn't have a vtable",
+ type.GetTypeName().AsCString("<invalid>"));
}
return llvm::Error::success();
}
@@ -213,8 +181,7 @@ llvm::Error ItaniumABILanguageRuntime::TypeHasVTable(CompilerType type) {
// and is can pass in instances of classes which is not suitable for dynamic
// type detection, these cases should pass true for \a check_type.
llvm::Expected<LanguageRuntime::VTableInfo>
- ItaniumABILanguageRuntime::GetVTableInfo(ValueObject &in_value,
- bool check_type) {
+ItaniumABIRuntime::GetVTableInfo(ValueObject &in_value, bool check_type) {
CompilerType type = in_value.GetCompilerType();
if (check_type) {
@@ -240,7 +207,8 @@ llvm::Expected<LanguageRuntime::VTableInfo>
process->ReadPointerFromMemory(original_ptr, error);
if (!error.Success() || vtable_load_addr == LLDB_INVALID_ADDRESS)
- return llvm::createStringError(std::errc::invalid_argument,
+ return llvm::createStringError(
+ std::errc::invalid_argument,
"failed to read vtable pointer from memory at 0x%" PRIx64,
original_ptr);
@@ -252,8 +220,9 @@ llvm::Expected<LanguageRuntime::VTableInfo>
Address vtable_addr;
if (!process->GetTarget().ResolveLoadAddress(vtable_load_addr, vtable_addr))
return llvm::createStringError(std::errc::invalid_argument,
- "failed to resolve vtable pointer 0x%"
- PRIx64 "to a section", vtable_load_addr);
+ "failed to resolve vtable pointer 0x%" PRIx64
+ "to a section",
+ vtable_load_addr);
// Check our cache first to see if we already have this info
{
@@ -270,20 +239,21 @@ llvm::Expected<LanguageRuntime::VTableInfo>
vtable_load_addr);
llvm::StringRef name = symbol->GetMangled().GetDemangledName().GetStringRef();
if (name.starts_with(vtable_demangled_prefix)) {
- VTableInfo info = {vtable_addr, symbol};
+ LanguageRuntime::VTableInfo info = {vtable_addr, symbol};
std::lock_guard<std::mutex> locker(m_mutex);
auto pos = m_vtable_info_map[vtable_addr] = info;
return info;
}
return llvm::createStringError(std::errc::invalid_argument,
- "symbol found that contains 0x%" PRIx64 " is not a vtable symbol",
- vtable_load_addr);
+ "symbol found that contains 0x%" PRIx64
+ " is not a vtable symbol",
+ vtable_load_addr);
}
-bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
+bool ItaniumABIRuntime::GetDynamicTypeAndAddress(
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name, Address &dynamic_address,
- Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
+ Value::ValueType &value_type, Process &process) {
// For Itanium, if the type has a vtable pointer in the object, it will be at
// offset 0 in the object. That will point to the "address point" within the
// vtable (not the beginning of the vtable.) We can then look up the symbol
@@ -291,28 +261,21 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
// contain the full class name. The second pointer above the "address point"
// is the "offset_to_top". We'll use that to get the start of the value
// object which holds the dynamic type.
- //
-
- class_type_or_name.Clear();
- value_type = Value::ValueType::Scalar;
-
- if (!CouldHaveDynamicValue(in_value))
- return false;
// Check if we have a vtable pointer in this value. If we don't it will
// return an error, else it will return a valid resolved address. We don't
// want GetVTableInfo to check the type since we accept void * as a possible
// dynamic type and that won't pass the type check. We already checked the
// type above in CouldHaveDynamicValue(...).
- llvm::Expected<VTableInfo> vtable_info_or_err =
+ llvm::Expected<LanguageRuntime::VTableInfo> vtable_info_or_err =
GetVTableInfo(in_value, /*check_type=*/false);
if (!vtable_info_or_err) {
llvm::consumeError(vtable_info_or_err.takeError());
return false;
}
- const VTableInfo &vtable_info = vtable_info_or_err.get();
- class_type_or_name = GetTypeInfo(in_value, vtable_info);
+ const LanguageRuntime::VTableInfo &vtable_info = vtable_info_or_err.get();
+ class_type_or_name = GetTypeInfo(in_value, vtable_info, process);
if (!class_type_or_name)
return false;
@@ -332,11 +295,11 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
}
// The offset_to_top is two pointers above the vtable pointer.
- Target &target = m_process->GetTarget();
+ Target &target = process.GetTarget();
const addr_t vtable_load_addr = vtable_info.addr.GetLoadAddress(&target);
if (vtable_load_addr == LLDB_INVALID_ADDRESS)
return false;
- const uint32_t addr_byte_size = m_process->GetAddressByteSize();
+ const uint32_t addr_byte_size = process.GetAddressByteSize();
const lldb::addr_t offset_to_top_location =
vtable_load_addr - 2 * addr_byte_size;
// Watch for underflow, offset_to_top_location should be less than
@@ -353,146 +316,14 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
// the original address.
lldb::addr_t dynamic_addr =
in_value.GetPointerValue().address + offset_to_top;
- if (!m_process->GetTarget().ResolveLoadAddress(
- dynamic_addr, dynamic_address)) {
+ if (!process.GetTarget().ResolveLoadAddress(dynamic_addr, dynamic_address)) {
dynamic_address.SetRawAddress(dynamic_addr);
}
return true;
}
-TypeAndOrName ItaniumABILanguageRuntime::FixUpDynamicType(
- const TypeAndOrName &type_and_or_name, ValueObject &static_value) {
- CompilerType static_type(static_value.GetCompilerType());
- Flags static_type_flags(static_type.GetTypeInfo());
-
- TypeAndOrName ret(type_and_or_name);
- if (type_and_or_name.HasType()) {
- // The type will always be the type of the dynamic object. If our parent's
- // type was a pointer, then our type should be a pointer to the type of the
- // dynamic object. If a reference, then the original type should be
- // okay...
- CompilerType orig_type = type_and_or_name.GetCompilerType();
- CompilerType corrected_type = orig_type;
- if (static_type_flags.AllSet(eTypeIsPointer))
- corrected_type = orig_type.GetPointerType();
- else if (static_type_flags.AllSet(eTypeIsReference))
- corrected_type = orig_type.GetLValueReferenceType();
- ret.SetCompilerType(corrected_type);
- } else {
- // If we are here we need to adjust our dynamic type name to include the
- // correct & or * symbol
- std::string corrected_name(type_and_or_name.GetName().GetCString());
- if (static_type_flags.AllSet(eTypeIsPointer))
- corrected_name.append(" *");
- else if (static_type_flags.AllSet(eTypeIsReference))
- corrected_name.append(" &");
- // the parent type should be a correctly pointer'ed or referenc'ed type
- ret.SetCompilerType(static_type);
- ret.SetName(corrected_name.c_str());
- }
- return ret;
-}
-
-// Static Functions
-LanguageRuntime *
-ItaniumABILanguageRuntime::CreateInstance(Process *process,
- lldb::LanguageType language) {
- // FIXME: We have to check the process and make sure we actually know that
- // this process supports
- // the Itanium ABI.
- if (language == eLanguageTypeC_plus_plus ||
- language == eLanguageTypeC_plus_plus_03 ||
- language == eLanguageTypeC_plus_plus_11 ||
- language == eLanguageTypeC_plus_plus_14)
- return new ItaniumABILanguageRuntime(process);
- else
- return nullptr;
-}
-
-class CommandObjectMultiwordItaniumABI_Demangle : public CommandObjectParsed {
-public:
- CommandObjectMultiwordItaniumABI_Demangle(CommandInterpreter &interpreter)
- : CommandObjectParsed(
- interpreter, "demangle", "Demangle a C++ mangled name.",
- "language cplusplus demangle [<mangled-name> ...]") {
- AddSimpleArgumentList(eArgTypeSymbol, eArgRepeatPlus);
- }
-
- ~CommandObjectMultiwordItaniumABI_Demangle() override = default;
-
-protected:
- void DoExecute(Args &command, CommandReturnObject &result) override {
- bool demangled_any = false;
- bool error_any = false;
- for (auto &entry : command.entries()) {
- if (entry.ref().empty())
- continue;
-
- // the actual Mangled class should be strict about this, but on the
- // command line if you're copying mangled names out of 'nm' on Darwin,
- // they will come out with an extra underscore - be willing to strip this
- // on behalf of the user. This is the moral equivalent of the -_/-n
- // options to c++filt
- auto name = entry.ref();
- if (name.starts_with("__Z"))
- name = name.drop_front();
-
- Mangled mangled(name);
- if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus) {
- ConstString demangled(mangled.GetDisplayDemangledName());
- demangled_any = true;
- result.AppendMessageWithFormat("%s ---> %s\n", entry.c_str(),
- demangled.GetCString());
- } else {
- error_any = true;
- result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n",
- entry.ref().str().c_str());
- }
- }
-
- result.SetStatus(
- error_any ? lldb::eReturnStatusFailed
- : (demangled_any ? lldb::eReturnStatusSuccessFinishResult
- : lldb::eReturnStatusSuccessFinishNoResult));
- }
-};
-
-class CommandObjectMultiwordItaniumABI : public CommandObjectMultiword {
-public:
- CommandObjectMultiwordItaniumABI(CommandInterpreter &interpreter)
- : CommandObjectMultiword(
- interpreter, "cplusplus",
- "Commands for operating on the C++ language runtime.",
- "cplusplus <subcommand> [<subcommand-options>]") {
- LoadSubCommand(
- "demangle",
- CommandObjectSP(
- new CommandObjectMultiwordItaniumABI_Demangle(interpreter)));
- }
-
- ~CommandObjectMultiwordItaniumABI() override = default;
-};
-
-void ItaniumABILanguageRuntime::Initialize() {
- PluginManager::RegisterPlugin(
- GetPluginNameStatic(), "Itanium ABI for the C++ language", CreateInstance,
- [](CommandInterpreter &interpreter) -> lldb::CommandObjectSP {
- return CommandObjectSP(
- new CommandObjectMultiwordItaniumABI(interpreter));
- });
-}
-
-void ItaniumABILanguageRuntime::Terminate() {
- PluginManager::UnregisterPlugin(CreateInstance);
-}
-
-BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
- const BreakpointSP &bkpt, bool catch_bp, bool throw_bp) {
- return CreateExceptionResolver(bkpt, catch_bp, throw_bp, false);
-}
-
-BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
- const BreakpointSP &bkpt, bool catch_bp, bool throw_bp,
+void ItaniumABIRuntime::AppendExceptionBreakpointFunctions(
+ std::vector<const char *> &names, bool catch_bp, bool throw_bp,
bool for_expressions) {
// One complication here is that most users DON'T want to stop at
// __cxa_allocate_expression, but until we can do anything better with
@@ -505,30 +336,21 @@ BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
static const char *g_throw_name1 = "__cxa_throw";
static const char *g_throw_name2 = "__cxa_rethrow";
static const char *g_exception_throw_name = "__cxa_allocate_exception";
- std::vector<const char *> exception_names;
- exception_names.reserve(4);
+
if (catch_bp)
- exception_names.push_back(g_catch_name);
+ names.push_back(g_catch_name);
if (throw_bp) {
- exception_names.push_back(g_throw_name1);
- exception_names.push_back(g_throw_name2);
+ names.push_back(g_throw_name1);
+ names.push_back(g_throw_name2);
}
if (for_expressions)
- exception_names.push_back(g_exception_throw_name);
-
- BreakpointResolverSP resolver_sp(new BreakpointResolverName(
- bkpt, exception_names.data(), exception_names.size(),
- eFunctionNameTypeBase, eLanguageTypeUnknown, 0, eLazyBoolNo));
-
- return resolver_sp;
+ names.push_back(g_exception_throw_name);
}
-lldb::SearchFilterSP ItaniumABILanguageRuntime::CreateExceptionSearchFilter() {
- Target &target = m_process->GetTarget();
-
- FileSpecList filter_modules;
+void ItaniumABIRuntime::AppendExceptionBreakpointFilterModules(
+ FileSpecList &filter_modules, const Target &target) {
if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
// Limit the number of modules that are searched for these breakpoints for
// Apple binaries.
@@ -537,77 +359,15 @@ lldb::SearchFilterSP ItaniumABILanguageRuntime::CreateExceptionSearchFilter() {
filter_modules.EmplaceBack("libc++abi.1.0.dylib");
filter_modules.EmplaceBack("libc++abi.1.dylib");
}
- return target.GetSearchFilterForModuleList(&filter_modules);
-}
-
-lldb::BreakpointSP ItaniumABILanguageRuntime::CreateExceptionBreakpoint(
- bool catch_bp, bool throw_bp, bool for_expressions, bool is_internal) {
- Target &target = m_process->GetTarget();
- FileSpecList filter_modules;
- BreakpointResolverSP exception_resolver_sp =
- CreateExceptionResolver(nullptr, catch_bp, throw_bp, for_expressions);
- SearchFilterSP filter_sp(CreateExceptionSearchFilter());
- const bool hardware = false;
- const bool resolve_indirect_functions = false;
- return target.CreateBreakpoint(filter_sp, exception_resolver_sp, is_internal,
- hardware, resolve_indirect_functions);
-}
-
-void ItaniumABILanguageRuntime::SetExceptionBreakpoints() {
- if (!m_process)
- return;
-
- const bool catch_bp = false;
- const bool throw_bp = true;
- const bool is_internal = true;
- const bool for_expressions = true;
-
- // For the exception breakpoints set by the Expression parser, we'll be a
- // little more aggressive and stop at exception allocation as well.
-
- if (m_cxx_exception_bp_sp) {
- m_cxx_exception_bp_sp->SetEnabled(true);
- } else {
- m_cxx_exception_bp_sp = CreateExceptionBreakpoint(
- catch_bp, throw_bp, for_expressions, is_internal);
- if (m_cxx_exception_bp_sp)
- m_cxx_exception_bp_sp->SetBreakpointKind("c++ exception");
- }
-}
-
-void ItaniumABILanguageRuntime::ClearExceptionBreakpoints() {
- if (!m_process)
- return;
-
- if (m_cxx_exception_bp_sp) {
- m_cxx_exception_bp_sp->SetEnabled(false);
- }
-}
-
-bool ItaniumABILanguageRuntime::ExceptionBreakpointsAreSet() {
- return m_cxx_exception_bp_sp && m_cxx_exception_bp_sp->IsEnabled();
-}
-
-bool ItaniumABILanguageRuntime::ExceptionBreakpointsExplainStop(
- lldb::StopInfoSP stop_reason) {
- if (!m_process)
- return false;
-
- if (!stop_reason || stop_reason->GetStopReason() != eStopReasonBreakpoint)
- return false;
-
- uint64_t break_site_id = stop_reason->GetValue();
- return m_process->GetBreakpointSiteList().StopPointSiteContainsBreakpoint(
- break_site_id, m_cxx_exception_bp_sp->GetID());
}
-ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
- ThreadSP thread_sp) {
+ValueObjectSP ItaniumABIRuntime::GetExceptionObjectForThread(ThreadSP thread_sp,
+ Process &process) {
if (!thread_sp->SafeToCallFunctions())
return {};
TypeSystemClangSP scratch_ts_sp =
- ScratchTypeSystemClang::GetForTarget(m_process->GetTarget());
+ ScratchTypeSystemClang::GetForTarget(process.GetTarget());
if (!scratch_ts_sp)
return {};
@@ -621,11 +381,11 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetStopOthers(true);
- options.SetTimeout(m_process->GetUtilityExpressionTimeout());
+ options.SetTimeout(process.GetUtilityExpressionTimeout());
options.SetTryAllThreads(false);
thread_sp->CalculateExecutionContext(exe_ctx);
- const ModuleList &modules = m_process->GetTarget().GetImages();
+ const ModuleList &modules = process.GetTarget().GetImages();
SymbolContextList contexts;
SymbolContext context;
@@ -639,7 +399,7 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
Status error;
FunctionCaller *function_caller =
- m_process->GetTarget().GetFunctionCallerForLanguage(
+ process.GetTarget().GetFunctionCallerForLanguage(
eLanguageTypeC, voidstar, addr, ValueList(), "caller", error);
ExpressionResults func_call_ret;
@@ -650,30 +410,30 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
return ValueObjectSP();
}
- size_t ptr_size = m_process->GetAddressByteSize();
+ size_t ptr_size = process.GetAddressByteSize();
addr_t result_ptr = results.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
addr_t exception_addr =
- m_process->ReadPointerFromMemory(result_ptr - ptr_size, error);
+ process.ReadPointerFromMemory(result_ptr - ptr_size, error);
if (!error.Success()) {
return ValueObjectSP();
}
lldb_private::formatters::InferiorSizedWord exception_isw(exception_addr,
- *m_process);
+ process);
ValueObjectSP exception = ValueObject::CreateValueObjectFromData(
- "exception", exception_isw.GetAsData(m_process->GetByteOrder()), exe_ctx,
+ "exception", exception_isw.GetAsData(process.GetByteOrder()), exe_ctx,
voidstar);
- ValueObjectSP dyn_exception
- = exception->GetDynamicValue(eDynamicDontRunTarget);
+ ValueObjectSP dyn_exception =
+ exception->GetDynamicValue(eDynamicDontRunTarget);
// If we succeed in making a dynamic value, return that:
if (dyn_exception)
- return dyn_exception;
+ return dyn_exception;
return exception;
}
-TypeAndOrName ItaniumABILanguageRuntime::GetDynamicTypeInfo(
+TypeAndOrName ItaniumABIRuntime::GetDynamicTypeInfo(
const lldb_private::Address &vtable_addr) {
std::lock_guard<std::mutex> locker(m_mutex);
DynamicTypeCache::const_iterator pos = m_dynamic_type_map.find(vtable_addr);
@@ -683,7 +443,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetDynamicTypeInfo(
return pos->second;
}
-void ItaniumABILanguageRuntime::SetDynamicTypeInfo(
+void ItaniumABIRuntime::SetDynamicTypeInfo(
const lldb_private::Address &vtable_addr, const TypeAndOrName &type_info) {
std::lock_guard<std::mutex> locker(m_mutex);
m_dynamic_type_map[vtable_addr] = type_info;
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
new file mode 100644
index 0000000000000..8b8e700c670b5
--- /dev/null
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABIRuntime.h
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABIRUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABIRUNTIME_H
+
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/ValueObject/ValueObject.h"
+
+#include <vector>
+
+namespace lldb_private {
+
+class ItaniumABIRuntime {
+public:
+ ItaniumABIRuntime() = default;
+
+ llvm::Expected<LanguageRuntime::VTableInfo>
+ GetVTableInfo(ValueObject &in_value, bool check_type);
+
+ bool GetDynamicTypeAndAddress(ValueObject &in_value,
+ lldb::DynamicValueType use_dynamic,
+ TypeAndOrName &class_type_or_name,
+ Address &dynamic_address,
+ Value::ValueType &value_type, Process &process);
+
+ void AppendExceptionBreakpointFunctions(std::vector<const char *> &names,
+ bool catch_bp, bool throw_bp,
+ bool for_expressions);
+
+ void AppendExceptionBreakpointFilterModules(FileSpecList &list,
+ const Target &target);
+
+ lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp,
+ Process &process);
+
+private:
+ TypeAndOrName GetTypeInfo(ValueObject &in_value,
+ const LanguageRuntime::VTableInfo &vtable_info,
+ Process &process);
+
+ llvm::Error TypeHasVTable(CompilerType type);
+
+ TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr);
+
+ void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr,
+ const TypeAndOrName &type_info);
+
+ using DynamicTypeCache = std::map<Address, TypeAndOrName>;
+ using VTableInfoCache = std::map<Address, LanguageRuntime::VTableInfo>;
+
+ DynamicTypeCache m_dynamic_type_map;
+ VTableInfoCache m_vtable_info_map;
+ std::mutex m_mutex;
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/Plugins/REPL/Clang/CMakeLists.txt b/lldb/source/Plugins/REPL/Clang/CMakeLists.txt
index 3a7e188d7a29a..45a5e6c89f929 100644
--- a/lldb/source/Plugins/REPL/Clang/CMakeLists.txt
+++ b/lldb/source/Plugins/REPL/Clang/CMakeLists.txt
@@ -11,6 +11,5 @@ add_lldb_library(lldbPluginClangREPL PLUGIN
lldbTarget
lldbUtility
lldbPluginClangCommon
- lldbPluginCPPRuntime
lldbPluginTypeSystemClang
)
More information about the lldb-commits
mailing list