Threads displayed.

This commit is contained in:
Ben Vanik
2013-12-25 17:31:53 -08:00
parent d368e0cb74
commit a1da55a006
19 changed files with 468 additions and 131 deletions

View File

@@ -76,6 +76,15 @@ int Debugger::ResumeAllThreads(bool force) {
return result;
}
void Debugger::ForEachThread(std::function<void(ThreadState*)> callback) {
LockMutex(threads_lock_);
for (auto it = threads_.begin(); it != threads_.end(); ++it) {
ThreadState* thread_state = it->second;
callback(thread_state);
}
UnlockMutex(threads_lock_);
}
int Debugger::AddBreakpoint(Breakpoint* breakpoint) {
// Add to breakpoints map.
LockMutex(breakpoints_lock_);

View File

@@ -86,6 +86,8 @@ public:
int ResumeThread(uint32_t thread_id);
int ResumeAllThreads(bool force = false);
void ForEachThread(std::function<void (ThreadState*)> callback);
int AddBreakpoint(Breakpoint* breakpoint);
int RemoveBreakpoint(Breakpoint* breakpoint);
void FindBreakpoints(

View File

@@ -22,7 +22,7 @@ __declspec(thread) ThreadState* thread_state_ = NULL;
ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id) :
runtime_(runtime), memory_(runtime->memory()),
thread_id_(thread_id),
thread_id_(thread_id), name_(0),
backend_data_(0), raw_context_(0) {
if (thread_id_ == UINT_MAX) {
// System thread. Assign the system thread ID with a high bit
@@ -40,6 +40,19 @@ ThreadState::~ThreadState() {
if (thread_state_ == this) {
thread_state_ = NULL;
}
if (name_) {
xe_free(name_);
}
}
void ThreadState::set_name(const char* value) {
if (value == name_) {
return;
}
if (name_) {
xe_free(name_);
}
name_ = xestrdupa(value);
}
void ThreadState::Bind(ThreadState* thread_state) {

View File

@@ -29,6 +29,8 @@ public:
Runtime* runtime() const { return runtime_; }
Memory* memory() const { return memory_; }
uint32_t thread_id() const { return thread_id_; }
const char* name() const { return name_; }
void set_name(const char* value);
void* backend_data() const { return backend_data_; }
void* raw_context() const { return raw_context_; }
@@ -45,6 +47,7 @@ protected:
Runtime* runtime_;
Memory* memory_;
uint32_t thread_id_;
char* name_;
void* backend_data_;
void* raw_context_;
};