xref: /haiku/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2010-2011, 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 BSplitView;
30 class BStringView;
31 class BTabView;
32 class Image;
33 class InspectorWindow;
34 class RegistersView;
35 class SourceCode;
36 class StackFrame;
37 class UserBreakpoint;
38 class UserInterfaceListener;
39 class VariablesView;
40 
41 
42 class TeamWindow : public BWindow, ThreadListView::Listener,
43 	ImageListView::Listener, StackTraceView::Listener,
44 	ImageFunctionsView::Listener, BreakpointsView::Listener,
45 	SourceView::Listener, VariablesView::Listener, Team::Listener,
46 	Function::Listener, StackFrame::Listener {
47 public:
48 								TeamWindow(::Team* team,
49 									UserInterfaceListener* listener);
50 								~TeamWindow();
51 
52 	static	TeamWindow*			Create(::Team* team,
53 									UserInterfaceListener* listener);
54 									// throws
55 
56 	virtual	void				DispatchMessage(BMessage* message,
57 									BHandler* handler);
58 	virtual	void				MessageReceived(BMessage* message);
59 	virtual	bool				QuitRequested();
60 
61 			status_t			LoadSettings(
62 									const GuiTeamUiSettings* settings);
63 			status_t			SaveSettings(
64 									GuiTeamUiSettings* settings);
65 
66 
67 private:
68 	enum ActiveSourceObject {
69 		ACTIVE_SOURCE_NONE,
70 		ACTIVE_SOURCE_STACK_FRAME,
71 		ACTIVE_SOURCE_FUNCTION,
72 		ACTIVE_SOURCE_BREAKPOINT
73 	};
74 
75 private:
76 	// ThreadListView::Listener
77 	virtual	void				ThreadSelectionChanged(::Thread* thread);
78 
79 	// ImageListView::Listener
80 	virtual	void				ImageSelectionChanged(Image* image);
81 
82 	// StackTraceView::Listener
83 	virtual	void				StackFrameSelectionChanged(StackFrame* frame);
84 
85 	// ImageFunctionsView::Listener
86 	virtual	void				FunctionSelectionChanged(
87 									FunctionInstance* function);
88 
89 	// BreakpointsView::Listener
90 	virtual	void				BreakpointSelectionChanged(
91 									UserBreakpoint* breakpoint);
92 	virtual	void				SetBreakpointEnabledRequested(
93 									UserBreakpoint* breakpoint,
94 									bool enabled);
95 	virtual	void				ClearBreakpointRequested(
96 									UserBreakpoint* breakpoint);
97 
98 	virtual	void				WatchpointSelectionChanged(
99 									Watchpoint* Watchpoint);
100 	virtual	void				SetWatchpointEnabledRequested(
101 									Watchpoint* breakpoint,
102 									bool enabled);
103 	virtual	void				ClearWatchpointRequested(
104 									Watchpoint* watchpoint);
105 
106 
107 	// SourceView::Listener
108 	virtual	void				SetBreakpointRequested(target_addr_t address,
109 									bool enabled);
110 	virtual	void				ClearBreakpointRequested(target_addr_t address);
111 
112 	// VariablesView::Listener
113 	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
114 									ValueNodeContainer* container,
115 									ValueNode* valueNode);
116 
117 	// Team::Listener
118 	virtual	void				ThreadStateChanged(
119 									const Team::ThreadEvent& event);
120 	virtual	void				ThreadCpuStateChanged(
121 									const Team::ThreadEvent& event);
122 	virtual	void				ThreadStackTraceChanged(
123 									const Team::ThreadEvent& event);
124 	virtual	void				ImageDebugInfoChanged(
125 									const Team::ImageEvent& event);
126 	virtual	void				UserBreakpointChanged(
127 									const Team::UserBreakpointEvent& event);
128 	virtual	void				WatchpointChanged(
129 									const Team::WatchpointEvent& event);
130 	virtual void				DebugReportChanged(
131 									const Team::DebugReportEvent& event);
132 
133 	// Function::Listener
134 	virtual	void				FunctionSourceCodeChanged(Function* function);
135 
136 			void				_Init();
137 
138 			void				_SetActiveThread(::Thread* thread);
139 			void				_SetActiveImage(Image* image);
140 			void				_SetActiveStackTrace(StackTrace* stackTrace);
141 			void				_SetActiveStackFrame(StackFrame* frame);
142 			void				_SetActiveBreakpoint(
143 									UserBreakpoint* breakpoint);
144 			void				_SetActiveFunction(FunctionInstance* function);
145 			void				_SetActiveSourceCode(SourceCode* sourceCode);
146 			void				_UpdateCpuState();
147 			void				_UpdateRunButtons();
148 			void				_UpdateSourcePathState();
149 			void				_ScrollToActiveFunction();
150 
151 			void				_HandleThreadStateChanged(thread_id threadID);
152 			void				_HandleCpuStateChanged(thread_id threadID);
153 			void				_HandleStackTraceChanged(thread_id threadID);
154 			void				_HandleImageDebugInfoChanged(image_id imageID);
155 			void				_HandleSourceCodeChanged();
156 			void				_HandleUserBreakpointChanged(
157 									UserBreakpoint* breakpoint);
158 			void				_HandleWatchpointChanged(
159 									Watchpoint* watchpoint);
160 			void				_HandleResolveMissingSourceFile(entry_ref&
161 									locatedPath);
162 
163 			status_t			_SaveInspectorSettings(
164 									const BMessage* settings);
165 private:
166 			::Team*				fTeam;
167 			::Thread*			fActiveThread;
168 			Image*				fActiveImage;
169 			StackTrace*			fActiveStackTrace;
170 			StackFrame*			fActiveStackFrame;
171 			UserBreakpoint*		fActiveBreakpoint;
172 			FunctionInstance*	fActiveFunction;
173 			SourceCode*			fActiveSourceCode;
174 			ActiveSourceObject	fActiveSourceObject;
175 			UserInterfaceListener* fListener;
176 			BTabView*			fTabView;
177 			BTabView*			fLocalsTabView;
178 			ThreadListView*		fThreadListView;
179 			ImageListView*		fImageListView;
180 			ImageFunctionsView*	fImageFunctionsView;
181 			BreakpointsView*	fBreakpointsView;
182 			VariablesView*		fVariablesView;
183 			RegistersView*		fRegistersView;
184 			StackTraceView*		fStackTraceView;
185 			SourceView*			fSourceView;
186 			BButton*			fRunButton;
187 			BButton*			fStepOverButton;
188 			BButton*			fStepIntoButton;
189 			BButton*			fStepOutButton;
190 			BMenuBar*			fMenuBar;
191 			BStringView*		fSourcePathView;
192 			BSplitView*			fFunctionSplitView;
193 			BSplitView*			fSourceSplitView;
194 			BSplitView*			fImageSplitView;
195 			BSplitView*			fThreadSplitView;
196 			InspectorWindow*	fInspectorWindow;
197 			GuiTeamUiSettings	fUiSettings;
198 			BFilePanel*			fFilePanel;
199 };
200 
201 
202 #endif	// TEAM_WINDOW_H
203