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/POSIX/PTrace.h"
14#include "DebugServer2/Host/ProcessSpawner.h"
15#include "DebugServer2/Target/ProcessBase.h"
16
17#include <mutex>
18
19namespace ds2 {
20namespace Target {
21namespace POSIX {
22
24protected:
25 std::set<int> _passthruSignals;
26
27 // state used by sendInterrupt and checkInterrupt
28 struct {
29 std::mutex mutex;
30 ProcessId pid = 0;
31 } _interruptState;
32
33protected:
34 ErrorCode initialize(ProcessId pid, uint32_t flags) override;
35 virtual ErrorCode attach(int waitStatus) = 0;
36
37protected:
38 ErrorCode sendInterrupt();
39 bool checkInterrupt(ThreadId tid, int waitStatus);
40
41public:
42 ErrorCode detach() override;
43 ErrorCode interrupt() override;
44 ErrorCode terminate() override;
45 bool isAlive() const override;
46
47public:
48 ErrorCode readString(Address const &address, std::string &str, size_t length,
49 size_t *count = nullptr) override;
50 ErrorCode readMemory(Address const &address, void *data, size_t length,
51 size_t *count = nullptr) override;
52 ErrorCode writeMemory(Address const &address, void const *data, size_t length,
53 size_t *count = nullptr) override;
54
55protected:
56 int convertMemoryProtectionToPOSIX(uint32_t protection) const;
57 uint32_t convertMemoryProtectionFromPOSIX(int POSIXProtection) const;
58
59public:
60 void resetSignalPass();
61 void setSignalPass(int signo, bool set);
62
63public:
64 ErrorCode wait() override;
65
66public:
67 virtual Host::POSIX::PTrace &ptrace() const = 0;
68
69public:
70 static ds2::Target::Process *Create(Host::ProcessSpawner &spawner);
71 static ds2::Target::Process *Attach(ProcessId pid);
72};
73} // namespace POSIX
74} // namespace Target
75} // namespace ds2
Definition Types.h:95
Definition PTrace.h:28
Definition ProcessSpawner.h:20
Definition Process.h:23
Definition ProcessBase.h:25