[Lldb-commits] [lldb] r330500 - FreeBSD: propagate error to user if memory access fails

Ed Maste via lldb-commits lldb-commits at lists.llvm.org
Sat Apr 21 04:23:56 PDT 2018


Author: emaste
Date: Sat Apr 21 04:23:56 2018
New Revision: 330500

URL: http://llvm.org/viewvc/llvm-project?rev=330500&view=rev
Log:
FreeBSD: propagate error to user if memory access fails

Previously, an attempt to read an unreadable address reported zeros.
Now, if DoReadMemory or DoWriteMemory encounters error then return 0
(bytes read or written) so that the error is reported to the user.

llvm.org/pr37190

Modified:
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=330500&r1=330499&r2=330500&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Sat Apr 21 04:23:56 2018
@@ -159,8 +159,10 @@ static size_t DoReadMemory(lldb::pid_t p
   pi_desc.piod_addr = buf;
   pi_desc.piod_len = size;
 
-  if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0)
+  if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0) {
     error.SetErrorToErrno();
+    return 0;
+  }
   return pi_desc.piod_len;
 }
 
@@ -173,8 +175,10 @@ static size_t DoWriteMemory(lldb::pid_t
   pi_desc.piod_addr = (void *)buf;
   pi_desc.piod_len = size;
 
-  if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0)
+  if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0) {
     error.SetErrorToErrno();
+    return 0;
+  }
   return pi_desc.piod_len;
 }
 




More information about the lldb-commits mailing list