================
@@ -0,0 +1,135 @@
+// This file comes from https://reviews.llvm.org/D78978.
+// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/).
+
+//===-- ProcessWasm.h -------------------------------------------*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H
+
+#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "lldb/Target/RegisterContext.h"
+
+namespace lldb_private {
+namespace wasm {
+
+// Each WebAssembly module has separated address spaces for Code and Memory.
+// A WebAssembly module also has a Data section which, when the module is
+// loaded, gets mapped into a region in the module Memory.
+// For the purpose of debugging, we can represent all these separated 32-bit
+// address spaces with a single virtual 64-bit address space.
+//
+// Struct wasm_addr_t provides this encoding using bitfields
+//
+enum WasmAddressType {
+  Memory = 0x00,
+  Object = 0x01,
+  Invalid = 0x03
+};
+struct wasm_addr_t {
+  uint64_t offset : 32;
+  uint64_t module_id : 30;
+  uint64_t type : 2;
+
+  wasm_addr_t(lldb::addr_t addr)
+      : type(addr >> 62), module_id((addr & 0x00ffffff00000000) >> 32),
+        offset(addr & 0x00000000ffffffff) {}
+
+  wasm_addr_t(WasmAddressType type_, uint32_t module_id_, uint32_t offset_)
+      : type(type_), module_id(module_id_), offset(offset_) {}
+
+  WasmAddressType GetType() { return static_cast<WasmAddressType>(type); }
+  operator lldb::addr_t() { return *(uint64_t *)this; }
+};
+
+/// ProcessWasm provides the access to the Wasm program state
+///  retrieved from the Wasm engine.
----------------
JDevlieghere wrote:

spurious space

https://github.com/llvm/llvm-project/pull/76683
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to