xref: /haiku/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h (revision 5ef0649658e5e41d2fa524980b3ece064e1ba93a)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2010-2017, Rene Gollent, rene@gollent.com.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef TEAM_WINDOW_H
7 #define TEAM_WINDOW_H
8 
9 
10 #include <String.h>
11 #include <Window.h>
12 
13 #include <util/OpenHashTable.h>
14 
15 #include "BreakpointsView.h"
16 #include "Function.h"
17 #include "GuiTeamUiSettings.h"
18 #include "ImageFunctionsView.h"
19 #include "ImageListView.h"
20 #include "SourceView.h"
21 #include "StackFrame.h"
22 #include "StackTraceView.h"
23 #include "Team.h"
24 #include "ThreadListView.h"
25 #include "VariablesView.h"
26 
27 
28 class BButton;
29 class BFilePanel;
30 class BMenuBar;
31 class BMessageRunner;
32 class BSplitView;
33 class BStringList;
34 class BStringView;
35 class BTabView;
36 class ConsoleOutputView;
37 class BreakpointEditWindow;
38 class ExpressionEvaluationWindow;
39 class ExpressionPromptWindow;
40 class Image;
41 class InspectorWindow;
42 class RegistersView;
43 class SourceCode;
44 class SourceLanguage;
45 class StackFrame;
46 class TeamSettingsWindow;
47 class Type;
48 class UserBreakpoint;
49 class UserInterfaceListener;
50 class VariablesView;
51 
52 
53 class TeamWindow : public BWindow, ThreadListView::Listener,
54 	ImageListView::Listener, StackTraceView::Listener,
55 	ImageFunctionsView::Listener, BreakpointsView::Listener,
56 	SourceView::Listener, VariablesView::Listener, Team::Listener,
57 	Function::Listener, StackFrame::Listener {
58 public:
59 								TeamWindow(::Team* team,
60 									UserInterfaceListener* listener);
61 								~TeamWindow();
62 
63 	static	TeamWindow*			Create(::Team* team,
64 									UserInterfaceListener* listener);
65 									// throws
66 
67 	virtual	void				DispatchMessage(BMessage* message,
68 									BHandler* handler);
69 	virtual	void				MessageReceived(BMessage* message);
70 	virtual	bool				QuitRequested();
71 
72 			status_t			LoadSettings(
73 									const GuiTeamUiSettings* settings);
74 			status_t			SaveSettings(
75 									GuiTeamUiSettings* settings);
76 
77 			void				DisplayBackgroundStatus(const char* message);
78 
79 
80 private:
81 	enum ActiveSourceObject {
82 		ACTIVE_SOURCE_NONE,
83 		ACTIVE_SOURCE_STACK_FRAME,
84 		ACTIVE_SOURCE_FUNCTION,
85 		ACTIVE_SOURCE_BREAKPOINT
86 	};
87 
88 	struct ThreadStackFrameSelectionKey;
89 	struct ThreadStackFrameSelectionEntry;
90 	struct ThreadStackFrameSelectionEntryHashDefinition;
91 
92 	typedef BOpenHashTable<ThreadStackFrameSelectionEntryHashDefinition>
93 		ThreadStackFrameSelectionInfoTable;
94 
95 
96 private:
97 	// ThreadListView::Listener
98 	virtual	void				ThreadSelectionChanged(::Thread* thread);
99 
100 	// ImageListView::Listener
101 	virtual	void				ImageSelectionChanged(Image* image);
102 
103 	// StackTraceView::Listener
104 	virtual	void				StackFrameSelectionChanged(StackFrame* frame);
105 
106 	// ImageFunctionsView::Listener
107 	virtual	void				FunctionSelectionChanged(
108 									FunctionInstance* function);
109 
110 	// BreakpointsView::Listener
111 	virtual	void				BreakpointSelectionChanged(
112 									BreakpointProxyList& proxies);
113 	virtual	void				SetBreakpointEnabledRequested(
114 									UserBreakpoint* breakpoint,
115 									bool enabled);
116 	virtual	void				ClearBreakpointRequested(
117 									UserBreakpoint* breakpoint);
118 
119 	virtual	void				SetWatchpointEnabledRequested(
120 									Watchpoint* breakpoint,
121 									bool enabled);
122 	virtual	void				ClearWatchpointRequested(
123 									Watchpoint* watchpoint);
124 
125 
126 	// SourceView::Listener
127 	virtual	void				SetBreakpointRequested(target_addr_t address,
128 									bool enabled);
129 	virtual	void				ClearBreakpointRequested(
130 									target_addr_t address);
131 	virtual	void				ThreadActionRequested(::Thread* thread,
132 									uint32 action, target_addr_t address);
133 	virtual	void				FunctionSourceCodeRequested(
134 									FunctionInstance* function,
135 									bool forceDisassembly);
136 
137 
138 	// VariablesView::Listener
139 	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
140 									ValueNodeContainer* container,
141 									ValueNode* valueNode);
142 	virtual	void				ExpressionEvaluationRequested(
143 									ExpressionInfo* info,
144 									StackFrame* frame,
145 									::Thread* thread);
146 	virtual	void				ValueNodeWriteRequested(ValueNode* node,
147 									CpuState* state, Value* value);
148 
149 	// Team::Listener
150 	virtual	void				TeamRenamed(const Team::Event& event);
151 	virtual	void				ThreadStateChanged(
152 									const Team::ThreadEvent& event);
153 	virtual	void				ThreadCpuStateChanged(
154 									const Team::ThreadEvent& event);
155 	virtual	void				ThreadStackTraceChanged(
156 									const Team::ThreadEvent& event);
157 	virtual	void				ImageDebugInfoChanged(
158 									const Team::ImageEvent& event);
159 	virtual	void				ConsoleOutputReceived(
160 									const Team::ConsoleOutputEvent& event);
161 	virtual	void				UserBreakpointChanged(
162 									const Team::UserBreakpointEvent& event);
163 	virtual	void				WatchpointChanged(
164 									const Team::WatchpointEvent& event);
165 	virtual void				DebugReportChanged(
166 									const Team::DebugReportEvent& event);
167 	virtual void				CoreFileChanged(
168 									const Team::CoreFileChangedEvent& event);
169 
170 
171 	// Function::Listener
172 	virtual	void				FunctionSourceCodeChanged(Function* function);
173 
174 			void				_Init();
175 
176 			void				_LoadSettings(
177 									const GuiTeamUiSettings* settings);
178 
179 			void				_UpdateTitle();
180 			void				_SetActiveThread(::Thread* thread);
181 			void				_SetActiveImage(Image* image);
182 			void				_SetActiveStackTrace(StackTrace* stackTrace);
183 			void				_SetActiveStackFrame(StackFrame* frame);
184 			void				_SetActiveBreakpoint(
185 									UserBreakpoint* breakpoint);
186 			void				_SetActiveFunction(FunctionInstance* function,
187 									bool searchForFrame = true);
188 			void				_SetActiveSourceCode(SourceCode* sourceCode);
189 			void				_UpdateCpuState();
190 			void				_UpdateRunButtons();
191 			void				_UpdateSourcePathState();
192 			void				_ScrollToActiveFunction();
193 
194 			void				_HandleThreadStateChanged(thread_id threadID);
195 			void				_HandleCpuStateChanged(thread_id threadID);
196 			void				_HandleStackTraceChanged(thread_id threadID);
197 			void				_HandleImageDebugInfoChanged(image_id imageID);
198 			void				_HandleSourceCodeChanged();
199 			void				_HandleUserBreakpointChanged(
200 									UserBreakpoint* breakpoint);
201 			void				_HandleWatchpointChanged(
202 									Watchpoint* watchpoint);
203 
204 	static	status_t			_RetrieveMatchingSourceWorker(void* arg);
205 			void				_HandleResolveMissingSourceFile(entry_ref&
206 									locatedPath);
207 			void				_HandleLocateSourceRequest(
208 									BStringList* entries = NULL);
209 	static	status_t			_RetrieveMatchingSourceEntries(
210 									const BString& path,
211 									BStringList* _entries);
212 
213 			status_t			_SaveInspectorSettings(
214 									const BMessage* settings);
215 
216 			status_t			_GetActiveSourceLanguage(
217 									SourceLanguage*& _language);
218 
219 private:
220 			::Team*				fTeam;
221 			::Thread*			fActiveThread;
222 			Image*				fActiveImage;
223 			StackTrace*			fActiveStackTrace;
224 			StackFrame*			fActiveStackFrame;
225 			ThreadStackFrameSelectionInfoTable*
226 								fThreadSelectionInfoTable;
227 			UserBreakpoint*		fActiveBreakpoint;
228 			FunctionInstance*	fActiveFunction;
229 			SourceCode*			fActiveSourceCode;
230 			ActiveSourceObject	fActiveSourceObject;
231 			UserInterfaceListener* fListener;
232 			BMessageRunner*		fTraceUpdateRunner;
233 			BTabView*			fTabView;
234 			BTabView*			fLocalsTabView;
235 			ThreadListView*		fThreadListView;
236 			ImageListView*		fImageListView;
237 			ImageFunctionsView*	fImageFunctionsView;
238 			BreakpointsView*	fBreakpointsView;
239 			VariablesView*		fVariablesView;
240 			RegistersView*		fRegistersView;
241 			StackTraceView*		fStackTraceView;
242 			SourceView*			fSourceView;
243 			BButton*			fRunButton;
244 			BButton*			fStepOverButton;
245 			BButton*			fStepIntoButton;
246 			BButton*			fStepOutButton;
247 			BMenuBar*			fMenuBar;
248 			BStringView*		fSourcePathView;
249 			BStringView*		fStatusBarView;
250 			ConsoleOutputView*	fConsoleOutputView;
251 			BSplitView*			fFunctionSplitView;
252 			BSplitView*			fSourceSplitView;
253 			BSplitView*			fImageSplitView;
254 			BSplitView*			fThreadSplitView;
255 			BSplitView*			fConsoleSplitView;
256 			TeamSettingsWindow*	fTeamSettingsWindow;
257 			BreakpointEditWindow* fBreakpointEditWindow;
258 			InspectorWindow*	fInspectorWindow;
259 			ExpressionEvaluationWindow* fExpressionEvalWindow;
260 			ExpressionPromptWindow* fExpressionPromptWindow;
261 			GuiTeamUiSettings	fUiSettings;
262 			BFilePanel*			fFilePanel;
263 			thread_id			fActiveSourceWorker;
264 };
265 
266 
267 #endif	// TEAM_WINDOW_H
268