2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #ifndef TARGET_HOST_INTERFACE_H
6 #define TARGET_HOST_INTERFACE_H
11 #include <ObjectList.h>
13 #include <util/DoublyLinkedList.h>
15 #include "controllers/TeamDebugger.h"
18 class DebuggerInterface
;
20 class SettingsManager
;
22 struct TeamDebuggerOptions
;
26 class TargetHostInterface
: public BLooper
, private TeamDebugger::Listener
{
29 TargetHostInterface();
30 virtual ~TargetHostInterface();
32 status_t
StartTeamDebugger(const TeamDebuggerOptions
& options
);
34 int32
CountTeamDebuggers() const;
35 TeamDebugger
* TeamDebuggerAt(int32 index
) const;
36 TeamDebugger
* FindTeamDebugger(team_id team
) const;
37 status_t
AddTeamDebugger(TeamDebugger
* debugger
);
38 void RemoveTeamDebugger(TeamDebugger
* debugger
);
40 virtual status_t
Init(Settings
* settings
) = 0;
41 virtual void Close() = 0;
43 virtual bool IsLocal() const = 0;
44 virtual bool Connected() const = 0;
46 virtual TargetHost
* GetTargetHost() = 0;
48 virtual status_t
Attach(team_id id
, thread_id threadID
,
49 DebuggerInterface
*& _interface
) const = 0;
50 virtual status_t
CreateTeam(int commandLineArgc
,
51 const char* const* arguments
,
52 team_id
& _teamID
) const = 0;
53 virtual status_t
LoadCore(const char* coreFilePath
,
54 DebuggerInterface
*& _interface
,
55 thread_id
& _thread
) const = 0;
57 virtual status_t
FindTeamByThread(thread_id thread
,
58 team_id
& _teamID
) const = 0;
61 void AddListener(Listener
* listener
);
62 void RemoveListener(Listener
* listener
);
66 virtual void MessageReceived(BMessage
* message
);
69 // TeamDebugger::Listener
70 virtual void TeamDebuggerStarted(TeamDebugger
* debugger
);
71 virtual void TeamDebuggerRestartRequested(
72 TeamDebugger
* debugger
);
73 virtual void TeamDebuggerQuit(TeamDebugger
* debugger
);
76 status_t
_StartTeamDebugger(team_id teamID
,
77 const TeamDebuggerOptions
& options
,
80 void _NotifyTeamDebuggerStarted(
81 TeamDebugger
* debugger
);
82 void _NotifyTeamDebuggerQuit(
83 TeamDebugger
* debugger
);
85 static int _CompareDebuggers(const TeamDebugger
* a
,
86 const TeamDebugger
* b
);
88 typedef DoublyLinkedList
<Listener
> ListenerList
;
89 typedef BObjectList
<TeamDebugger
> TeamDebuggerList
;
92 ListenerList fListeners
;
93 TeamDebuggerList fTeamDebuggers
;
97 class TargetHostInterface::Listener
98 : public DoublyLinkedListLinkImpl
<Listener
> {
101 virtual void TeamDebuggerStarted(TeamDebugger
* debugger
);
102 virtual void TeamDebuggerQuit(TeamDebugger
* debugger
);
103 virtual void TargetHostInterfaceQuit(
104 TargetHostInterface
* interface
);
109 TEAM_DEBUGGER_REQUEST_UNKNOWN
= 0,
110 TEAM_DEBUGGER_REQUEST_CREATE
,
111 TEAM_DEBUGGER_REQUEST_ATTACH
,
112 TEAM_DEBUGGER_REQUEST_LOAD_CORE
116 struct TeamDebuggerOptions
{
117 TeamDebuggerOptions();
120 const char* const* commandLineArgv
;
123 SettingsManager
* settingsManager
;
124 UserInterface
* userInterface
;
125 const char* coreFilePath
;
129 #endif // TARGET_HOST_INTERFACE_H