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