LLDB mainline
ArchitectureWasm.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
11#include "lldb/Symbol/Symbol.h"
14
15using namespace lldb_private;
16using namespace lldb;
17
19
22 "WebAssembly-specific algorithms",
24}
25
29
30std::unique_ptr<Architecture> ArchitectureWasm::Create(const ArchSpec &arch) {
31 llvm::Triple::ArchType machine = arch.GetMachine();
32 if (machine != llvm::Triple::wasm32 && machine != llvm::Triple::wasm64)
33 return nullptr;
34 return std::unique_ptr<Architecture>(new ArchitectureWasm());
35}
36
38 // The header is recorded as the symbol's prologue.
40 addr.CalculateSymbolContext(&sc, eSymbolContextSymbol);
41 if (!sc.symbol)
42 return addr;
43
44 const uint32_t header_size = sc.symbol->GetPrologueByteSize();
45 if (!header_size)
46 return addr;
47
48 const addr_t symbol_addr = sc.symbol->GetAddress().GetFileAddress();
49 const addr_t this_addr = addr.GetFileAddress();
50 if (this_addr < symbol_addr || this_addr >= symbol_addr + header_size)
51 return addr;
52
53 addr.Slide(symbol_addr + header_size - this_addr);
54 return addr;
55}
#define LLDB_PLUGIN_DEFINE(PluginName)
A section + offset based address class.
Definition Address.h:62
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
Definition Address.cpp:819
bool Slide(int64_t offset)
Definition Address.h:446
lldb::addr_t GetFileAddress() const
Get the file address.
Definition Address.cpp:281
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:881
Address SkipFunctionHeader(Address addr) const override
A WebAssembly function begins with a local variable declaration header that is part of the function b...
static std::unique_ptr< Architecture > Create(const ArchSpec &arch)
static llvm::StringRef GetPluginNameStatic()
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
Defines a symbol context baton that can be handed other debug core functions.
Symbol * symbol
The Symbol for a given query.
Address GetAddress() const
Definition Symbol.h:89
uint32_t GetPrologueByteSize()
Definition Symbol.cpp:313
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80