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