[Lldb-commits] [lldb] [lldb-dap] Use protocol types for ReadMemory request (PR #144552)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 17 09:49:48 PDT 2025


================
@@ -742,6 +742,42 @@ bool fromJSON(const llvm::json::Value &, DisassembledInstruction &,
               llvm::json::Path);
 llvm::json::Value toJSON(const DisassembledInstruction &);
 
+/// Arguments for `readMemory` request.
+struct ReadMemoryArguments {
+  /// Memory reference to the base location from which data should be read.
+  std::string memoryReference;
+
+  /// Offset (in bytes) to be applied to the reference location before reading
+  /// data. Can be negative.
+  std::optional<int64_t> offset;
+
+  /// Number of bytes to read at the specified location and offset.
+  uint64_t count;
+};
+bool fromJSON(const llvm::json::Value &, ReadMemoryArguments &,
+              llvm::json::Path);
+
+/// Response to `readMemory` request.
+struct ReadMemoryResponse {
+  /// The address of the first byte of data returned.
+  /// Treated as a hex value if prefixed with `0x`, or as a decimal value
+  /// otherwise.
+  std::string address;
+
+  /// The number of unreadable bytes encountered after the last successfully
+  /// read byte.
+  /// This can be used to determine the number of bytes that should be skipped
+  /// before a subsequent `readMemory` request succeeds.
+  std::optional<uint64_t> unreadableBytes;
+
+  /// The bytes read from memory, encoded using base64. If the decoded length
+  /// of `data` is less than the requested `count` in the original `readMemory`
+  /// request, and `unreadableBytes` is zero or omitted, then the client should
+  /// assume it's reached the end of readable memory.
+  std::optional<std::string> data;
----------------
ashgti wrote:

Should we have `data` be a `std::vector<std::byte> data;` instead of a string? Then we can do the hex encoding in the fromJSON/toJSON functions.

https://github.com/llvm/llvm-project/pull/144552


More information about the lldb-commits mailing list