1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "DebugEvent.h" 7 8 #include "CpuState.h" 9 10 11 // #pragma mark - DebugEvent 12 13 14 DebugEvent::DebugEvent(int32 eventType, team_id team, 15 thread_id thread) 16 : 17 fEventType(eventType), 18 fTeam(team), 19 fThread(thread), 20 fThreadStopped(false) 21 { 22 } 23 24 25 DebugEvent::~DebugEvent() 26 { 27 } 28 29 30 void 31 DebugEvent::SetThreadStopped(bool stopped) 32 { 33 fThreadStopped = stopped; 34 } 35 36 37 // #pragma mark - CpuStateEvent 38 39 40 CpuStateEvent::CpuStateEvent(debug_debugger_message eventType, team_id team, 41 thread_id thread, CpuState* state) 42 : 43 DebugEvent(eventType, team, thread), 44 fCpuState(state) 45 { 46 if (fCpuState != NULL) 47 fCpuState->AcquireReference(); 48 } 49 50 51 CpuStateEvent::~CpuStateEvent() 52 { 53 if (fCpuState != NULL) 54 fCpuState->ReleaseReference(); 55 } 56 57 58 // #pragma mark - ThreadDebuggedEvent 59 60 61 ThreadDebuggedEvent::ThreadDebuggedEvent(team_id team, thread_id thread) 62 : 63 DebugEvent(B_DEBUGGER_MESSAGE_THREAD_DEBUGGED, team, thread) 64 { 65 } 66 67 68 // #pragma mark - DebuggerCallEvent 69 70 71 DebuggerCallEvent::DebuggerCallEvent(team_id team, thread_id thread, 72 target_addr_t message) 73 : 74 DebugEvent(B_DEBUGGER_MESSAGE_DEBUGGER_CALL, team, thread), 75 fMessage(message) 76 { 77 } 78 79 80 // #pragma mark - BreakpointHitEvent 81 82 83 BreakpointHitEvent::BreakpointHitEvent(team_id team, thread_id thread, 84 CpuState* state) 85 : 86 CpuStateEvent(B_DEBUGGER_MESSAGE_BREAKPOINT_HIT, team, thread, state) 87 { 88 } 89 90 91 // #pragma mark - WatchpointHitEvent 92 93 94 WatchpointHitEvent::WatchpointHitEvent(team_id team, thread_id thread, 95 CpuState* state) 96 : 97 CpuStateEvent(B_DEBUGGER_MESSAGE_WATCHPOINT_HIT, team, thread, state) 98 { 99 } 100 101 102 103 // #pragma mark - SingleStepEvent 104 105 106 SingleStepEvent::SingleStepEvent(team_id team, thread_id thread, 107 CpuState* state) 108 : 109 CpuStateEvent(B_DEBUGGER_MESSAGE_SINGLE_STEP, team, thread, state) 110 { 111 } 112 113 114 // #pragma mark - ExceptionOccurredEvent 115 116 117 ExceptionOccurredEvent::ExceptionOccurredEvent(team_id team, thread_id thread, 118 debug_exception_type exception) 119 : 120 DebugEvent(B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED, team, thread), 121 fException(exception) 122 { 123 } 124 125 126 // #pragma mark - TeamDeletedEvent 127 128 129 TeamDeletedEvent::TeamDeletedEvent(team_id team, thread_id thread) 130 : 131 DebugEvent(B_DEBUGGER_MESSAGE_TEAM_DELETED, team, thread) 132 { 133 } 134 135 136 // #pragma mark - TeamExecEvent 137 138 139 TeamExecEvent::TeamExecEvent(team_id team, thread_id thread) 140 : 141 DebugEvent(B_DEBUGGER_MESSAGE_TEAM_EXEC, team, thread) 142 { 143 } 144 145 146 // #pragma mark - ThreadCreatedEvent 147 148 149 ThreadCreatedEvent::ThreadCreatedEvent(team_id team, thread_id thread, 150 thread_id newThread) 151 : 152 DebugEvent(B_DEBUGGER_MESSAGE_THREAD_CREATED, team, thread), 153 fNewThread(newThread) 154 { 155 } 156 157 158 // #pragma mark - ThreadRenamedEvent 159 160 161 ThreadRenamedEvent::ThreadRenamedEvent(team_id team, thread_id thread, 162 thread_id renamedThread, const char* newName) 163 : 164 DebugEvent(DEBUGGER_MESSAGE_THREAD_RENAMED, team, thread), 165 fRenamedThread(renamedThread) 166 { 167 strlcpy(fName, newName, sizeof(fName)); 168 } 169 170 171 // #pragma mark - ThreadPriorityChangedEvent 172 173 174 ThreadPriorityChangedEvent::ThreadPriorityChangedEvent(team_id team, 175 thread_id thread, thread_id changedThread, int32 newPriority) 176 : 177 DebugEvent(DEBUGGER_MESSAGE_THREAD_PRIORITY_CHANGED, team, thread), 178 fChangedThread(changedThread), 179 fNewPriority(newPriority) 180 { 181 } 182 183 184 // #pragma mark - ThreadDeletedEvent 185 186 187 ThreadDeletedEvent::ThreadDeletedEvent(team_id team, thread_id thread) 188 : 189 DebugEvent(B_DEBUGGER_MESSAGE_THREAD_DELETED, team, thread) 190 { 191 } 192 193 194 // #pragma mark - ImageCreatedEvent 195 196 197 ImageCreatedEvent::ImageCreatedEvent(team_id team, thread_id thread, 198 const ImageInfo& info) 199 : 200 DebugEvent(B_DEBUGGER_MESSAGE_IMAGE_CREATED, team, thread), 201 fInfo(info) 202 { 203 } 204 205 206 // #pragma mark - ImageDeletedEvent 207 208 209 ImageDeletedEvent::ImageDeletedEvent(team_id team, thread_id thread, 210 const ImageInfo& info) 211 : 212 DebugEvent(B_DEBUGGER_MESSAGE_IMAGE_DELETED, team, thread), 213 fInfo(info) 214 { 215 } 216 217 218 // #pragma mark - PostSyscallEvent 219 220 221 PostSyscallEvent::PostSyscallEvent(team_id team, thread_id thread, 222 const SyscallInfo& info) 223 : 224 DebugEvent(B_DEBUGGER_MESSAGE_POST_SYSCALL, team, thread), 225 fInfo(info) 226 { 227 } 228 229 230 // #pragma mark - HandedOverEvent 231 232 233 HandedOverEvent::HandedOverEvent(team_id team, thread_id thread, 234 thread_id causingThread) 235 : 236 DebugEvent(B_DEBUGGER_MESSAGE_HANDED_OVER, team, thread), 237 fCausingThread(causingThread) 238 { 239 } 240 241 242 // #pragma mark - SignalReceivedEvent 243 244 245 SignalReceivedEvent::SignalReceivedEvent(team_id team, thread_id thread, 246 const SignalInfo& info) 247 : 248 DebugEvent(B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED, team, thread), 249 fInfo(info) 250 { 251 } 252