|
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 (llvm::ArrayRef< uint8_t > data) |
| Checks whether the data buffer starts with a valid Wasm module header. | |
| static llvm::Expected< uint32_t > | ParseImports (DataExtractor &import_data) |
| static llvm::Expected< uint32_t > | GetFunctionCodeOffset (DataExtractor &data, lldb::offset_t offset) |
| Get the offset in the function to the first instruction. | |
| static llvm::Expected< std::vector< WasmFunction > > | ParseFunctions (DataExtractor &data) |
| static llvm::Expected< std::vector< WasmSegment > > | ParseData (DataExtractor &data) |
| static llvm::Expected< uint64_t > | ParseMemoryMinSize (DataExtractor &data) |
| Parse the minimum size in bytes of the module's first linear memory. | |
| static llvm::Expected< std::vector< Symbol > > | ParseNames (SectionSP code_section_sp, DataExtractor &name_data, const std::vector< WasmFunction > &functions, std::vector< WasmSegment > &segments, uint32_t num_imported_functions) |
| static SectionType | GetSectionTypeFromName (llvm::StringRef Name) |
Variables | |
| static const uint32_t | kWasmHeaderSize |
|
static |
Get the offset in the function to the first instruction.
Definition at line 366 of file ObjectFileWasm.cpp.
References lldb_private::DataExtractor::GetU8(), and lldb_private::DataExtractor::GetULEB128().
Referenced by ParseFunctions().
|
static |
Definition at line 609 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(), ParseImports(), ParseMemoryMinSize(), 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(), ParseImports(), and ParseNames().
|
static |
Definition at line 435 of file ObjectFileWasm.cpp.
References WasmSegment::Active, GetULEB32(), GetWasmOffsetFromInitExpr(), WasmSegment::Passive, and segment::size.
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Definition at line 382 of file ObjectFileWasm.cpp.
References GetFunctionCodeOffset(), and GetULEB32().
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Definition at line 324 of file ObjectFileWasm.cpp.
References lldb_private::DataExtractor::GetAsLLVM(), GetULEB32(), and GetWasmString().
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Parse the minimum size in bytes of the module's first linear memory.
This is the memory guaranteed to exist at instantiation, and so the upper bound of the static data region.
Definition at line 492 of file ObjectFileWasm.cpp.
References lldb_private::DataExtractor::GetU8(), and GetULEB32().
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections().
|
static |
Definition at line 512 of file ObjectFileWasm.cpp.
References WasmFunction::code_offset, lldb::eSymbolTypeCode, lldb_private::DataExtractor::GetAsLLVM(), GetULEB32(), GetWasmString(), WasmFunction::section_offset, and WasmFunction::size.
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().