Chromium Code Reviews| 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 * NaCl Server Runtime user thread state. | 8 * NaCl Server Runtime user thread state. |
| 9 */ | 9 */ |
| 10 #include "native_client/src/shared/platform/nacl_check.h" | 10 #include "native_client/src/shared/platform/nacl_check.h" |
| 11 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 11 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
| 12 #include "native_client/src/trusted/service_runtime/nacl_desc_effector_ldr.h" | 12 #include "native_client/src/trusted/service_runtime/nacl_desc_effector_ldr.h" |
| 13 | 13 |
| 14 #include "native_client/src/trusted/service_runtime/nacl_globals.h" | 14 #include "native_client/src/trusted/service_runtime/nacl_globals.h" |
| 15 #include "native_client/src/trusted/service_runtime/nacl_oop_debugger_hooks.h" | |
| 15 #include "native_client/src/trusted/service_runtime/nacl_tls.h" | 16 #include "native_client/src/trusted/service_runtime/nacl_tls.h" |
| 16 #include "native_client/src/trusted/service_runtime/nacl_switch_to_app.h" | 17 #include "native_client/src/trusted/service_runtime/nacl_switch_to_app.h" |
| 17 #include "native_client/src/trusted/service_runtime/nacl_stack_safety.h" | 18 #include "native_client/src/trusted/service_runtime/nacl_stack_safety.h" |
| 18 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" | 19 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" |
| 19 | 20 |
| 20 | 21 |
| 21 void WINAPI NaClThreadLauncher(void *state) { | 22 void WINAPI NaClThreadLauncher(void *state) { |
| 22 struct NaClAppThread *natp = (struct NaClAppThread *) state; | 23 struct NaClAppThread *natp = (struct NaClAppThread *) state; |
| 23 NaClLog(4, "NaClThreadLauncher: entered\n"); | 24 NaClLog(4, "NaClThreadLauncher: entered\n"); |
| 24 | 25 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 45 | 46 |
| 46 NaClStackSafetyNowOnUntrustedStack(); /* real soon now! */ | 47 NaClStackSafetyNowOnUntrustedStack(); /* real soon now! */ |
| 47 | 48 |
| 48 /* | 49 /* |
| 49 * Notify the debug stub, that a new thread is availible. | 50 * Notify the debug stub, that a new thread is availible. |
| 50 */ | 51 */ |
| 51 if (NULL != natp->nap->debug_stub_callbacks) { | 52 if (NULL != natp->nap->debug_stub_callbacks) { |
| 52 natp->nap->debug_stub_callbacks->thread_create_hook(natp); | 53 natp->nap->debug_stub_callbacks->thread_create_hook(natp); |
| 53 } | 54 } |
| 54 | 55 |
| 56 NaClOopDebuggerThreadCreateHook(natp); | |
| 57 | |
| 55 /* | 58 /* |
| 56 * We need to set an exception handler in every thread we start, | 59 * We need to set an exception handler in every thread we start, |
| 57 * otherwise the system's default handler is called and a message box is | 60 * otherwise the system's default handler is called and a message box is |
| 58 * shown. | 61 * shown. |
| 59 */ | 62 */ |
| 60 WINDOWS_EXCEPTION_TRY; | 63 WINDOWS_EXCEPTION_TRY; |
| 61 NaClStartThreadInApp(natp, natp->user.prog_ctr); | 64 NaClStartThreadInApp(natp, natp->user.prog_ctr); |
| 62 WINDOWS_EXCEPTION_CATCH; | 65 WINDOWS_EXCEPTION_CATCH; |
| 63 } | 66 } |
| 64 | 67 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 | 136 |
| 134 void NaClAppThreadDtor(struct NaClAppThread *natp) { | 137 void NaClAppThreadDtor(struct NaClAppThread *natp) { |
| 135 /* | 138 /* |
| 136 * the thread must not be still running, else this crashes the system | 139 * the thread must not be still running, else this crashes the system |
| 137 */ | 140 */ |
| 138 | 141 |
| 139 /* | 142 /* |
| 140 * Notify the debug stub that we are done with this thread | 143 * Notify the debug stub that we are done with this thread |
| 141 */ | 144 */ |
| 142 if (NULL != natp->nap->debug_stub_callbacks) { | 145 if (NULL != natp->nap->debug_stub_callbacks) { |
| 143 natp->nap->debug_stub_callbacks->thread_exit_hook(natp); | 146 natp->nap->debug_stub_callbacks->thread_exit_hook(natp); |
|
Mark Seaborn
2011/06/13 19:40:51
There's already a hook facility right here. Can't
garianov1
2011/06/13 20:09:10
My intention is to enable OOP debugger hooks all t
| |
| 144 } | 147 } |
| 148 NaClOopDebuggerThreadExitHook(natp, natp->nap->exit_status); | |
| 145 | 149 |
| 146 NaClThreadDtor(&natp->thread); | 150 NaClThreadDtor(&natp->thread); |
| 147 NaClSignalStackUnregister(); | 151 NaClSignalStackUnregister(); |
| 148 NaClSignalStackFree(natp->signal_stack); | 152 NaClSignalStackFree(natp->signal_stack); |
| 149 natp->signal_stack = NULL; | 153 natp->signal_stack = NULL; |
| 150 NaClClosureResultDtor(&natp->result); | 154 NaClClosureResultDtor(&natp->result); |
| 151 NaClTlsFree(natp); | 155 NaClTlsFree(natp); |
| 152 NaClCondVarDtor(&natp->cv); | 156 NaClCondVarDtor(&natp->cv); |
| 153 NaClMutexDtor(&natp->mu); | 157 NaClMutexDtor(&natp->mu); |
| 154 } | 158 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 return 0; | 194 return 0; |
| 191 } | 195 } |
| 192 | 196 |
| 193 return NaClAppThreadCtor(natp, | 197 return NaClAppThreadCtor(natp, |
| 194 nap, | 198 nap, |
| 195 usr_entry, | 199 usr_entry, |
| 196 usr_stack_ptr, | 200 usr_stack_ptr, |
| 197 tls_idx, | 201 tls_idx, |
| 198 sys_tdb_base); | 202 sys_tdb_base); |
| 199 } | 203 } |
| OLD | NEW |