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