Debugger: Split into core library and application.
[haiku.git] / headers / private / debugger / target_host_interface / TargetHostInterface.h
blob99ad997f7a2cfd29eafeff2b1645e85c816465aa
1 /*
2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef TARGET_HOST_INTERFACE_H
6 #define TARGET_HOST_INTERFACE_H
8 #include <OS.h>
9 #include <Looper.h>
11 #include <ObjectList.h>
13 #include <util/DoublyLinkedList.h>
15 #include "controllers/TeamDebugger.h"
18 class DebuggerInterface;
19 class Settings;
20 class SettingsManager;
21 class TargetHost;
22 struct TeamDebuggerOptions;
23 class UserInterface;
26 class TargetHostInterface : public BLooper, private TeamDebugger::Listener {
27 public:
28 class 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);
64 // BLooper
65 virtual void Quit();
66 virtual void MessageReceived(BMessage* message);
68 private:
69 // TeamDebugger::Listener
70 virtual void TeamDebuggerStarted(TeamDebugger* debugger);
71 virtual void TeamDebuggerRestartRequested(
72 TeamDebugger* debugger);
73 virtual void TeamDebuggerQuit(TeamDebugger* debugger);
75 private:
76 status_t _StartTeamDebugger(team_id teamID,
77 const TeamDebuggerOptions& options,
78 bool stopInMain);
80 void _NotifyTeamDebuggerStarted(
81 TeamDebugger* debugger);
82 void _NotifyTeamDebuggerQuit(
83 TeamDebugger* debugger);
85 static int _CompareDebuggers(const TeamDebugger* a,
86 const TeamDebugger* b);
87 private:
88 typedef DoublyLinkedList<Listener> ListenerList;
89 typedef BObjectList<TeamDebugger> TeamDebuggerList;
91 private:
92 ListenerList fListeners;
93 TeamDebuggerList fTeamDebuggers;
97 class TargetHostInterface::Listener
98 : public DoublyLinkedListLinkImpl<Listener> {
99 public:
100 virtual ~Listener();
101 virtual void TeamDebuggerStarted(TeamDebugger* debugger);
102 virtual void TeamDebuggerQuit(TeamDebugger* debugger);
103 virtual void TargetHostInterfaceQuit(
104 TargetHostInterface* interface);
108 enum {
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();
118 int requestType;
119 int commandLineArgc;
120 const char* const* commandLineArgv;
121 team_id team;
122 thread_id thread;
123 SettingsManager* settingsManager;
124 UserInterface* userInterface;
125 const char* coreFilePath;
129 #endif // TARGET_HOST_INTERFACE_H