xref: /haiku/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h (revision 85892ec52f476b254d75e2bb2e6560e72faa567c)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2010-2014, 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 BreakConditionConfigWindow;
36 class BreakpointEditWindow;
37 class ExpressionPromptWindow;
38 class Image;
39 class InspectorWindow;
40 class RegistersView;
41 class SourceCode;
42 class SourceLanguage;
43 class StackFrame;
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 
134 	// Team::Listener
135 	virtual	void				ThreadStateChanged(
136 									const Team::ThreadEvent& event);
137 	virtual	void				ThreadCpuStateChanged(
138 									const Team::ThreadEvent& event);
139 	virtual	void				ThreadStackTraceChanged(
140 									const Team::ThreadEvent& event);
141 	virtual	void				ImageDebugInfoChanged(
142 									const Team::ImageEvent& event);
143 	virtual	void				ConsoleOutputReceived(
144 									const Team::ConsoleOutputEvent& event);
145 	virtual	void				UserBreakpointChanged(
146 									const Team::UserBreakpointEvent& event);
147 	virtual	void				WatchpointChanged(
148 									const Team::WatchpointEvent& event);
149 	virtual void				DebugReportChanged(
150 									const Team::DebugReportEvent& event);
151 
152 
153 	// Function::Listener
154 	virtual	void				FunctionSourceCodeChanged(Function* function);
155 
156 			void				_Init();
157 
158 			void				_SetActiveThread(::Thread* thread);
159 			void				_SetActiveImage(Image* image);
160 			void				_SetActiveStackTrace(StackTrace* stackTrace);
161 			void				_SetActiveStackFrame(StackFrame* frame);
162 			void				_SetActiveBreakpoint(
163 									UserBreakpoint* breakpoint);
164 			void				_SetActiveFunction(FunctionInstance* function);
165 			void				_SetActiveSourceCode(SourceCode* sourceCode);
166 			void				_UpdateCpuState();
167 			void				_UpdateRunButtons();
168 			void				_UpdateSourcePathState();
169 			void				_ScrollToActiveFunction();
170 
171 			void				_HandleThreadStateChanged(thread_id threadID);
172 			void				_HandleCpuStateChanged(thread_id threadID);
173 			void				_HandleStackTraceChanged(thread_id threadID);
174 			void				_HandleImageDebugInfoChanged(image_id imageID);
175 			void				_HandleSourceCodeChanged();
176 			void				_HandleUserBreakpointChanged(
177 									UserBreakpoint* breakpoint);
178 			void				_HandleWatchpointChanged(
179 									Watchpoint* watchpoint);
180 
181 	static	status_t			_RetrieveMatchingSourceWorker(void* arg);
182 			void				_HandleResolveMissingSourceFile(entry_ref&
183 									locatedPath);
184 			void				_HandleLocateSourceRequest(
185 									BStringList* entries = NULL);
186 	static	status_t			_RetrieveMatchingSourceEntries(
187 									const BString& path,
188 									BStringList* _entries);
189 
190 			status_t			_SaveInspectorSettings(
191 									const BMessage* settings);
192 
193 			status_t			_GetActiveSourceLanguage(
194 									SourceLanguage*& _language);
195 
196 private:
197 			::Team*				fTeam;
198 			::Thread*			fActiveThread;
199 			Image*				fActiveImage;
200 			StackTrace*			fActiveStackTrace;
201 			StackFrame*			fActiveStackFrame;
202 			UserBreakpoint*		fActiveBreakpoint;
203 			FunctionInstance*	fActiveFunction;
204 			SourceCode*			fActiveSourceCode;
205 			ActiveSourceObject	fActiveSourceObject;
206 			UserInterfaceListener* fListener;
207 			BMessageRunner*		fTraceUpdateRunner;
208 			BTabView*			fTabView;
209 			BTabView*			fLocalsTabView;
210 			ThreadListView*		fThreadListView;
211 			ImageListView*		fImageListView;
212 			ImageFunctionsView*	fImageFunctionsView;
213 			BreakpointsView*	fBreakpointsView;
214 			VariablesView*		fVariablesView;
215 			RegistersView*		fRegistersView;
216 			StackTraceView*		fStackTraceView;
217 			SourceView*			fSourceView;
218 			BButton*			fRunButton;
219 			BButton*			fStepOverButton;
220 			BButton*			fStepIntoButton;
221 			BButton*			fStepOutButton;
222 			BMenuBar*			fMenuBar;
223 			BStringView*		fSourcePathView;
224 			ConsoleOutputView*	fConsoleOutputView;
225 			BSplitView*			fFunctionSplitView;
226 			BSplitView*			fSourceSplitView;
227 			BSplitView*			fImageSplitView;
228 			BSplitView*			fThreadSplitView;
229 			BSplitView*			fConsoleSplitView;
230 			BreakConditionConfigWindow* fBreakConditionConfigWindow;
231 			BreakpointEditWindow* fBreakpointEditWindow;
232 			InspectorWindow*	fInspectorWindow;
233 			ExpressionPromptWindow* fExpressionPromptWindow;
234 			GuiTeamUiSettings	fUiSettings;
235 			BFilePanel*			fFilePanel;
236 			thread_id			fActiveSourceWorker;
237 };
238 
239 
240 #endif	// TEAM_WINDOW_H
241