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