[Lldb-commits] [PATCH] D62715: [NativeProcessLinux] Reuse memory read by process_vm_readv before calling ptrace

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 31 04:39:54 PDT 2019


labath added a comment.

Thinking about tests, do you know of any way to create memory which is readable by ptrace, but it is not accessible via process_vm_readv ? I know that latest android phones have memory like that, but I believe this depends on selinux or some other mechanism which cannot be reproduced in a test.

If we can't do anything like that, we should at least have an lldb-server test that performs a read (`$m` packet) crossing page boundaries, where one of the pages is unmapped. Probably the easiest way to guarantee that a particular page will be unmapped is to first `mmap` 2 pages worth of memory, and then `munmap` one of them.



================
Comment at: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:1457
 
-    bytes_read = process_vm_readv(pid, &local_iov, 1, &remote_iov, 1, 0);
-    const bool success = bytes_read == size;
+    auto vm_bytes_read =
+        process_vm_readv(pid, &local_iov, 1, &remote_iov, 1, 0);
----------------
llvm's policy is to *not* "almost always use auto".  And it's nice to know whether this returns size_t, ssize_t, or something else without looking up the documentation.


================
Comment at: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:1467
+      if (!success) {
+        addr = reinterpret_cast<addr_t>(reinterpret_cast<char *>(addr) +
+                                        vm_bytes_read);
----------------
`addr += vm_bytes_read` ?
Since this is talking about addresses in the other process, I can't imagine that casting to a `char *` is going to make this more "correct" in any way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62715/new/

https://reviews.llvm.org/D62715





More information about the lldb-commits mailing list