| Index: src/trusted/debug_stub/posix/thread_impl.cc
|
| diff --git a/src/trusted/debug_stub/posix/thread_impl.cc b/src/trusted/debug_stub/posix/thread_impl.cc
|
| index 45e68c4316cc9abaff3c718d90d5337b0982ad7c..d07e3fb928b70bb45b4dd0c9000fe675842c1898 100644
|
| --- a/src/trusted/debug_stub/posix/thread_impl.cc
|
| +++ b/src/trusted/debug_stub/posix/thread_impl.cc
|
| @@ -12,7 +12,9 @@
|
| #include "native_client/src/trusted/port/mutex.h"
|
| #include "native_client/src/trusted/port/platform.h"
|
| #include "native_client/src/trusted/port/thread.h"
|
| +#include "native_client/src/trusted/service_runtime/nacl_app_thread.h" // only for NaClAppThread->nap
|
| #include "native_client/src/trusted/service_runtime/nacl_signal.h"
|
| +#include "native_client/src/trusted/service_runtime/sel_ldr.h"
|
|
|
| /*
|
| * Define the OS specific portions of IThread interface.
|
| @@ -39,6 +41,8 @@ static IThread::ThreadMap_t *ThreadGetMap() {
|
| return map_;
|
| }
|
|
|
| +volatile int signaled_ = 0;
|
| +
|
| class Thread : public IThread {
|
| public:
|
| Thread(uint32_t id, struct NaClAppThread *natp)
|
| @@ -103,6 +107,9 @@ class Thread : public IThread {
|
| struct NaClSignalContext context;
|
| NaClSignalContextFromHandler(&context, ucontext);
|
| if (NaClSignalContextIsUntrusted(&context)) {
|
| + while (__sync_lock_test_and_set(&signaled_, 1)) {
|
| + usleep(100);
|
| + }
|
| uint32_t thread_id = IPlatform::GetCurrentThread();
|
| Thread* thread = static_cast<Thread*>(Acquire(thread_id));
|
| State old_state = thread->state_;
|
| @@ -115,6 +122,7 @@ class Thread : public IThread {
|
| NaClSignalContextToHandler(ucontext, &thread->context_);
|
| thread->state_ = old_state;
|
| Release(thread);
|
| + __sync_lock_release(&signaled_);
|
| return NACL_SIGNAL_RETURN;
|
| } else {
|
| // Do not attempt to debug crashes in trusted code.
|
| @@ -180,6 +188,24 @@ void IThread::SetExceptionCatch(IThread::CatchFunc_t func, void *cookie) {
|
| s_CatchCookie = cookie;
|
| }
|
|
|
| +void IThread::SuspendAll(uint32_t signaled_id) {
|
| + if (signaled_id == 0) {
|
| + NaClLog(LOG_FATAL, "IThread::SuspendAll: not implemented\n");
|
| + } else {
|
| + Thread* thread = static_cast<Thread*>(Acquire(signaled_id));
|
| + NaClUntrustedThreadsSuspendAll2(thread->natp_->nap, thread->natp_);
|
| + Release(thread);
|
| + }
|
| +}
|
|
|
| -} // End of port namespace
|
| +void IThread::ResumeAll(uint32_t signaled_id) {
|
| + if (signaled_id == 0) {
|
| + NaClLog(LOG_FATAL, "IThread::ResumeAll: not implemented\n");
|
| + } else {
|
| + Thread* thread = static_cast<Thread*>(Acquire(signaled_id));
|
| + NaClUntrustedThreadsResumeAll2(thread->natp_->nap, thread->natp_);
|
| + Release(thread);
|
| + }
|
| +}
|
|
|
| +} // namespace port
|
|
|