LLDB mainline
PlatformEmscripten.cpp
Go to the documentation of this file.
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
10
12#include "lldb/Host/HostInfo.h"
14#include "lldb/Utility/Log.h"
15
16using namespace lldb;
17using namespace lldb_private;
19
21
22static uint32_t g_initialize_count = 0;
23
25 const ArchSpec *arch) {
27 LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
28 arch ? arch->GetArchitectureName() : "<null>",
29 arch ? arch->GetTriple().getTriple() : "<null>");
30
31 bool create =
32 force || (arch && arch->IsValid() && arch->GetTriple().isOSEmscripten());
33 LLDB_LOG(log, "create = {0}", create);
34 return create ? PlatformSP(new PlatformEmscripten(false)) : PlatformSP();
35}
36
38 if (is_host)
39 return "Local Emscripten user platform plug-in.";
40 return "Remote Emscripten user platform plug-in.";
41}
42
45
46 if (g_initialize_count++ == 0) {
47#if defined(__EMSCRIPTEN__)
48 PlatformSP platform_sp(new PlatformEmscripten(true));
49 platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
50 Platform::SetHostPlatform(platform_sp);
51#endif
55 }
56}
57
64
66 if (is_host)
67 m_supported_architectures.push_back(HostInfo::GetArchitecture());
68 else
70 {llvm::Triple::wasm32, llvm::Triple::wasm64}, llvm::Triple::Emscripten);
71}
72
74 const ArchSpec &process_host_arch) {
76 return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch);
78}
79
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:375
static uint32_t g_initialize_count
#define LLDB_PLUGIN_DEFINE(PluginName)
PlatformPOSIX(bool is_host)
Default Constructor.
An architecture specification class.
Definition ArchSpec.h:32
static void Terminate()
Definition Platform.cpp:152
static void SetHostPlatform(const lldb::PlatformSP &platform_sp)
Definition Platform.cpp:159
static void Initialize()
Definition Platform.cpp:150
static std::vector< ArchSpec > CreateArchList(llvm::ArrayRef< llvm::Triple::ArchType > archs, llvm::Triple::OSType os)
Create a list of ArchSpecs with the given OS and a architectures.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static llvm::StringRef GetPluginDescriptionStatic(bool is_host)
bool CanDebugProcess() override
Not all platforms will support debugging a process by spawning somehow halted for a debugger (specifi...
std::vector< ArchSpec > GetSupportedArchitectures(const ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
static llvm::StringRef GetPluginNameStatic(bool is_host)
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
std::shared_ptr< lldb_private::Platform > PlatformSP