2009-06-16 00:25:36 +00: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
|
|
|
|
|
2009-07-22 19:20:06 +00:00
|
|
|
|
2009-06-16 00:25:36 +00:00
|
|
|
#include <debugger.h>
|
2009-06-16 21:47:49 +00:00
|
|
|
#include <Looper.h>
|
|
|
|
|
2009-06-17 13:40:10 +00:00
|
|
|
#include <debug_support.h>
|
2009-06-16 21:47:49 +00:00
|
|
|
|
2009-06-18 17:57:37 +00:00
|
|
|
#include "DebugEvent.h"
|
2009-06-19 22:13:32 +00:00
|
|
|
#include "Team.h"
|
2009-06-16 21:47:49 +00:00
|
|
|
#include "TeamWindow.h"
|
2009-06-24 01:46:38 +00:00
|
|
|
#include "ThreadHandler.h"
|
2009-06-19 15:09:56 +00:00
|
|
|
#include "Worker.h"
|
2009-06-16 00:25:36 +00:00
|
|
|
|
|
|
|
|
2009-06-18 17:57:37 +00:00
|
|
|
class DebuggerInterface;
|
2009-07-01 22:09:33 +00:00
|
|
|
class FileManager;
|
2009-06-27 21:09:21 +00:00
|
|
|
class TeamDebugInfo;
|
2009-06-16 00:25:36 +00:00
|
|
|
|
|
|
|
|
2009-06-24 00:16:22 +00:00
|
|
|
class TeamDebugger : public BLooper, private TeamWindow::Listener,
|
2009-06-19 22:13:32 +00:00
|
|
|
private JobListener, private Team::Listener {
|
2009-06-16 00:25:36 +00:00
|
|
|
public:
|
2009-06-24 00:16:22 +00:00
|
|
|
class Listener;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TeamDebugger(Listener* listener);
|
2009-06-16 00:25:36 +00:00
|
|
|
~TeamDebugger();
|
|
|
|
|
2009-06-16 21:47:49 +00:00
|
|
|
status_t Init(team_id teamID, thread_id threadID,
|
|
|
|
bool stopInMain);
|
2009-06-16 00:25:36 +00:00
|
|
|
|
2009-06-16 21:47:49 +00:00
|
|
|
team_id TeamID() const { return fTeamID; }
|
|
|
|
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
2009-06-16 00:25:36 +00:00
|
|
|
|
2009-06-24 00:16:22 +00:00
|
|
|
private:
|
2009-06-18 21:45:14 +00:00
|
|
|
// TeamWindow::Listener
|
2009-07-18 23:52:16 +00:00
|
|
|
virtual void FunctionSourceCodeRequested(
|
2009-07-07 20:47:39 +00:00
|
|
|
FunctionInstance* function);
|
2009-07-18 23:52:16 +00:00
|
|
|
virtual void ImageDebugInfoRequested(Image* image);
|
|
|
|
virtual void StackFrameValueRequested(::Thread* thread,
|
|
|
|
StackFrame* stackFrame, Variable* variable,
|
|
|
|
TypeComponentPath* path);
|
|
|
|
virtual void ThreadActionRequested(thread_id threadID,
|
|
|
|
uint32 action);
|
2009-06-22 21:51:32 +00:00
|
|
|
virtual void SetBreakpointRequested(target_addr_t address,
|
|
|
|
bool enabled);
|
|
|
|
virtual void ClearBreakpointRequested(target_addr_t address);
|
2009-07-18 23:52:16 +00:00
|
|
|
virtual bool TeamWindowQuitRequested();
|
2009-06-18 21:45:14 +00:00
|
|
|
|
2009-06-19 15:09:56 +00:00
|
|
|
// JobListener
|
|
|
|
virtual void JobDone(Job* job);
|
|
|
|
virtual void JobFailed(Job* job);
|
|
|
|
virtual void JobAborted(Job* job);
|
|
|
|
|
2009-06-19 22:13:32 +00: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-07-01 22:09:33 +00:00
|
|
|
private:
|
|
|
|
struct ImageHandler;
|
|
|
|
struct ImageHandlerHashDefinition;
|
|
|
|
typedef OpenHashTable<ImageHandlerHashDefinition> ImageHandlerTable;
|
|
|
|
|
2009-06-16 00:25:36 +00:00
|
|
|
private:
|
|
|
|
static status_t _DebugEventListenerEntry(void* data);
|
|
|
|
status_t _DebugEventListener();
|
|
|
|
|
2009-06-18 17:57:37 +00:00
|
|
|
void _HandleDebuggerMessage(DebugEvent* event);
|
2009-06-16 00:25:36 +00:00
|
|
|
|
2009-06-17 13:40:10 +00:00
|
|
|
bool _HandleThreadCreated(
|
2009-06-18 17:57:37 +00:00
|
|
|
ThreadCreatedEvent* event);
|
2009-06-17 13:40:10 +00:00
|
|
|
bool _HandleThreadDeleted(
|
2009-06-18 17:57:37 +00:00
|
|
|
ThreadDeletedEvent* event);
|
2009-06-17 13:40:10 +00:00
|
|
|
bool _HandleImageCreated(
|
2009-06-18 17:57:37 +00:00
|
|
|
ImageCreatedEvent* event);
|
2009-06-17 13:40:10 +00:00
|
|
|
bool _HandleImageDeleted(
|
2009-06-18 17:57:37 +00:00
|
|
|
ImageDeletedEvent* event);
|
2009-06-17 13:40:10 +00:00
|
|
|
|
2009-07-01 22:09:33 +00:00
|
|
|
void _HandleImageFileChanged(image_id imageID);
|
|
|
|
|
2009-06-22 21:51:32 +00:00
|
|
|
void _HandleSetUserBreakpoint(target_addr_t address,
|
|
|
|
bool enabled);
|
|
|
|
void _HandleClearUserBreakpoint(
|
|
|
|
target_addr_t address);
|
2009-06-18 21:45:14 +00:00
|
|
|
|
2009-06-24 01:46:38 +00:00
|
|
|
ThreadHandler* _GetThreadHandler(thread_id threadID);
|
2009-06-19 22:13:32 +00:00
|
|
|
|
2009-07-03 14:23:19 +00:00
|
|
|
status_t _AddImage(const ImageInfo& imageInfo,
|
|
|
|
Image** _image = NULL);
|
2009-07-01 22:09:33 +00:00
|
|
|
|
2009-06-22 21:51:32 +00:00
|
|
|
void _NotifyUser(const char* title,
|
|
|
|
const char* text,...);
|
|
|
|
|
2009-06-16 00:25:36 +00:00
|
|
|
private:
|
2009-06-24 00:16:22 +00:00
|
|
|
Listener* fListener;
|
2009-06-16 21:47:49 +00:00
|
|
|
::Team* fTeam;
|
2009-06-16 00:25:36 +00:00
|
|
|
team_id fTeamID;
|
2009-06-24 01:46:38 +00:00
|
|
|
ThreadHandlerTable fThreadHandlers;
|
|
|
|
// protected by the team lock
|
2009-07-01 22:09:33 +00:00
|
|
|
ImageHandlerTable* fImageHandlers;
|
2009-06-18 17:57:37 +00:00
|
|
|
DebuggerInterface* fDebuggerInterface;
|
2009-06-27 21:09:21 +00:00
|
|
|
TeamDebugInfo* fTeamDebugInfo;
|
2009-07-01 22:09:33 +00:00
|
|
|
FileManager* fFileManager;
|
2009-06-19 15:09:56 +00:00
|
|
|
Worker* fWorker;
|
2009-06-25 23:51:09 +00:00
|
|
|
BreakpointManager* fBreakpointManager;
|
2009-06-16 00:25:36 +00:00
|
|
|
thread_id fDebugEventListener;
|
2009-06-16 21:47:49 +00:00
|
|
|
TeamWindow* fTeamWindow;
|
2009-06-16 00:25:36 +00:00
|
|
|
volatile bool fTerminating;
|
2009-06-23 13:09:50 +00:00
|
|
|
bool fKillTeamOnQuit;
|
2009-06-16 00:25:36 +00:00
|
|
|
};
|
|
|
|
|
2009-06-24 00:16:22 +00:00
|
|
|
|
|
|
|
class TeamDebugger::Listener {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void TeamDebuggerQuit(TeamDebugger* debugger) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-16 00:25:36 +00:00
|
|
|
#endif // TEAM_DEBUGGER_H
|