1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef DEBUG_EVENT_H 6#define DEBUG_EVENT_H 7 8#include <debugger.h> 9 10#include "ImageInfo.h" 11#include "Types.h" 12 13 14class CpuState; 15 16 17// constants for synthetic events generated via the 18// start_system_watching() interface 19enum { 20 DEBUGGER_MESSAGE_THREAD_RENAMED = 'dmtr', 21 DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED = 'dmpc' 22}; 23 24 25class DebugEvent { 26public: 27 DebugEvent(int32 eventType, 28 team_id team, thread_id thread); 29 virtual ~DebugEvent(); 30 31 int32 EventType() const { return fEventType; } 32 team_id Team() const { return fTeam; } 33 thread_id Thread() const { return fThread; } 34 35 bool ThreadStopped() const { return fThreadStopped; } 36 void SetThreadStopped(bool stopped); 37 38private: 39 int32 fEventType; 40 team_id fTeam; 41 thread_id fThread; 42 bool fThreadStopped; 43}; 44 45 46class CpuStateEvent : public DebugEvent { 47public: 48 CpuStateEvent(debug_debugger_message eventType, 49 team_id team, thread_id thread, 50 CpuState* state); 51 virtual ~CpuStateEvent(); 52 53 CpuState* GetCpuState() const { return fCpuState; } 54 55private: 56 CpuState* fCpuState; 57}; 58 59 60class ThreadDebuggedEvent : public DebugEvent { 61public: 62 ThreadDebuggedEvent(team_id team, 63 thread_id thread); 64}; 65 66 67class DebuggerCallEvent : public DebugEvent { 68public: 69 DebuggerCallEvent(team_id team, 70 thread_id thread, target_addr_t message); 71 72 target_addr_t Message() const { return fMessage; } 73 74private: 75 target_addr_t fMessage; 76}; 77 78 79class BreakpointHitEvent : public CpuStateEvent { 80public: 81 BreakpointHitEvent(team_id team, 82 thread_id thread, CpuState* state); 83}; 84 85 86class WatchpointHitEvent : public CpuStateEvent { 87public: 88 WatchpointHitEvent(team_id team, 89 thread_id thread, CpuState* state); 90}; 91 92 93class SingleStepEvent : public CpuStateEvent { 94public: 95 SingleStepEvent(team_id team, 96 thread_id thread, CpuState* state); 97}; 98 99 100class ExceptionOccurredEvent : public DebugEvent { 101public: 102 ExceptionOccurredEvent(team_id team, 103 thread_id thread, 104 debug_exception_type exception); 105 106 debug_exception_type Exception() const { return fException; } 107 108private: 109 debug_exception_type fException; 110}; 111 112 113class TeamDeletedEvent : public DebugEvent { 114public: 115 TeamDeletedEvent(team_id team, 116 thread_id thread); 117}; 118 119 120class TeamExecEvent : public DebugEvent { 121public: 122 TeamExecEvent(team_id team, thread_id thread); 123}; 124 125 126class ThreadCreatedEvent : public DebugEvent { 127public: 128 ThreadCreatedEvent(team_id team, 129 thread_id thread, thread_id newThread); 130 131 thread_id NewThread() const { return fNewThread; } 132 133private: 134 thread_id fNewThread; 135}; 136 137 138class ThreadRenamedEvent : public DebugEvent { 139public: 140 ThreadRenamedEvent(team_id team, 141 thread_id thread, thread_id renamedThread, 142 const char* name); 143 144 thread_id RenamedThread() const { return fRenamedThread; } 145 const char* NewName() const { return fName; } 146 147private: 148 thread_id fRenamedThread; 149 char fName[B_OS_NAME_LENGTH]; 150}; 151 152 153class ThreadPriorityChangedEvent : public DebugEvent { 154public: 155 ThreadPriorityChangedEvent(team_id team, 156 thread_id thread, thread_id changedThread, 157 int32 newPriority); 158 159 thread_id ChangedThread() const { return fChangedThread; } 160 int32 NewPriority() const { return fNewPriority; } 161 162private: 163 thread_id fChangedThread; 164 int32 fNewPriority; 165}; 166 167 168class ThreadDeletedEvent : public DebugEvent { 169public: 170 ThreadDeletedEvent(team_id team, 171 thread_id thread); 172}; 173 174 175class ImageCreatedEvent : public DebugEvent { 176public: 177 ImageCreatedEvent(team_id team, 178 thread_id thread, const ImageInfo& info); 179 180 const ImageInfo& GetImageInfo() const { return fInfo; } 181 182private: 183 ImageInfo fInfo; 184}; 185 186 187class ImageDeletedEvent : public DebugEvent { 188public: 189 ImageDeletedEvent(team_id team, 190 thread_id thread, const ImageInfo& info); 191 192 const ImageInfo& GetImageInfo() const { return fInfo; } 193 194private: 195 ImageInfo fInfo; 196}; 197 198 199class HandedOverEvent : public DebugEvent { 200public: 201 HandedOverEvent(team_id team, 202 thread_id thread, thread_id causingThread); 203 204 thread_id CausingThread() const { return fCausingThread; } 205 206private: 207 thread_id fCausingThread; 208}; 209 210 211#endif // DEBUG_EVENT_H 212