Breakpoint hits reaching all the way to UI.
Nasty json only hackery right now, but fixable to support other protocols.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
namespace alloy {
|
||||
namespace runtime {
|
||||
|
||||
class Debugger;
|
||||
class Function;
|
||||
class FunctionInfo;
|
||||
class Runtime;
|
||||
@@ -37,9 +38,40 @@ public:
|
||||
Type type() const { return type_; }
|
||||
uint64_t address() const { return address_; }
|
||||
|
||||
const char* id() const { return id_.c_str(); }
|
||||
void set_id(const char* id) { id_ = id; }
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
uint64_t address_;
|
||||
|
||||
std::string id_;
|
||||
};
|
||||
|
||||
|
||||
class DebugEvent {
|
||||
public:
|
||||
DebugEvent(Debugger* debugger) :
|
||||
debugger_(debugger) {}
|
||||
virtual ~DebugEvent() {}
|
||||
Debugger* debugger() const { return debugger_; }
|
||||
protected:
|
||||
Debugger* debugger_;
|
||||
};
|
||||
|
||||
|
||||
class BreakpointHitEvent : public DebugEvent {
|
||||
public:
|
||||
BreakpointHitEvent(
|
||||
Debugger* debugger, ThreadState* thread_state, Breakpoint* breakpoint) :
|
||||
thread_state_(thread_state), breakpoint_(breakpoint),
|
||||
DebugEvent(debugger) {}
|
||||
virtual ~BreakpointHitEvent() {}
|
||||
ThreadState* thread_state() const { return thread_state_; }
|
||||
Breakpoint* breakpoint() const { return breakpoint_; }
|
||||
protected:
|
||||
ThreadState* thread_state_;
|
||||
Breakpoint* breakpoint_;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,20 +82,34 @@ public:
|
||||
|
||||
Runtime* runtime() const { return runtime_; }
|
||||
|
||||
int SuspendAllThreads(uint32_t timeout_ms = UINT_MAX);
|
||||
int ResumeThread(uint32_t thread_id);
|
||||
int ResumeAllThreads();
|
||||
|
||||
int AddBreakpoint(Breakpoint* breakpoint);
|
||||
int RemoveBreakpoint(Breakpoint* breakpoint);
|
||||
void FindBreakpoints(
|
||||
uint64_t address, std::vector<Breakpoint*>& out_breakpoints);
|
||||
|
||||
void OnThreadCreated(ThreadState* thread_state);
|
||||
void OnThreadDestroyed(ThreadState* thread_state);
|
||||
void OnFunctionDefined(FunctionInfo* symbol_info, Function* function);
|
||||
|
||||
void OnBreakpointHit(ThreadState* thread_state, Breakpoint* breakpoint);
|
||||
|
||||
public:
|
||||
Delegate<BreakpointHitEvent> breakpoint_hit;
|
||||
|
||||
private:
|
||||
Runtime* runtime_;
|
||||
|
||||
Mutex* threads_lock_;
|
||||
typedef std::unordered_map<uint32_t, ThreadState*> ThreadMap;
|
||||
ThreadMap threads_;
|
||||
|
||||
Mutex* breakpoints_lock_;
|
||||
typedef std::multimap<uint64_t, Breakpoint*> BreakpointsMultimap;
|
||||
BreakpointsMultimap breakpoints_;
|
||||
typedef std::multimap<uint64_t, Breakpoint*> BreakpointMultimap;
|
||||
BreakpointMultimap breakpoints_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user