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