Added a few classes to the debug kit:
* BDebugMessageHandler: Interface with hooks for handling of debug messages. * BDebugContext: Essentially a C++ wrapper for struct debug_context, with handy methods for controlling a debugged team. * BTeamDebugger: Proxy for a debugged team. Derived from BDebugContext. * BDebugLooper: Wraps a main debug message loop. Any number of BTeamDebuggers can be added and associated with BDebugMessageHandlers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35953 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DEBUG_CONTEXT_H
|
||||
#define _DEBUG_CONTEXT_H
|
||||
|
||||
|
||||
#include <debug_support.h>
|
||||
|
||||
|
||||
class BDebugContext {
|
||||
public:
|
||||
BDebugContext();
|
||||
~BDebugContext();
|
||||
|
||||
status_t Init(team_id team, port_id nubPort);
|
||||
void Uninit();
|
||||
|
||||
team_id Team() const { return fContext.team; }
|
||||
port_id NubPort() const { return fContext.nub_port; }
|
||||
port_id ReplyPort() const
|
||||
{ return fContext.reply_port; }
|
||||
|
||||
status_t SendDebugMessage(int32 messageCode,
|
||||
const void *message, size_t messageSize,
|
||||
void* reply, size_t replySize);
|
||||
|
||||
status_t SetTeamDebuggingFlags(int32 flags);
|
||||
|
||||
ssize_t ReadMemoryPartial(const void* address,
|
||||
void* buffer, size_t size);
|
||||
ssize_t ReadMemory(const void* address,
|
||||
void* buffer, size_t size);
|
||||
ssize_t ReadString(const void* address,
|
||||
char* buffer, size_t size);
|
||||
|
||||
status_t SetBreakpoint(void* address);
|
||||
status_t ClearBreakpoint(void* address);
|
||||
|
||||
status_t SetWatchpoint(void* address, uint32 type,
|
||||
int32 length);
|
||||
status_t ClearWatchpoint(void* address);
|
||||
|
||||
status_t ContinueThread(thread_id thread);
|
||||
status_t SetThreadDebuggingFlags(thread_id thread,
|
||||
int32 flags);
|
||||
status_t GetThreadCpuState(thread_id thread,
|
||||
debug_debugger_message* _messageCode,
|
||||
debug_cpu_state* cpuState);
|
||||
|
||||
protected:
|
||||
debug_context fContext;
|
||||
};
|
||||
|
||||
|
||||
#endif // _DEBUG_CONTEXT_H
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DEBUG_LOOPER_H
|
||||
#define _DEBUG_LOOPER_H
|
||||
|
||||
|
||||
#include <Locker.h>
|
||||
|
||||
#include <ObjectList.h>
|
||||
|
||||
|
||||
class BDebugMessageHandler;
|
||||
class BTeamDebugger;
|
||||
|
||||
|
||||
class BDebugLooper {
|
||||
public:
|
||||
BDebugLooper();
|
||||
virtual ~BDebugLooper();
|
||||
|
||||
status_t Init();
|
||||
|
||||
thread_id Run(bool spawnThread);
|
||||
void Quit();
|
||||
|
||||
status_t AddTeamDebugger(BTeamDebugger* debugger,
|
||||
BDebugMessageHandler* handler);
|
||||
bool RemoveTeamDebugger(BTeamDebugger* debugger);
|
||||
bool RemoveTeamDebugger(team_id team);
|
||||
|
||||
private:
|
||||
struct Debugger;
|
||||
|
||||
struct Job;
|
||||
struct JobList;
|
||||
struct AddDebuggerJob;
|
||||
struct RemoveDebuggerJob;
|
||||
|
||||
friend struct AddDebuggerJob;
|
||||
friend struct RemoveDebuggerJob;
|
||||
|
||||
typedef BObjectList<Debugger> DebuggerList;
|
||||
|
||||
private:
|
||||
static status_t _MessageLoopEntry(void* data);
|
||||
status_t _MessageLoop();
|
||||
|
||||
status_t _DoJob(Job* job);
|
||||
void _Notify();
|
||||
|
||||
private:
|
||||
BLocker fLock;
|
||||
thread_id fThread;
|
||||
bool fOwnsThread;
|
||||
bool fTerminating;
|
||||
bool fNotified;
|
||||
JobList* fJobs;
|
||||
sem_id fEventSemaphore;
|
||||
DebuggerList fDebuggers;
|
||||
};
|
||||
|
||||
|
||||
#endif // _DEBUG_LOOPER_H
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DEBUG_MESSAGE_HANDLER_H
|
||||
#define _DEBUG_MESSAGE_HANDLER_H
|
||||
|
||||
|
||||
#include <debugger.h>
|
||||
|
||||
|
||||
class BDebugMessageHandler {
|
||||
public:
|
||||
virtual ~BDebugMessageHandler();
|
||||
|
||||
virtual bool HandleDebugMessage(int32 messageCode,
|
||||
const debug_debugger_message_data& message);
|
||||
|
||||
virtual bool HandleThreadDebugged(
|
||||
const debug_thread_debugged& message);
|
||||
virtual bool HandleDebuggerCall(
|
||||
const debug_debugger_call& message);
|
||||
virtual bool HandleBreakpointHit(
|
||||
const debug_breakpoint_hit& message);
|
||||
virtual bool HandleWatchpointHit(
|
||||
const debug_watchpoint_hit& message);
|
||||
virtual bool HandleSingleStep(
|
||||
const debug_single_step& message);
|
||||
virtual bool HandlePreSyscall(
|
||||
const debug_pre_syscall& message);
|
||||
virtual bool HandlePostSyscall(
|
||||
const debug_post_syscall& message);
|
||||
virtual bool HandleSignalReceived(
|
||||
const debug_signal_received& message);
|
||||
virtual bool HandleExceptionOccurred(
|
||||
const debug_exception_occurred& message);
|
||||
virtual bool HandleTeamCreated(
|
||||
const debug_team_created& message);
|
||||
virtual bool HandleTeamDeleted(
|
||||
const debug_team_deleted& message);
|
||||
virtual bool HandleTeamExec(
|
||||
const debug_team_exec& message);
|
||||
virtual bool HandleThreadCreated(
|
||||
const debug_thread_created& message);
|
||||
virtual bool HandleThreadDeleted(
|
||||
const debug_thread_deleted& message);
|
||||
virtual bool HandleImageCreated(
|
||||
const debug_image_created& message);
|
||||
virtual bool HandleImageDeleted(
|
||||
const debug_image_deleted& message);
|
||||
virtual bool HandleProfilerUpdate(
|
||||
const debug_profiler_update& message);
|
||||
virtual bool HandleHandedOver(
|
||||
const debug_handed_over& message);
|
||||
};
|
||||
|
||||
|
||||
#endif // _DEBUG_MESSAGE_HANDLER_H
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TEAM_DEBUGGER_H
|
||||
#define _TEAM_DEBUGGER_H
|
||||
|
||||
|
||||
#include <debugger.h>
|
||||
|
||||
#include <DebugContext.h>
|
||||
|
||||
|
||||
class BPath;
|
||||
|
||||
|
||||
class BTeamDebugger : public BDebugContext {
|
||||
public:
|
||||
BTeamDebugger();
|
||||
~BTeamDebugger();
|
||||
|
||||
status_t Install(team_id team);
|
||||
status_t Uninstall();
|
||||
|
||||
status_t LoadProgram(const char* const* args,
|
||||
int32 argCount, bool traceLoading);
|
||||
|
||||
status_t ReadDebugMessage(int32& _messageCode,
|
||||
debug_debugger_message_data& messageBuffer);
|
||||
|
||||
port_id DebuggerPort() const { return fDebuggerPort; }
|
||||
|
||||
private:
|
||||
static thread_id _LoadProgram(const char* const* args,
|
||||
int32 argCount, bool traceLoading);
|
||||
static status_t _FindProgram(const char* programName,
|
||||
BPath& resolvedPath);
|
||||
|
||||
private:
|
||||
port_id fDebuggerPort;
|
||||
};
|
||||
|
||||
|
||||
#endif // _TEAM_DEBUGGER_H
|
||||
Reference in New Issue
Block a user