================ @@ -16,12 +15,61 @@ namespace lldb_dap { +static llvm::Expected<protocol::DataBreakpointInfoResponseBody> +HandleDataBreakpointBytes(DAP &dap, + const protocol::DataBreakpointInfoArguments &args) { + llvm::StringRef address = args.name; + + unsigned long long load_addr = LLDB_INVALID_ADDRESS; + if (llvm::getAsUnsignedInteger(address, 0, load_addr)) { + return llvm::make_error<DAPError>(llvm::formatv("invalid address"), + llvm::inconvertibleErrorCode(), false); + } + + lldb::SBAddress sb_addr(load_addr, dap.target); + if (!sb_addr.IsValid()) { + return llvm::make_error<DAPError>( + llvm::formatv("address {:x} does not exist in the debuggee", load_addr), + llvm::inconvertibleErrorCode(), false); + } + + const uint32_t byte_size = + args.bytes.value_or(dap.target.GetAddressByteSize()); + + protocol::DataBreakpointInfoResponseBody response; + response.dataId = llvm::formatv("{:x-}/{}", load_addr, byte_size); + + lldb::SBMemoryRegionInfo region; + lldb::SBError err = + dap.target.GetProcess().GetMemoryRegionInfo(load_addr, region); + // Only lldb-server supports "qMemoryRegionInfo". So, don't fail this ---------------- DavidSpickett wrote:
This API can return information about regions that are not mapped, you can check that with: ``` /// Check if this memory address is mapped into the process address /// space. /// /// \return /// true if this memory address is in the process address space. bool IsMapped(); ``` Though, I would assume an unmapped region would be neither readable nor writeable, so it may not be relevant whether it's mapped or not. In theory memory can be mapped and not readable, though I don't know how Linux presents it. Execute only memory you can fetch from but not load from. If you were using lldb-dap with an embedded target, it could be a concern. I don't know if any of that is a concern for this code specifically though. https://github.com/llvm/llvm-project/pull/141122 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits