DebugServer2
Loading...
Searching...
No Matches
Process.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/Host/Darwin/PTrace.h"
14#include "DebugServer2/Target/Darwin/MachOProcess.h"
15
16namespace ds2 {
17namespace Target {
18namespace Darwin {
19
21protected:
23
24protected:
25 ErrorCode attach(int waitStatus) override;
26
27public:
28 ErrorCode terminate() override;
29
30public:
31 ErrorCode suspend() override;
32
33public:
34 ErrorCode getMemoryRegionInfo(Address const &address,
35 MemoryRegionInfo &info) override;
36
37public:
38 ErrorCode allocateMemory(size_t size, uint32_t protection,
39 uint64_t *address) override;
40 ErrorCode deallocateMemory(uint64_t address, size_t size) override;
41
42protected:
43 // Injects `code` at the current thread's PC, executes it to completion,
44 // and restores the original code/registers. Darwin's ptrace cannot read
45 // or write registers/memory (see Host::Darwin::PTrace), so this goes
46 // through Mach for state/memory access instead of POSIX::PTrace::execute.
47 ErrorCode executeCode(ByteVector const &code, uint64_t &result);
48
49public:
50 ErrorCode readString(Address const &address, std::string &str, size_t length,
51 size_t *count = nullptr) override;
52 ErrorCode readMemory(Address const &address, void *data, size_t length,
53 size_t *count = nullptr) override;
54 ErrorCode writeMemory(Address const &address, void const *data, size_t length,
55 size_t *count = nullptr) override;
56
57public:
58 ErrorCode wait() override;
59
60public:
61 Host::POSIX::PTrace &ptrace() const override;
62
63protected:
64 ErrorCode updateInfo() override;
65 ErrorCode updateAuxiliaryVector() override;
66
67protected:
68 friend class Thread;
69 ErrorCode readCPUState(ThreadId tid, Architecture::CPUState &state,
70 uint32_t flags = 0);
71 ErrorCode writeCPUState(ThreadId tid, Architecture::CPUState const &state,
72 uint32_t flags = 0);
73
74public:
75 ErrorCode afterResume() override;
76
77protected:
78 friend class POSIX::Process;
79};
80} // namespace Darwin
81} // namespace Target
82} // namespace ds2
Definition Types.h:95
Definition PTrace.h:22
Definition PTrace.h:28
Definition MachOProcess.h:20
Definition Process.h:20
Definition Thread.h:26
Definition Process.h:23
Definition Types.h:361