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