153446ebfSIngo Weinhold /*
253446ebfSIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
353446ebfSIngo Weinhold * Distributed under the terms of the MIT License.
453446ebfSIngo Weinhold */
553446ebfSIngo Weinhold
653446ebfSIngo Weinhold
753446ebfSIngo Weinhold #include <DebugMessageHandler.h>
853446ebfSIngo Weinhold
953446ebfSIngo Weinhold
~BDebugMessageHandler()1053446ebfSIngo Weinhold BDebugMessageHandler::~BDebugMessageHandler()
1153446ebfSIngo Weinhold {
1253446ebfSIngo Weinhold }
1353446ebfSIngo Weinhold
1453446ebfSIngo Weinhold
1553446ebfSIngo Weinhold /*! Handles the supplied debugger message.
1653446ebfSIngo Weinhold Can be overridded by subclasses. The base class implementation calls the
1753446ebfSIngo Weinhold respective Handle*() hook for the message.
1853446ebfSIngo Weinhold
1953446ebfSIngo Weinhold \param messageCode The (port) message code identifying the debugger message.
2053446ebfSIngo Weinhold \param message The message data.
2153446ebfSIngo Weinhold \return \c true, if the caller is supposed to continue the thread, \c false
2253446ebfSIngo Weinhold otherwise.
2353446ebfSIngo Weinhold */
2453446ebfSIngo Weinhold bool
HandleDebugMessage(int32 messageCode,const debug_debugger_message_data & message)2553446ebfSIngo Weinhold BDebugMessageHandler::HandleDebugMessage(int32 messageCode,
2653446ebfSIngo Weinhold const debug_debugger_message_data& message)
2753446ebfSIngo Weinhold {
2853446ebfSIngo Weinhold switch (messageCode) {
2953446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED:
3053446ebfSIngo Weinhold return HandleThreadDebugged(message.thread_debugged);
3153446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_DEBUGGER_CALL:
3253446ebfSIngo Weinhold return HandleDebuggerCall(message.debugger_call);
3353446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT:
3453446ebfSIngo Weinhold return HandleBreakpointHit(message.breakpoint_hit);
3553446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT:
3653446ebfSIngo Weinhold return HandleWatchpointHit(message.watchpoint_hit);
3753446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_SINGLE_STEP:
3853446ebfSIngo Weinhold return HandleSingleStep(message.single_step);
3953446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_PRE_SYSCALL:
4053446ebfSIngo Weinhold return HandlePreSyscall(message.pre_syscall);
4153446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_POST_SYSCALL:
4253446ebfSIngo Weinhold return HandlePostSyscall(message.post_syscall);
4353446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED:
4453446ebfSIngo Weinhold return HandleSignalReceived(message.signal_received);
4553446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED:
4653446ebfSIngo Weinhold return HandleExceptionOccurred(message.exception_occurred);
4753446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_TEAM_CREATED:
4853446ebfSIngo Weinhold return HandleTeamCreated(message.team_created);
4953446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_TEAM_DELETED:
5053446ebfSIngo Weinhold return HandleTeamDeleted(message.team_deleted);
5153446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_TEAM_EXEC:
5253446ebfSIngo Weinhold return HandleTeamExec(message.team_exec);
5353446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_THREAD_CREATED:
5453446ebfSIngo Weinhold return HandleThreadCreated(message.thread_created);
5553446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_THREAD_DELETED:
5653446ebfSIngo Weinhold return HandleThreadDeleted(message.thread_deleted);
5753446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_IMAGE_CREATED:
5853446ebfSIngo Weinhold return HandleImageCreated(message.image_created);
5953446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_IMAGE_DELETED:
6053446ebfSIngo Weinhold return HandleImageDeleted(message.image_deleted);
6153446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_PROFILER_UPDATE:
6253446ebfSIngo Weinhold return HandleProfilerUpdate(message.profiler_update);
6353446ebfSIngo Weinhold case B_DEBUGGER_MESSAGE_HANDED_OVER:
6453446ebfSIngo Weinhold return HandleHandedOver(message.handed_over);
6553446ebfSIngo Weinhold default:
6653446ebfSIngo Weinhold return true;
6753446ebfSIngo Weinhold }
6853446ebfSIngo Weinhold }
6953446ebfSIngo Weinhold
7053446ebfSIngo Weinhold
7153446ebfSIngo Weinhold bool
HandleThreadDebugged(const debug_thread_debugged & message)7253446ebfSIngo Weinhold BDebugMessageHandler::HandleThreadDebugged(const debug_thread_debugged& message)
7353446ebfSIngo Weinhold {
74*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_DEBUGGED,
75*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
7653446ebfSIngo Weinhold }
7753446ebfSIngo Weinhold
7853446ebfSIngo Weinhold
7953446ebfSIngo Weinhold bool
HandleDebuggerCall(const debug_debugger_call & message)8053446ebfSIngo Weinhold BDebugMessageHandler::HandleDebuggerCall(const debug_debugger_call& message)
8153446ebfSIngo Weinhold {
82*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_DEBUGGER_CALL,
83*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
8453446ebfSIngo Weinhold }
8553446ebfSIngo Weinhold
8653446ebfSIngo Weinhold
8753446ebfSIngo Weinhold bool
HandleBreakpointHit(const debug_breakpoint_hit & message)8853446ebfSIngo Weinhold BDebugMessageHandler::HandleBreakpointHit(const debug_breakpoint_hit& message)
8953446ebfSIngo Weinhold {
90*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_BREAKPOINT_HIT,
91*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
9253446ebfSIngo Weinhold }
9353446ebfSIngo Weinhold
9453446ebfSIngo Weinhold
9553446ebfSIngo Weinhold bool
HandleWatchpointHit(const debug_watchpoint_hit & message)9653446ebfSIngo Weinhold BDebugMessageHandler::HandleWatchpointHit(const debug_watchpoint_hit& message)
9753446ebfSIngo Weinhold {
98*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_WATCHPOINT_HIT,
99*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
10053446ebfSIngo Weinhold }
10153446ebfSIngo Weinhold
10253446ebfSIngo Weinhold
10353446ebfSIngo Weinhold bool
HandleSingleStep(const debug_single_step & message)10453446ebfSIngo Weinhold BDebugMessageHandler::HandleSingleStep(const debug_single_step& message)
10553446ebfSIngo Weinhold {
106*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_SINGLE_STEP,
107*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
10853446ebfSIngo Weinhold }
10953446ebfSIngo Weinhold
11053446ebfSIngo Weinhold
11153446ebfSIngo Weinhold bool
HandlePreSyscall(const debug_pre_syscall & message)11253446ebfSIngo Weinhold BDebugMessageHandler::HandlePreSyscall(const debug_pre_syscall& message)
11353446ebfSIngo Weinhold {
114*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_PRE_SYSCALL,
115*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
11653446ebfSIngo Weinhold }
11753446ebfSIngo Weinhold
11853446ebfSIngo Weinhold
11953446ebfSIngo Weinhold bool
HandlePostSyscall(const debug_post_syscall & message)12053446ebfSIngo Weinhold BDebugMessageHandler::HandlePostSyscall(const debug_post_syscall& message)
12153446ebfSIngo Weinhold {
122*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_POST_SYSCALL,
123*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
12453446ebfSIngo Weinhold }
12553446ebfSIngo Weinhold
12653446ebfSIngo Weinhold
12753446ebfSIngo Weinhold bool
HandleSignalReceived(const debug_signal_received & message)12853446ebfSIngo Weinhold BDebugMessageHandler::HandleSignalReceived(const debug_signal_received& message)
12953446ebfSIngo Weinhold {
130*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED,
131*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
13253446ebfSIngo Weinhold }
13353446ebfSIngo Weinhold
13453446ebfSIngo Weinhold
13553446ebfSIngo Weinhold bool
HandleExceptionOccurred(const debug_exception_occurred & message)13653446ebfSIngo Weinhold BDebugMessageHandler::HandleExceptionOccurred(
13753446ebfSIngo Weinhold const debug_exception_occurred& message)
13853446ebfSIngo Weinhold {
139*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED,
140*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
14153446ebfSIngo Weinhold }
14253446ebfSIngo Weinhold
14353446ebfSIngo Weinhold
14453446ebfSIngo Weinhold bool
HandleTeamCreated(const debug_team_created & message)14553446ebfSIngo Weinhold BDebugMessageHandler::HandleTeamCreated(const debug_team_created& message)
14653446ebfSIngo Weinhold {
147*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_CREATED,
148*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
14953446ebfSIngo Weinhold }
15053446ebfSIngo Weinhold
15153446ebfSIngo Weinhold
15253446ebfSIngo Weinhold bool
HandleTeamDeleted(const debug_team_deleted & message)15353446ebfSIngo Weinhold BDebugMessageHandler::HandleTeamDeleted(const debug_team_deleted& message)
15453446ebfSIngo Weinhold {
155*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_DELETED,
156*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
15753446ebfSIngo Weinhold }
15853446ebfSIngo Weinhold
15953446ebfSIngo Weinhold
16053446ebfSIngo Weinhold bool
HandleTeamExec(const debug_team_exec & message)16153446ebfSIngo Weinhold BDebugMessageHandler::HandleTeamExec(const debug_team_exec& message)
16253446ebfSIngo Weinhold {
163*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_TEAM_EXEC,
164*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
16553446ebfSIngo Weinhold }
16653446ebfSIngo Weinhold
16753446ebfSIngo Weinhold
16853446ebfSIngo Weinhold bool
HandleThreadCreated(const debug_thread_created & message)16953446ebfSIngo Weinhold BDebugMessageHandler::HandleThreadCreated(const debug_thread_created& message)
17053446ebfSIngo Weinhold {
171*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_CREATED,
172*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
17353446ebfSIngo Weinhold }
17453446ebfSIngo Weinhold
17553446ebfSIngo Weinhold
17653446ebfSIngo Weinhold bool
HandleThreadDeleted(const debug_thread_deleted & message)17753446ebfSIngo Weinhold BDebugMessageHandler::HandleThreadDeleted(const debug_thread_deleted& message)
17853446ebfSIngo Weinhold {
179*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_THREAD_DELETED,
180*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
18153446ebfSIngo Weinhold }
18253446ebfSIngo Weinhold
18353446ebfSIngo Weinhold
18453446ebfSIngo Weinhold bool
HandleImageCreated(const debug_image_created & message)18553446ebfSIngo Weinhold BDebugMessageHandler::HandleImageCreated(const debug_image_created& message)
18653446ebfSIngo Weinhold {
187*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_IMAGE_CREATED,
188*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
18953446ebfSIngo Weinhold }
19053446ebfSIngo Weinhold
19153446ebfSIngo Weinhold
19253446ebfSIngo Weinhold bool
HandleImageDeleted(const debug_image_deleted & message)19353446ebfSIngo Weinhold BDebugMessageHandler::HandleImageDeleted(const debug_image_deleted& message)
19453446ebfSIngo Weinhold {
195*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_IMAGE_DELETED,
196*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
19753446ebfSIngo Weinhold }
19853446ebfSIngo Weinhold
19953446ebfSIngo Weinhold
20053446ebfSIngo Weinhold bool
HandleProfilerUpdate(const debug_profiler_update & message)20153446ebfSIngo Weinhold BDebugMessageHandler::HandleProfilerUpdate(const debug_profiler_update& message)
20253446ebfSIngo Weinhold {
203*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_PROFILER_UPDATE,
204*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
20553446ebfSIngo Weinhold }
20653446ebfSIngo Weinhold
20753446ebfSIngo Weinhold
20853446ebfSIngo Weinhold bool
HandleHandedOver(const debug_handed_over & message)20953446ebfSIngo Weinhold BDebugMessageHandler::HandleHandedOver(const debug_handed_over& message)
21053446ebfSIngo Weinhold {
211*64d5a0a4SIngo Weinhold return UnhandledDebugMessage(B_DEBUGGER_MESSAGE_HANDED_OVER,
212*64d5a0a4SIngo Weinhold (const debug_debugger_message_data&)message);
213*64d5a0a4SIngo Weinhold }
214*64d5a0a4SIngo Weinhold
215*64d5a0a4SIngo Weinhold
216*64d5a0a4SIngo Weinhold /*! Called by the base class versions of the specific Handle*() methods.
217*64d5a0a4SIngo Weinhold Can be overridded to handle any message not handled otherwise.
218*64d5a0a4SIngo Weinhold */
219*64d5a0a4SIngo Weinhold bool
UnhandledDebugMessage(int32 messageCode,const debug_debugger_message_data & message)220*64d5a0a4SIngo Weinhold BDebugMessageHandler::UnhandledDebugMessage(int32 messageCode,
221*64d5a0a4SIngo Weinhold const debug_debugger_message_data& message)
222*64d5a0a4SIngo Weinhold {
22353446ebfSIngo Weinhold return true;
22453446ebfSIngo Weinhold }
225