DebugServer2
Loading...
Searching...
No Matches
ThreadBase.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/Architecture/CPUState.h"
14#include "DebugServer2/Target/ProcessDecl.h"
15#include "DebugServer2/Utils/Log.h"
16
17#include <functional>
18
19namespace ds2 {
20namespace Target {
21
23public:
24 enum State { kInvalid, kRunning, kStepped, kStopped, kTerminated };
25
26protected:
27 Process *_process;
28 ThreadId _tid;
29 StopInfo _stopInfo;
30 State _state;
31
32protected:
33 ThreadBase(Process *process, ThreadId tid);
34
35public:
36 virtual ~ThreadBase() = default;
37
38public:
39 inline Process *process() const { return _process; }
40 inline ThreadId tid() const { return _tid; }
41 inline StopInfo const &stopInfo() const { return _stopInfo; }
42
43public:
44 virtual ErrorCode terminate() = 0;
45
46public:
47 virtual ErrorCode suspend() = 0;
48
49public:
50 inline State state() const { return _state; }
51
52public:
53 virtual ErrorCode step(int signal = 0,
54 Address const &address = Address()) = 0;
55 virtual ErrorCode resume(int signal = 0,
56 Address const &address = Address()) = 0;
57
58public:
59 virtual ErrorCode beforeResume();
60
61public:
62 virtual ErrorCode readCPUState(Architecture::CPUState &state) = 0;
63 virtual ErrorCode writeCPUState(Architecture::CPUState const &state) = 0;
64 virtual ErrorCode modifyRegisters(
65 std::function<void(Architecture::CPUState &state)> action) final;
66
67public:
68 inline uint32_t core() const { return _stopInfo.core; }
69
70protected:
71 friend class ProcessBase;
72 virtual void updateState() = 0;
73};
74} // namespace Target
75} // namespace ds2
Definition Types.h:95
Definition ProcessBase.h:25
Definition ThreadBase.h:22
Definition Types.h:131