| 32 | namespace crashpad { |
| 33 | |
| 34 | ProcessMemoryLinux::ProcessMemoryLinux(PtraceConnection* connection) |
| 35 | : ProcessMemory(), mem_fd_(), ignore_top_byte_(false) { |
| 36 | #if defined(ARCH_CPU_ARM_FAMILY) |
| 37 | if (connection->Is64Bit()) { |
| 38 | ignore_top_byte_ = true; |
| 39 | } |
| 40 | #endif // ARCH_CPU_ARM_FAMILY |
| 41 | |
| 42 | char path[32]; |
| 43 | snprintf(path, sizeof(path), "/proc/%d/mem", connection->GetProcessID()); |
| 44 | mem_fd_.reset(HANDLE_EINTR(open(path, O_RDONLY | O_NOCTTY | O_CLOEXEC))); |
| 45 | if (mem_fd_.is_valid()) { |
| 46 | read_up_to_ = [this](VMAddress address, size_t size, void* buffer) { |
| 47 | ssize_t bytes_read = |
| 48 | HANDLE_EINTR(pread64(mem_fd_.get(), buffer, size, address)); |
| 49 | if (bytes_read < 0) { |
| 50 | PLOG(ERROR) << "pread64"; |
| 51 | } |
| 52 | return bytes_read; |
| 53 | }; |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | read_up_to_ = std::bind(&PtraceConnection::ReadUpTo, |
| 58 | connection, |
| 59 | std::placeholders::_1, |
| 60 | std::placeholders::_2, |
| 61 | std::placeholders::_3); |
| 62 | } |
| 63 | |
| 64 | ProcessMemoryLinux::~ProcessMemoryLinux() {} |
| 65 |
nothing calls this directly
no test coverage detected