| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 for (a = 0; a < envc; a++) g_nacl_debug_state->env_[a] = envv[a]; | 173 for (a = 0; a < envc; a++) g_nacl_debug_state->env_[a] = envv[a]; |
| 174 } DBG_CATCH_ALL | 174 } DBG_CATCH_ALL |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void NaClDebugThreadPrepDebugging(struct NaClAppThread *natp) throw() { | 178 void NaClDebugThreadPrepDebugging(struct NaClAppThread *natp) throw() { |
| 179 UNREFERENCED_PARAMETER(natp); | 179 UNREFERENCED_PARAMETER(natp); |
| 180 | 180 |
| 181 if (NaClDebugIsEnabled()) { | 181 if (NaClDebugIsEnabled()) { |
| 182 uint32_t id = IPlatform::GetCurrentThread(); | 182 uint32_t id = IPlatform::GetCurrentThread(); |
| 183 IThread* thread = IThread::Acquire(id, true); | 183 IThread* thread = IThread::Create(id, natp); |
| 184 g_nacl_debug_state->target_->SetMemoryBase(natp->nap->mem_start); | 184 g_nacl_debug_state->target_->SetMemoryBase(natp->nap->mem_start); |
| 185 g_nacl_debug_state->target_->TrackThread(thread); | 185 g_nacl_debug_state->target_->TrackThread(thread); |
| 186 | |
| 187 /* | |
| 188 * TODO(noelallen) We need to associate the natp with this thread | |
| 189 * so we can get to the untrusted context preserved on a syscall. | |
| 190 */ | |
| 191 } | 186 } |
| 192 } | 187 } |
| 193 | 188 |
| 194 void NaClDebugThreadStopDebugging(struct NaClAppThread *natp) throw() { | 189 void NaClDebugThreadStopDebugging(struct NaClAppThread *natp) throw() { |
| 195 UNREFERENCED_PARAMETER(natp); | 190 UNREFERENCED_PARAMETER(natp); |
| 196 | 191 |
| 197 if (NaClDebugIsEnabled()) { | 192 if (NaClDebugIsEnabled()) { |
| 198 uint32_t id = IPlatform::GetCurrentThread(); | 193 uint32_t id = IPlatform::GetCurrentThread(); |
| 199 IThread* thread = IThread::Acquire(id, false); | 194 IThread* thread = IThread::Acquire(id); |
| 200 g_nacl_debug_state->target_->IgnoreThread(thread); | 195 g_nacl_debug_state->target_->IgnoreThread(thread); |
| 201 IThread::Release(thread); | 196 IThread::Release(thread); |
| 202 | |
| 203 /* | |
| 204 * TODO(noelallen) We need to associate the natp with this thread | |
| 205 * so we can get to the thread once we support freeing a thread | |
| 206 * from a different thread than the executing one. | |
| 207 */ | |
| 208 } | 197 } |
| 209 } | 198 } |
| 210 | 199 |
| 211 int NaClDebugStart(void) throw() { | 200 int NaClDebugStart(void) throw() { |
| 212 if (NaClDebugIsEnabled()) { | 201 if (NaClDebugIsEnabled()) { |
| 213 NaClThread *thread = new NaClThread; | 202 NaClThread *thread = new NaClThread; |
| 214 | 203 |
| 215 if (NULL == thread) return false; | 204 if (NULL == thread) return false; |
| 216 | 205 |
| 217 /* Add a temp breakpoint. */ | 206 /* Add a temp breakpoint. */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 initialised = 1; | 249 initialised = 1; |
| 261 nap->debug_stub_callbacks = &debug_callbacks; | 250 nap->debug_stub_callbacks = &debug_callbacks; |
| 262 NaClDebugStubInit(); | 251 NaClDebugStubInit(); |
| 263 g_nacl_debug_state = new NaClDebugState(); | 252 g_nacl_debug_state = new NaClDebugState(); |
| 264 CHECK(g_nacl_debug_state->Init()); | 253 CHECK(g_nacl_debug_state->Init()); |
| 265 NaClDebugSetAppInfo(nap); | 254 NaClDebugSetAppInfo(nap); |
| 266 NaClDebugSetAppEnvironment(argc, argv, envc, envv); | 255 NaClDebugSetAppEnvironment(argc, argv, envc, envv); |
| 267 NaClDebugStart(); | 256 NaClDebugStart(); |
| 268 return 1; | 257 return 1; |
| 269 } | 258 } |
| OLD | NEW |