Skip to content

Commit 7d0500a

Browse files
committed
[LLDB] Add empty Microsoft ABI language runtime
1 parent 5c73fed commit 7d0500a

File tree

7 files changed

+157
-4
lines changed

7 files changed

+157
-4
lines changed

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ add_lldb_library(lldbPluginCPPRuntime
1111
)
1212

1313
add_subdirectory(ItaniumABI)
14-
#add_subdirectory(MicrosoftABI)
14+
add_subdirectory(MicrosoftABI)

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,10 @@ bool CPPLanguageRuntime::IsSymbolARuntimeThunk(const Symbol &symbol) {
491491
return mangled_name.starts_with("_ZTh") || mangled_name.starts_with("_ZTv") ||
492492
mangled_name.starts_with("_ZTc");
493493
}
494+
495+
bool CPPLanguageRuntime::ShouldUseMicrosoftABI(Process *process) {
496+
return process->GetTarget()
497+
.GetArchitecture()
498+
.GetTriple()
499+
.isWindowsMSVCEnvironment();
500+
}

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class CPPLanguageRuntime : public LanguageRuntime {
8181

8282
bool IsSymbolARuntimeThunk(const Symbol &symbol) override;
8383

84+
static bool ShouldUseMicrosoftABI(Process *process);
85+
8486
protected:
8587
// Classes that inherit from CPPLanguageRuntime can see and modify these
8688
CPPLanguageRuntime(Process *process);

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ TypeAndOrName ItaniumABILanguageRuntime::FixUpDynamicType(
397397
LanguageRuntime *
398398
ItaniumABILanguageRuntime::CreateInstance(Process *process,
399399
lldb::LanguageType language) {
400-
// FIXME: We have to check the process and make sure we actually know that
401-
// this process supports
402-
// the Itanium ABI.
400+
if (ShouldUseMicrosoftABI(process))
401+
return nullptr;
402+
403403
if (language == eLanguageTypeC_plus_plus ||
404404
language == eLanguageTypeC_plus_plus_03 ||
405405
language == eLanguageTypeC_plus_plus_11 ||
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_lldb_library(lldbPluginCXXMicrosoftABI PLUGIN
2+
MicrosoftABILanguageRuntime.cpp
3+
4+
LINK_LIBS
5+
lldbPluginCPPRuntime
6+
)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "MicrosoftABILanguageRuntime.h"
10+
11+
#include "lldb/Core/PluginManager.h"
12+
#include "lldb/Target/Process.h"
13+
14+
using namespace lldb;
15+
using namespace lldb_private;
16+
17+
LLDB_PLUGIN_DEFINE_ADV(MicrosoftABILanguageRuntime, CXXMicrosoftABI)
18+
19+
char MicrosoftABILanguageRuntime::ID = 0;
20+
21+
void MicrosoftABILanguageRuntime::Initialize() {
22+
PluginManager::RegisterPlugin(GetPluginNameStatic(),
23+
"Microsoft ABI for the C++ language",
24+
CreateInstance);
25+
}
26+
27+
void MicrosoftABILanguageRuntime::Terminate() {
28+
PluginManager::UnregisterPlugin(CreateInstance);
29+
}
30+
31+
LanguageRuntime *
32+
MicrosoftABILanguageRuntime::CreateInstance(Process *process,
33+
lldb::LanguageType language) {
34+
if (!ShouldUseMicrosoftABI(process))
35+
return nullptr;
36+
37+
if (!(language == eLanguageTypeC_plus_plus ||
38+
language == eLanguageTypeC_plus_plus_03 ||
39+
language == eLanguageTypeC_plus_plus_11 ||
40+
language == eLanguageTypeC_plus_plus_14))
41+
return nullptr;
42+
43+
return new MicrosoftABILanguageRuntime(process);
44+
}
45+
46+
llvm::Expected<LanguageRuntime::VTableInfo>
47+
MicrosoftABILanguageRuntime::GetVTableInfo(ValueObject &in_value,
48+
bool check_type) {
49+
return llvm::createStringError("Not implemented");
50+
}
51+
52+
bool MicrosoftABILanguageRuntime::GetDynamicTypeAndAddress(
53+
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
54+
TypeAndOrName &class_type_or_name, Address &address,
55+
Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
56+
return false;
57+
}
58+
59+
TypeAndOrName MicrosoftABILanguageRuntime::FixUpDynamicType(
60+
const TypeAndOrName &type_and_or_name, ValueObject &static_value) {
61+
return type_and_or_name;
62+
}
63+
64+
bool MicrosoftABILanguageRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
65+
return false;
66+
}
67+
68+
lldb::BreakpointResolverSP MicrosoftABILanguageRuntime::CreateExceptionResolver(
69+
const lldb::BreakpointSP &bkpt, bool catch_bp, bool throw_bp) {
70+
return nullptr;
71+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_MICROSOFTABI_MICROSOFTABILANGUAGERUNTIME_H
10+
#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_MICROSOFTABI_MICROSOFTABILANGUAGERUNTIME_H
11+
12+
#include "lldb/Core/Value.h"
13+
#include "lldb/Symbol/Type.h"
14+
#include "lldb/Target/LanguageRuntime.h"
15+
16+
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
17+
18+
namespace lldb_private {
19+
20+
class MicrosoftABILanguageRuntime : public CPPLanguageRuntime {
21+
public:
22+
static void Initialize();
23+
24+
static void Terminate();
25+
26+
static lldb_private::LanguageRuntime *
27+
CreateInstance(Process *process, lldb::LanguageType language);
28+
29+
static llvm::StringRef GetPluginNameStatic() { return "microsoft-abi"; }
30+
31+
static char ID;
32+
33+
bool isA(const void *ClassID) const override {
34+
return ClassID == &ID || CPPLanguageRuntime::isA(ClassID);
35+
}
36+
37+
static bool classof(const LanguageRuntime *runtime) {
38+
return runtime->isA(&ID);
39+
}
40+
41+
llvm::Expected<LanguageRuntime::VTableInfo>
42+
GetVTableInfo(ValueObject &in_value, bool check_type) override;
43+
44+
bool GetDynamicTypeAndAddress(ValueObject &in_value,
45+
lldb::DynamicValueType use_dynamic,
46+
TypeAndOrName &class_type_or_name,
47+
Address &address, Value::ValueType &value_type,
48+
llvm::ArrayRef<uint8_t> &local_buffer) override;
49+
50+
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
51+
ValueObject &static_value) override;
52+
53+
bool CouldHaveDynamicValue(ValueObject &in_value) override;
54+
55+
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
56+
57+
lldb::BreakpointResolverSP
58+
CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp,
59+
bool throw_bp) override;
60+
61+
private:
62+
MicrosoftABILanguageRuntime(Process *process) : CPPLanguageRuntime(process) {}
63+
};
64+
65+
} // namespace lldb_private
66+
67+
#endif

0 commit comments

Comments
 (0)