LLDB mainline
|
#include "ObjectFileWasm.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Support/CheckedArithmetic.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Format.h"
#include <optional>
Go to the source code of this file.
Classes | |
struct | WasmFunction |
struct | WasmSegment |
Functions | |
static llvm::Expected< uint32_t > | GetULEB32 (DataExtractor &data, lldb::offset_t &offset) |
Helper to read a 32-bit ULEB using LLDB's DataExtractor. | |
static llvm::Expected< uint32_t > | GetULEB32 (llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) |
Helper to read a 32-bit ULEB using LLVM's DataExtractor. | |
static llvm::Expected< std::string > | GetWasmString (llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) |
Helper to read a Wasm string, whcih is encoded as a vector of UTF-8 codes. | |
static lldb::offset_t | GetWasmOffsetFromInitExpr (DataExtractor &data, lldb::offset_t &offset) |
An "init expr" refers to a constant expression used to determine the initial value of certain elements within a module during instantiation. | |
static bool | ValidateModuleHeader (const DataBufferSP &data_sp) |
Checks whether the data buffer starts with a valid Wasm module header. | |
static llvm::Expected< std::vector< WasmFunction > > | ParseFunctions (DataExtractor &data) |
static llvm::Expected< std::vector< WasmSegment > > | ParseData (DataExtractor &data) |
static llvm::Expected< std::vector< Symbol > > | ParseNames (SectionSP code_section_sp, DataExtractor &name_data, const std::vector< WasmFunction > &functions, std::vector< WasmSegment > &segments) |
static SectionType | GetSectionTypeFromName (llvm::StringRef Name) |
Variables | |
static const uint32_t | kWasmHeaderSize |
|
static |
Definition at line 491 of file ObjectFileWasm.cpp.
References lldb::eSectionTypeOther, lldb::eSectionTypeWasmName, and lldb_private::ObjectFile::GetDWARFSectionTypeFromName().
|
inlinestatic |
Helper to read a 32-bit ULEB using LLDB's DataExtractor.
Definition at line 40 of file ObjectFileWasm.cpp.
References GetULEB32().
Referenced by GetULEB32(), GetWasmString(), ParseData(), ParseFunctions(), and ParseNames().
|
inlinestatic |
Helper to read a 32-bit ULEB using LLVM's DataExtractor.
Definition at line 50 of file ObjectFileWasm.cpp.
|
static |
An "init expr" refers to a constant expression used to determine the initial value of certain elements within a module during instantiation.
These expressions are restricted to operations that can be evaluated at module instantiation time. Currently we only support simple constant opcodes.
Definition at line 78 of file ObjectFileWasm.cpp.
References lldb_private::DataExtractor::GetFloat(), lldb_private::DataExtractor::GetSLEB128(), lldb_private::DataExtractor::GetU8(), lldb_private::DataExtractor::GetULEB128(), and LLDB_INVALID_OFFSET.
Referenced by ParseData().
|
inlinestatic |
Helper to read a Wasm string, whcih is encoded as a vector of UTF-8 codes.
Definition at line 61 of file ObjectFileWasm.cpp.
References GetULEB32().
Referenced by lldb_private::wasm::ObjectFileWasm::DecodeNextSection(), lldb_private::wasm::ObjectFileWasm::GetExternalDebugInfoFileSpec(), and ParseNames().
|
static |
Definition at line 356 of file ObjectFileWasm.cpp.
References WasmSegment::Active, GetULEB32(), GetWasmOffsetFromInitExpr(), WasmSegment::init_expr_offset, WasmSegment::memory_index, WasmSegment::Passive, WasmSegment::section_offset, WasmSegment::size, and WasmSegment::type.
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Definition at line 311 of file ObjectFileWasm.cpp.
References GetULEB32().
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Definition at line 411 of file ObjectFileWasm.cpp.
References lldb::eSymbolTypeCode, lldb_private::DataExtractor::GetAsLLVM(), GetULEB32(), and GetWasmString().
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Checks whether the data buffer starts with a valid Wasm module header.
Definition at line 116 of file ObjectFileWasm.cpp.
References kWasmHeaderSize.
Referenced by lldb_private::wasm::ObjectFileWasm::CreateInstance(), lldb_private::wasm::ObjectFileWasm::CreateMemoryInstance(), and lldb_private::wasm::ObjectFileWasm::GetModuleSpecifications().
|
static |
Definition at line 36 of file ObjectFileWasm.cpp.
Referenced by lldb_private::wasm::ObjectFileWasm::DecodeSections(), and ValidateModuleHeader().