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