Skip to content

Commit 19df051

Browse files
Merge pull request #11260 from adrian-prantl/wasm
[LLDB] Add Swift support for WebAssembly
2 parents 9bed4e5 + 2842260 commit 19df051

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ LLDBMemoryReader::getSymbolAddress(const std::string &name) {
144144
load_addr, swift::remote::RemoteAddress::DefaultAddressSpace);
145145
}
146146

147-
static std::unique_ptr<swift::SwiftObjectFileFormat>
147+
std::unique_ptr<swift::SwiftObjectFileFormat>
148148
GetSwiftObjectFileFormat(llvm::Triple::ObjectFormatType obj_format_type) {
149149
std::unique_ptr<swift::SwiftObjectFileFormat> obj_file_format;
150150
switch (obj_format_type) {
@@ -157,6 +157,9 @@ GetSwiftObjectFileFormat(llvm::Triple::ObjectFormatType obj_format_type) {
157157
case llvm::Triple::COFF:
158158
obj_file_format = std::make_unique<swift::SwiftObjectFileFormatCOFF>();
159159
break;
160+
case llvm::Triple::Wasm:
161+
obj_file_format = std::make_unique<swift::SwiftObjectFileFormatWasm>();
162+
break;
160163
default:
161164
LLDB_LOG(GetLog(LLDBLog::Types), "Could not determine swift reflection "
162165
"section names for object format type");

lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include "llvm/Support/Memory.h"
2525

2626
namespace lldb_private {
27+
28+
std::unique_ptr<swift::SwiftObjectFileFormat>
29+
GetSwiftObjectFileFormat(llvm::Triple::ObjectFormatType obj_format_type);
30+
2731
class LLDBMemoryReader;
2832
class MemoryReaderLocalBufferHolder {
2933
public:

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,6 @@ CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp, bool thro
295295
return resolver_sp;
296296
}
297297

298-
static std::unique_ptr<swift::SwiftObjectFileFormat>
299-
GetObjectFileFormat(llvm::Triple::ObjectFormatType obj_format_type) {
300-
std::unique_ptr<swift::SwiftObjectFileFormat> obj_file_format;
301-
switch (obj_format_type) {
302-
case llvm::Triple::MachO:
303-
obj_file_format = std::make_unique<swift::SwiftObjectFileFormatMachO>();
304-
break;
305-
case llvm::Triple::ELF:
306-
obj_file_format = std::make_unique<swift::SwiftObjectFileFormatELF>();
307-
break;
308-
case llvm::Triple::COFF:
309-
obj_file_format = std::make_unique<swift::SwiftObjectFileFormatCOFF>();
310-
break;
311-
default:
312-
if (Log *log = GetLog(LLDBLog::Types))
313-
log->Printf("%s: Could not find out swift reflection section names for "
314-
"object format type.",
315-
__FUNCTION__);
316-
}
317-
return obj_file_format;
318-
}
319-
320298
static bool HasReflectionInfo(ObjectFile *obj_file) {
321299
if (!obj_file)
322300
return false;
@@ -332,7 +310,7 @@ static bool HasReflectionInfo(ObjectFile *obj_file) {
332310

333311
const auto obj_format_type =
334312
obj_file->GetArchitecture().GetTriple().getObjectFormat();
335-
auto obj_file_format_up = GetObjectFileFormat(obj_format_type);
313+
auto obj_file_format_up = GetSwiftObjectFileFormat(obj_format_type);
336314
if (!obj_file_format_up)
337315
return false;
338316

@@ -561,7 +539,7 @@ bool SwiftLanguageRuntime::AddJitObjectFileToReflectionContext(
561539
llvm::SmallVector<llvm::StringRef, 1> likely_module_names) {
562540
assert(obj_file.GetType() == ObjectFile::eTypeJIT &&
563541
"Not a JIT object file!");
564-
auto obj_file_format = GetObjectFileFormat(obj_format_type);
542+
auto obj_file_format = GetSwiftObjectFileFormat(obj_format_type);
565543

566544
if (!obj_file_format)
567545
return false;
@@ -607,7 +585,7 @@ std::optional<uint32_t> SwiftLanguageRuntime::AddObjectFileToReflectionContext(
607585
auto obj_format_type =
608586
module->GetArchitecture().GetTriple().getObjectFormat();
609587

610-
auto obj_file_format = GetObjectFileFormat(obj_format_type);
588+
auto obj_file_format = GetSwiftObjectFileFormat(obj_format_type);
611589
if (!obj_file_format)
612590
return {};
613591

0 commit comments

Comments
 (0)