Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: src/trusted/debug_stub/win/thread_impl.cc

Issue 10365028: Debug stub: associate NaClAppThread with IThread (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/debug_stub/win/thread_impl.cc
diff --git a/src/trusted/debug_stub/win/thread_impl.cc b/src/trusted/debug_stub/win/thread_impl.cc
index 3eab93e289a2354ed6df2e8ca6e239ab0eb72343..495a60d21a423f0dc7c075d96dbaffb892622d90 100644
--- a/src/trusted/debug_stub/win/thread_impl.cc
+++ b/src/trusted/debug_stub/win/thread_impl.cc
@@ -9,6 +9,7 @@
#include <exception>
#include <stdexcept>
+#include "native_client/src/shared/platform/nacl_log.h"
#include "native_client/src/trusted/port/mutex.h"
#include "native_client/src/trusted/port/thread.h"
@@ -209,8 +210,8 @@ static int GetSizeofRegInCtx(int32_t num) {
class Thread : public IThread {
public:
- explicit Thread(uint32_t id) : ref_(1), id_(id),
- handle_(NULL), state_(RUNNING) {
+ Thread(uint32_t id, struct NaClAppThread *natp)
+ : ref_(1), id_(id), handle_(NULL), natp_(natp), state_(RUNNING) {
handle_ = OpenThread(THREAD_ALL_ACCESS, false, id);
memset(&context_, 0, sizeof(context_));
context_.ContextFlags = CONTEXT_ALL;
@@ -361,6 +362,7 @@ class Thread : public IThread {
private:
uint32_t ref_;
uint32_t id_;
+ struct NaClAppThread *natp_;
State state_;
HANDLE handle_;
CONTEXT context_;
@@ -368,32 +370,39 @@ class Thread : public IThread {
friend class IThread;
};
-IThread* IThread::Acquire(uint32_t id, bool create) {
+IThread* IThread::Create(uint32_t id, struct NaClAppThread* natp) {
MutexLock lock(ThreadGetLock());
Thread* thread;
ThreadMap_t &map = *ThreadGetMap();
- // Check if we have that thread
if (map.count(id)) {
- thread = static_cast<Thread*>(map[id]);
- thread->ref_++;
- return thread;
+ NaClLog(LOG_ERROR, "IThread::Create: thread 0x%x already exists\n", id);
Mark Seaborn 2012/05/07 21:56:49 Ditto
eaeltsin 2012/05/08 11:10:19 Done.
+ return NULL;
}
- // If not, can we create it?
- if (create) {
- // If not add it to the map
- thread = new Thread(id);
- if (NULL == thread->handle_) {
- delete thread;
- return NULL;
- }
+ thread = new Thread(id, natp);
+ if (NULL == thread->handle_) {
+ delete thread;
Mark Seaborn 2012/05/07 21:56:49 FYI, this isn't consistent with the posix implemen
eaeltsin 2012/05/08 11:10:19 This is the old code, kept as is. Anyway, this co
+ return NULL;
+ }
+
+ map[id] = thread;
+ return thread;
+}
+
+IThread* IThread::Acquire(uint32_t id) {
+ MutexLock lock(ThreadGetLock());
+ Thread* thread;
+ ThreadMap_t &map = *ThreadGetMap();
- map[id] = thread;
- return thread;
+ if (map.count(id) == 0) {
+ NaClLog(LOG_ERROR, "IThread::Acquire: thread 0x%x does not exist\n", id);
+ return NULL;
}
- return NULL;
+ thread = static_cast<Thread*>(map[id]);
+ thread->ref_++;
+ return thread;
}
void IThread::Release(IThread *ithread) {

Powered by Google App Engine
This is Rietveld 408576698