[Lldb-commits] [lldb] r359572 - [lldb] [Process/NetBSD] Fix handling piod_len from PT_IO calls
Michal Gorny via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 30 09:30:32 PDT 2019
Author: mgorny
Date: Tue Apr 30 09:30:32 2019
New Revision: 359572
URL: http://llvm.org/viewvc/llvm-project?rev=359572&view=rev
Log:
[lldb] [Process/NetBSD] Fix handling piod_len from PT_IO calls
Fix bugs in piod_len return value processing in ReadMemory()
and WriteMemory() methods. In particular, add support for piod_len == 0
indicating EOF, and fix summing bytes_read/bytes_written when PT_IO does
partial reads/writes.
The EOF condition could happen if LLDB attempts to read past
vm.maxaddress, e.g. as a result of RBP containing large (invalid) value.
Previously, the 0 return caused the function to retry reading via PT_IO
indefinitely, effectively deadlooping lldb-server.
Partial reads probably did not occur in practice, yet they would cause
ReadMemory() to return incorrect bytes_read and/or overwrite previously
read data.
WriteMemory() suffered from analoguous problems.
Differential Revision: https://reviews.llvm.org/D61310
Modified:
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp?rev=359572&r1=359571&r2=359572&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Tue Apr 30 09:30:32 2019
@@ -695,10 +695,10 @@ Status NativeProcessNetBSD::ReadMemory(l
io.piod_addr = dst + bytes_read;
Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
- if (error.Fail())
+ if (error.Fail() || io.piod_len == 0)
return error;
- bytes_read = io.piod_len;
+ bytes_read += io.piod_len;
io.piod_len = size - bytes_read;
} while (bytes_read < size);
@@ -723,10 +723,10 @@ Status NativeProcessNetBSD::WriteMemory(
io.piod_offs = (void *)(addr + bytes_written);
Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
- if (error.Fail())
+ if (error.Fail() || io.piod_len == 0)
return error;
- bytes_written = io.piod_len;
+ bytes_written += io.piod_len;
io.piod_len = size - bytes_written;
} while (bytes_written < size);
More information about the lldb-commits
mailing list