2009-06-16 04:25:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef TEAM_DEBUGGER_H
|
|
|
|
#define TEAM_DEBUGGER_H
|
|
|
|
|
|
|
|
#include <debugger.h>
|
2009-06-17 01:47:49 +04:00
|
|
|
#include <Looper.h>
|
|
|
|
|
2009-06-17 17:40:10 +04:00
|
|
|
#include <debug_support.h>
|
2009-06-17 01:47:49 +04:00
|
|
|
|
2009-06-18 21:57:37 +04:00
|
|
|
#include "DebugEvent.h"
|
2009-06-20 02:13:32 +04:00
|
|
|
#include "Team.h"
|
2009-06-17 01:47:49 +04:00
|
|
|
#include "TeamWindow.h"
|
2009-06-19 19:09:56 +04:00
|
|
|
#include "Worker.h"
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
|
2009-06-18 21:57:37 +04:00
|
|
|
class DebuggerInterface;
|
2009-06-18 04:35:12 +04:00
|
|
|
class TeamDebugModel;
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-23 16:14:05 +04:00
|
|
|
enum {
|
|
|
|
MSG_DEBUGGER_QUIT_REQUESTED = 'dbqt'
|
|
|
|
};
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-20 02:13:32 +04:00
|
|
|
class TeamDebugger : private BLooper, private TeamWindow::Listener,
|
|
|
|
private JobListener, private Team::Listener {
|
2009-06-16 04:25:36 +04:00
|
|
|
public:
|
|
|
|
TeamDebugger();
|
|
|
|
~TeamDebugger();
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
status_t Init(team_id teamID, thread_id threadID,
|
|
|
|
bool stopInMain);
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
team_id TeamID() const { return fTeamID; }
|
|
|
|
|
2009-06-23 16:14:05 +04:00
|
|
|
void DeleteSelf();
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
private:
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-19 01:45:14 +04:00
|
|
|
// TeamWindow::Listener
|
2009-06-21 17:17:21 +04:00
|
|
|
virtual void StackFrameSourceCodeRequested(
|
|
|
|
TeamWindow* window, StackFrame* frame);
|
2009-06-19 01:45:14 +04:00
|
|
|
virtual void ThreadActionRequested(TeamWindow* window,
|
|
|
|
thread_id threadID, uint32 action);
|
2009-06-23 01:51:32 +04:00
|
|
|
virtual void SetBreakpointRequested(target_addr_t address,
|
|
|
|
bool enabled);
|
|
|
|
virtual void ClearBreakpointRequested(target_addr_t address);
|
2009-06-19 01:45:14 +04:00
|
|
|
virtual bool TeamWindowQuitRequested(TeamWindow* window);
|
|
|
|
|
2009-06-19 19:09:56 +04:00
|
|
|
// JobListener
|
|
|
|
virtual void JobDone(Job* job);
|
|
|
|
virtual void JobFailed(Job* job);
|
|
|
|
virtual void JobAborted(Job* job);
|
|
|
|
|
2009-06-20 02:13:32 +04:00
|
|
|
// Team::Listener
|
|
|
|
virtual void ThreadStateChanged(
|
|
|
|
const ::Team::ThreadEvent& event);
|
|
|
|
virtual void ThreadCpuStateChanged(
|
|
|
|
const ::Team::ThreadEvent& event);
|
|
|
|
virtual void ThreadStackTraceChanged(
|
|
|
|
const ::Team::ThreadEvent& event);
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
private:
|
|
|
|
static status_t _DebugEventListenerEntry(void* data);
|
|
|
|
status_t _DebugEventListener();
|
|
|
|
|
2009-06-18 21:57:37 +04:00
|
|
|
void _HandleDebuggerMessage(DebugEvent* event);
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-19 01:45:14 +04:00
|
|
|
bool _HandleThreadStopped(thread_id threadID,
|
|
|
|
CpuState* cpuState);
|
|
|
|
|
|
|
|
bool _HandleThreadDebugged(
|
|
|
|
ThreadDebuggedEvent* event);
|
|
|
|
bool _HandleDebuggerCall(
|
|
|
|
DebuggerCallEvent* event);
|
|
|
|
bool _HandleBreakpointHit(
|
|
|
|
BreakpointHitEvent* event);
|
|
|
|
bool _HandleWatchpointHit(
|
|
|
|
WatchpointHitEvent* event);
|
|
|
|
bool _HandleSingleStep(
|
|
|
|
SingleStepEvent* event);
|
|
|
|
bool _HandleExceptionOccurred(
|
|
|
|
ExceptionOccurredEvent* event);
|
2009-06-17 17:40:10 +04:00
|
|
|
bool _HandleThreadCreated(
|
2009-06-18 21:57:37 +04:00
|
|
|
ThreadCreatedEvent* event);
|
2009-06-17 17:40:10 +04:00
|
|
|
bool _HandleThreadDeleted(
|
2009-06-18 21:57:37 +04:00
|
|
|
ThreadDeletedEvent* event);
|
2009-06-17 17:40:10 +04:00
|
|
|
bool _HandleImageCreated(
|
2009-06-18 21:57:37 +04:00
|
|
|
ImageCreatedEvent* event);
|
2009-06-17 17:40:10 +04:00
|
|
|
bool _HandleImageDeleted(
|
2009-06-18 21:57:37 +04:00
|
|
|
ImageDeletedEvent* event);
|
2009-06-17 17:40:10 +04:00
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
void _UpdateThreadState(::Thread* thread);
|
2009-06-19 19:09:56 +04:00
|
|
|
void _SetThreadState(::Thread* thread, uint32 state,
|
|
|
|
CpuState* cpuState);
|
2009-06-18 04:35:12 +04:00
|
|
|
|
2009-06-23 01:51:32 +04:00
|
|
|
status_t _SetUserBreakpoint(target_addr_t address,
|
|
|
|
bool enabled);
|
|
|
|
|
2009-06-19 01:45:14 +04:00
|
|
|
void _HandleThreadAction(thread_id threadID,
|
|
|
|
uint32 action);
|
2009-06-23 01:51:32 +04:00
|
|
|
void _HandleSetUserBreakpoint(target_addr_t address,
|
|
|
|
bool enabled);
|
|
|
|
void _HandleClearUserBreakpoint(
|
|
|
|
target_addr_t address);
|
2009-06-19 01:45:14 +04:00
|
|
|
|
2009-06-20 02:13:32 +04:00
|
|
|
void _HandleThreadStateChanged(thread_id threadID);
|
|
|
|
void _HandleCpuStateChanged(thread_id threadID);
|
|
|
|
void _HandleStackTraceChanged(thread_id threadID);
|
|
|
|
|
2009-06-23 01:51:32 +04:00
|
|
|
void _NotifyUser(const char* title,
|
|
|
|
const char* text,...);
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
private:
|
2009-06-17 01:47:49 +04:00
|
|
|
::Team* fTeam;
|
2009-06-18 04:35:12 +04:00
|
|
|
TeamDebugModel* fDebugModel;
|
2009-06-16 04:25:36 +04:00
|
|
|
team_id fTeamID;
|
|
|
|
port_id fNubPort;
|
2009-06-18 21:57:37 +04:00
|
|
|
DebuggerInterface* fDebuggerInterface;
|
2009-06-19 19:09:56 +04:00
|
|
|
Worker* fWorker;
|
2009-06-16 04:25:36 +04:00
|
|
|
thread_id fDebugEventListener;
|
2009-06-17 01:47:49 +04:00
|
|
|
TeamWindow* fTeamWindow;
|
2009-06-16 04:25:36 +04:00
|
|
|
volatile bool fTerminating;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TEAM_DEBUGGER_H
|