1 /*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7 #include <DebugMessageHandler.h>
8
9
~BDebugMessageHandler()10 BDebugMessageHandler::~BDebugMessageHandler()
11 {
12 }
13
14
15 /*! Handles the supplied debugger message.
16 Can be overridded by subclasses. The base class implementation calls the
17 respective Handle*() hook for the message.
18
19 \param messageCode The (port) message code identifying the debugger message.
20 \param message The message data.
21 \return \c true, if the caller is supposed to continue the thread, \c false
22 otherwise.
23 */
24 bool
HandleDebugMessage(int32 messageCode,const debug_debugger_message_data & message)25 BDebugMessageHandler::HandleDebugMessage(int32 messageCode,
26 const debug_debugger_message_data& message)
27 {
28 switch (messageCode) {
29 case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED:
30 return HandleThreadDebugged(message.thread_debugged);
31 case B_DEBUGGER_MESSAGE_DEBUGGER_CALL:
32 return HandleDebuggerCall(message.debugger_call);
33 case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT:
34 return HandleBreakpointHit(message.breakpoint_hit);
35 case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT:
36 return HandleWatchpointHit(message.watchpoint_hit);
37 case B_DEBUGGER_MESSAGE_SINGLE_STEP:
38 return HandleSingleStep(message.single_step);
39 case B_DEBUGGER_MESSAGE_PRE_SYSCALL:
40 return HandlePreSyscall(message.pre_syscall);
41 case B_DEBUGGER_MESSAGE_POST_SYSCALL:
42 return HandlePostSyscall(message.post_syscall);
43 case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED:
44 return HandleSignalReceived(message.signal_received);
45 case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED:
46 return HandleExceptionOccurred(message.exception_occurred);
47 case B_DEBUGGER_MESSAGE_TEAM_CREATED:
48 return HandleTeamCreated(message.team_created);
49 case B_DEBUGGER_MESSAGE_TEAM_DELETED:
50 return HandleTeamDeleted(message.team_deleted);
51 case B_DEBUGGER_MESSAGE_TEAM_EXEC:
52 return HandleTeamExec(message.team_exec);
53 case B_DEBUGGER_MESSAGE_THREAD_CREATED:
54 return HandleThreadCreated(message.thread_created);
55 case B_DEBUGGER_MESSAGE_THREAD_DELETED:
56 return HandleThreadDeleted(message.thread_deleted);
57 case B_DEBUGGER_MESSAGE_IMAGE_CREATED:
58 return HandleImageCreated(message.image_created);
59 case B_DEBUGGER_MESSAGE_IMAGE_DELETED:
60 return HandleImageDeleted(message.image_deleted);
61 case B_DEBUGGER_MESSAGE_PROFILER_UPDATE:
62 return HandleProfilerUpdate(message.profiler_update);
63 case B_DEBUGGER_MESSAGE_HANDED_OVER:
64 return HandleHandedOver(message.handed_over);
65 default:
66 return true;
67 }
68 }
69
70
71 bool
HandleThreadDebugged(const debug_thread_debugged & message)72 BDebugMessageHandler::HandleThreadDebugged(const debug_thread_debugged& message)
73 {
74 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_DEBUGGED,
75 (const debug_debugger_message_data&)message);
76 }
77
78
79 bool
HandleDebuggerCall(const debug_debugger_call & message)80 BDebugMessageHandler::HandleDebuggerCall(const debug_debugger_call& message)
81 {
82 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_DEBUGGER_CALL,
83 (const debug_debugger_message_data&)message);
84 }
85
86
87 bool
HandleBreakpointHit(const debug_breakpoint_hit & message)88 BDebugMessageHandler::HandleBreakpointHit(const debug_breakpoint_hit& message)
89 {
90 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_BREAKPOINT_HIT,
91 (const debug_debugger_message_data&)message);
92 }
93
94
95 bool
HandleWatchpointHit(const debug_watchpoint_hit & message)96 BDebugMessageHandler::HandleWatchpointHit(const debug_watchpoint_hit& message)
97 {
98 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_WATCHPOINT_HIT,
99 (const debug_debugger_message_data&)message);
100 }
101
102
103 bool
HandleSingleStep(const debug_single_step & message)104 BDebugMessageHandler::HandleSingleStep(const debug_single_step& message)
105 {
106 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_SINGLE_STEP,
107 (const debug_debugger_message_data&)message);
108 }
109
110
111 bool
HandlePreSyscall(const debug_pre_syscall & message)112 BDebugMessageHandler::HandlePreSyscall(const debug_pre_syscall& message)
113 {
114 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_PRE_SYSCALL,
115 (const debug_debugger_message_data&)message);
116 }
117
118
119 bool
HandlePostSyscall(const debug_post_syscall & message)120 BDebugMessageHandler::HandlePostSyscall(const debug_post_syscall& message)
121 {
122 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_POST_SYSCALL,
123 (const debug_debugger_message_data&)message);
124 }
125
126
127 bool
HandleSignalReceived(const debug_signal_received & message)128 BDebugMessageHandler::HandleSignalReceived(const debug_signal_received& message)
129 {
130 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED,
131 (const debug_debugger_message_data&)message);
132 }
133
134
135 bool
HandleExceptionOccurred(const debug_exception_occurred & message)136 BDebugMessageHandler::HandleExceptionOccurred(
137 const debug_exception_occurred& message)
138 {
139 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED,
140 (const debug_debugger_message_data&)message);
141 }
142
143
144 bool
HandleTeamCreated(const debug_team_created & message)145 BDebugMessageHandler::HandleTeamCreated(const debug_team_created& message)
146 {
147 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_CREATED,
148 (const debug_debugger_message_data&)message);
149 }
150
151
152 bool
HandleTeamDeleted(const debug_team_deleted & message)153 BDebugMessageHandler::HandleTeamDeleted(const debug_team_deleted& message)
154 {
155 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_DELETED,
156 (const debug_debugger_message_data&)message);
157 }
158
159
160 bool
HandleTeamExec(const debug_team_exec & message)161 BDebugMessageHandler::HandleTeamExec(const debug_team_exec& message)
162 {
163 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_EXEC,
164 (const debug_debugger_message_data&)message);
165 }
166
167
168 bool
HandleThreadCreated(const debug_thread_created & message)169 BDebugMessageHandler::HandleThreadCreated(const debug_thread_created& message)
170 {
171 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_CREATED,
172 (const debug_debugger_message_data&)message);
173 }
174
175
176 bool
HandleThreadDeleted(const debug_thread_deleted & message)177 BDebugMessageHandler::HandleThreadDeleted(const debug_thread_deleted& message)
178 {
179 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_DELETED,
180 (const debug_debugger_message_data&)message);
181 }
182
183
184 bool
HandleImageCreated(const debug_image_created & message)185 BDebugMessageHandler::HandleImageCreated(const debug_image_created& message)
186 {
187 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_IMAGE_CREATED,
188 (const debug_debugger_message_data&)message);
189 }
190
191
192 bool
HandleImageDeleted(const debug_image_deleted & message)193 BDebugMessageHandler::HandleImageDeleted(const debug_image_deleted& message)
194 {
195 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_IMAGE_DELETED,
196 (const debug_debugger_message_data&)message);
197 }
198
199
200 bool
HandleProfilerUpdate(const debug_profiler_update & message)201 BDebugMessageHandler::HandleProfilerUpdate(const debug_profiler_update& message)
202 {
203 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_PROFILER_UPDATE,
204 (const debug_debugger_message_data&)message);
205 }
206
207
208 bool
HandleHandedOver(const debug_handed_over & message)209 BDebugMessageHandler::HandleHandedOver(const debug_handed_over& message)
210 {
211 return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_HANDED_OVER,
212 (const debug_debugger_message_data&)message);
213 }
214
215
216 /*! Called by the base class versions of the specific Handle*() methods.
217 Can be overridded to handle any message not handled otherwise.
218 */
219 bool
UnhandledDebugMessage(int32 messageCode,const debug_debugger_message_data & message)220 BDebugMessageHandler::UnhandledDebugMessage(int32 messageCode,
221 const debug_debugger_message_data& message)
222 {
223 return true;
224 }
225