xref: /haiku/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h (revision 7c5d8dd2a860071f70dfe0492d38eac3b1009ee4)
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 	// SourceView::Listener
99 	virtual	void				SetBreakpointRequested(target_addr_t address,
100 									bool enabled);
101 	virtual	void				ClearBreakpointRequested(target_addr_t address);
102 
103 	// VariablesView::Listener
104 	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
105 									ValueNodeContainer* container,
106 									ValueNode* valueNode);
107 
108 	// Team::Listener
109 	virtual	void				ThreadStateChanged(
110 									const Team::ThreadEvent& event);
111 	virtual	void				ThreadCpuStateChanged(
112 									const Team::ThreadEvent& event);
113 	virtual	void				ThreadStackTraceChanged(
114 									const Team::ThreadEvent& event);
115 	virtual	void				ImageDebugInfoChanged(
116 									const Team::ImageEvent& event);
117 	virtual	void				UserBreakpointChanged(
118 									const Team::UserBreakpointEvent& event);
119 
120 	// Function::Listener
121 	virtual	void				FunctionSourceCodeChanged(Function* function);
122 
123 			void				_Init();
124 
125 			void				_SetActiveThread(::Thread* thread);
126 			void				_SetActiveImage(Image* image);
127 			void				_SetActiveStackTrace(StackTrace* stackTrace);
128 			void				_SetActiveStackFrame(StackFrame* frame);
129 			void				_SetActiveBreakpoint(
130 									UserBreakpoint* breakpoint);
131 			void				_SetActiveFunction(FunctionInstance* function);
132 			void				_SetActiveSourceCode(SourceCode* sourceCode);
133 			void				_UpdateCpuState();
134 			void				_UpdateRunButtons();
135 			void				_UpdateSourcePathState();
136 			void				_ScrollToActiveFunction();
137 
138 			void				_HandleThreadStateChanged(thread_id threadID);
139 			void				_HandleCpuStateChanged(thread_id threadID);
140 			void				_HandleStackTraceChanged(thread_id threadID);
141 			void				_HandleImageDebugInfoChanged(image_id imageID);
142 			void				_HandleSourceCodeChanged();
143 			void				_HandleUserBreakpointChanged(
144 									UserBreakpoint* breakpoint);
145 			void				_HandleResolveMissingSourceFile(entry_ref&
146 									locatedPath);
147 
148 			status_t			_SaveInspectorSettings(
149 									const BMessage* settings);
150 private:
151 			::Team*				fTeam;
152 			::Thread*			fActiveThread;
153 			Image*				fActiveImage;
154 			StackTrace*			fActiveStackTrace;
155 			StackFrame*			fActiveStackFrame;
156 			UserBreakpoint*		fActiveBreakpoint;
157 			FunctionInstance*	fActiveFunction;
158 			SourceCode*			fActiveSourceCode;
159 			ActiveSourceObject	fActiveSourceObject;
160 			UserInterfaceListener* fListener;
161 			BTabView*			fTabView;
162 			BTabView*			fLocalsTabView;
163 			ThreadListView*		fThreadListView;
164 			ImageListView*		fImageListView;
165 			ImageFunctionsView*	fImageFunctionsView;
166 			BreakpointsView*	fBreakpointsView;
167 			VariablesView*		fVariablesView;
168 			RegistersView*		fRegistersView;
169 			StackTraceView*		fStackTraceView;
170 			SourceView*			fSourceView;
171 			BButton*			fRunButton;
172 			BButton*			fStepOverButton;
173 			BButton*			fStepIntoButton;
174 			BButton*			fStepOutButton;
175 			BMenuBar*			fMenuBar;
176 			BStringView*		fSourcePathView;
177 			BSplitView*			fFunctionSplitView;
178 			BSplitView*			fSourceSplitView;
179 			BSplitView*			fImageSplitView;
180 			BSplitView*			fThreadSplitView;
181 			InspectorWindow*	fInspectorWindow;
182 			GUITeamUISettings	fUISettings;
183 			BFilePanel*			fSourceLocatePanel;
184 };
185 
186 
187 #endif	// TEAM_WINDOW_H
188