#ifndef V8_DEBUG_WASM_GDB_SERVER_GDB_REMOTE_UTIL_H_
#define V8_DEBUG_WASM_GDB_SERVER_GDB_REMOTE_UTIL_H_
#include <string>
#include <vector>
#include "src/flags/flags.h"
#include "src/utils/utils.h"
namespace v8 {
namespace internal {
namespace wasm {
namespace gdb_server {
#define TRACE_GDB_REMOTE(...) \
do { \
if (v8_flags.trace_wasm_gdb_remote) PrintF("[gdb-remote] " __VA_ARGS__); \
} while (false)
void UInt8ToHex(uint8_t byte, char chars[2]);
bool HexToUInt8(const char chars[2], uint8_t* byte);
bool NibbleToUInt8(char ch, uint8_t* byte);
std::vector<std::string> V8_EXPORT_PRIVATE StringSplit(const std::string& instr,
const char* delim);
std::string Mem2Hex(const uint8_t* mem, size_t count);
std::string Mem2Hex(const std::string& str);
class wasm_addr_t {
public:
wasm_addr_t(uint32_t module_id, uint32_t offset)
: module_id_(module_id), offset_(offset) {}
explicit wasm_addr_t(uint64_t address)
: module_id_(address >> 32), offset_(address & 0xffffffff) {}
inline uint32_t ModuleId() const { return module_id_; }
inline uint32_t Offset() const { return offset_; }
inline operator uint64_t() const {
return static_cast<uint64_t>(module_id_) << 32 | offset_;
}
private:
uint32_t module_id_;
uint32_t offset_;
};
}
}
}
}
#endif