-
-
Notifications
You must be signed in to change notification settings - Fork 336
/
TargetHostInterface.h
129 lines (98 loc) · 3.31 KB
/
TargetHostInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* Copyright 2016, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef TARGET_HOST_INTERFACE_H
#define TARGET_HOST_INTERFACE_H
#include <OS.h>
#include <Looper.h>
#include <ObjectList.h>
#include <util/DoublyLinkedList.h>
#include "TeamDebugger.h"
class DebuggerInterface;
class Settings;
class SettingsManager;
class TargetHost;
struct TeamDebuggerOptions;
class UserInterface;
class TargetHostInterface : public BLooper, private TeamDebugger::Listener {
public:
class Listener;
TargetHostInterface();
virtual ~TargetHostInterface();
status_t StartTeamDebugger(const TeamDebuggerOptions& options);
int32 CountTeamDebuggers() const;
TeamDebugger* TeamDebuggerAt(int32 index) const;
TeamDebugger* FindTeamDebugger(team_id team) const;
status_t AddTeamDebugger(TeamDebugger* debugger);
void RemoveTeamDebugger(TeamDebugger* debugger);
virtual status_t Init(Settings* settings) = 0;
virtual void Close() = 0;
virtual bool IsLocal() const = 0;
virtual bool Connected() const = 0;
virtual TargetHost* GetTargetHost() = 0;
virtual status_t Attach(team_id id, thread_id threadID,
DebuggerInterface*& _interface) const = 0;
virtual status_t CreateTeam(int commandLineArgc,
const char* const* arguments,
team_id& _teamID) const = 0;
virtual status_t LoadCore(const char* coreFilePath,
DebuggerInterface*& _interface,
thread_id& _thread) const = 0;
virtual status_t FindTeamByThread(thread_id thread,
team_id& _teamID) const = 0;
void AddListener(Listener* listener);
void RemoveListener(Listener* listener);
// BLooper
virtual void Quit();
virtual void MessageReceived(BMessage* message);
private:
// TeamDebugger::Listener
virtual void TeamDebuggerStarted(TeamDebugger* debugger);
virtual void TeamDebuggerRestartRequested(
TeamDebugger* debugger);
virtual void TeamDebuggerQuit(TeamDebugger* debugger);
private:
status_t _StartTeamDebugger(team_id teamID,
const TeamDebuggerOptions& options,
bool stopInMain);
void _NotifyTeamDebuggerStarted(
TeamDebugger* debugger);
void _NotifyTeamDebuggerQuit(
TeamDebugger* debugger);
static int _CompareDebuggers(const TeamDebugger* a,
const TeamDebugger* b);
private:
typedef DoublyLinkedList<Listener> ListenerList;
typedef BObjectList<TeamDebugger> TeamDebuggerList;
private:
ListenerList fListeners;
TeamDebuggerList fTeamDebuggers;
};
class TargetHostInterface::Listener
: public DoublyLinkedListLinkImpl<Listener> {
public:
virtual ~Listener();
virtual void TeamDebuggerStarted(TeamDebugger* debugger);
virtual void TeamDebuggerQuit(TeamDebugger* debugger);
virtual void TargetHostInterfaceQuit(
TargetHostInterface* interface);
};
enum {
TEAM_DEBUGGER_REQUEST_UNKNOWN = 0,
TEAM_DEBUGGER_REQUEST_CREATE,
TEAM_DEBUGGER_REQUEST_ATTACH,
TEAM_DEBUGGER_REQUEST_LOAD_CORE
};
struct TeamDebuggerOptions {
TeamDebuggerOptions();
int requestType;
int commandLineArgc;
const char* const* commandLineArgv;
team_id team;
thread_id thread;
SettingsManager* settingsManager;
UserInterface* userInterface;
const char* coreFilePath;
};
#endif // TARGET_HOST_INTERFACE_H