[Lldb-commits] [lldb] [lldb-dap] Support inspecting memory (PR #104317)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 07:04:10 PDT 2024


https://github.com/labath commented:

Sorry for being late to the party. I don't usually follow lldb-dap patches, but the mention of memory reads and windows errors intrigued me.

I don't think this is a good approach to reading memory. You shouldn't trust GetMemoryRegionInfo over ReadMemory. The data returned by the first may not be always there, and (in case of linux, at least), it will return the memory permissions in effect for the debugged application. The debugger can bypass (most of) those restrictions and also access memory that's unreadable to the debugged process.

The method I'd recommend is to call `ReadMemory`, and then if (and only if) it returns a partial (or no) result, consult the memory region info, to find the size of the unreadable region (by querying for the memory region containing the first byte that could not be read).

It's possible you had to do it this way, since before #106532 (and it looks like you started this patch before that), truncated reads did not work (on linux, at least), but it should be possible to do it now.

That should also avoid all of the business with being limited to a single memory region, since crossing from one readable region to another would be handled inside ReadMemory.

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


More information about the lldb-commits mailing list