| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 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 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "native_client/src/include/nacl_macros.h" | 9 #include "native_client/src/include/nacl_macros.h" |
| 10 #include "native_client/src/shared/gio/gio.h" | |
| 11 #include "native_client/src/shared/platform/nacl_check.h" | 10 #include "native_client/src/shared/platform/nacl_check.h" |
| 12 #include "native_client/src/shared/platform/nacl_exit.h" | 11 #include "native_client/src/shared/platform/nacl_exit.h" |
| 13 #include "native_client/src/shared/platform/nacl_log.h" | 12 #include "native_client/src/shared/platform/nacl_log.h" |
| 14 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h
" | 13 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h
" |
| 14 #include "native_client/src/trusted/service_runtime/load_file.h" |
| 15 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" | 15 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" |
| 16 #include "native_client/src/trusted/service_runtime/nacl_app.h" | 16 #include "native_client/src/trusted/service_runtime/nacl_app.h" |
| 17 #include "native_client/src/trusted/service_runtime/nacl_signal.h" | 17 #include "native_client/src/trusted/service_runtime/nacl_signal.h" |
| 18 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" | 18 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" |
| 19 #include "native_client/src/trusted/service_runtime/nacl_valgrind_hooks.h" | |
| 20 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 19 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 21 | 20 |
| 22 #if NACL_WINDOWS | 21 #if NACL_WINDOWS |
| 23 # include <windows.h> | 22 # include <windows.h> |
| 24 # include <dbghelp.h> | 23 # include <dbghelp.h> |
| 25 #elif NACL_LINUX | 24 #elif NACL_LINUX |
| 26 # include <signal.h> | 25 # include <signal.h> |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 /* | 28 /* |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 UNREFERENCED_PARAMETER(natp); | 244 UNREFERENCED_PARAMETER(natp); |
| 246 | 245 |
| 247 null_func_ptr(); | 246 null_func_ptr(); |
| 248 | 247 |
| 249 NaClLog(LOG_FATAL, "JumpToZeroCrashSyscall: Should not reach here\n"); | 248 NaClLog(LOG_FATAL, "JumpToZeroCrashSyscall: Should not reach here\n"); |
| 250 return 1; | 249 return 1; |
| 251 } | 250 } |
| 252 | 251 |
| 253 int main(int argc, char **argv) { | 252 int main(int argc, char **argv) { |
| 254 struct NaClApp app; | 253 struct NaClApp app; |
| 255 struct GioMemoryFileSnapshot gio_file; | |
| 256 | 254 |
| 257 NaClHandleBootstrapArgs(&argc, &argv); | 255 NaClHandleBootstrapArgs(&argc, &argv); |
| 258 | 256 |
| 259 /* Turn off buffering to aid debugging. */ | 257 /* Turn off buffering to aid debugging. */ |
| 260 setvbuf(stdout, NULL, _IONBF, 0); | 258 setvbuf(stdout, NULL, _IONBF, 0); |
| 261 setvbuf(stderr, NULL, _IONBF, 0); | 259 setvbuf(stderr, NULL, _IONBF, 0); |
| 262 | 260 |
| 263 NaClAllModulesInit(); | 261 NaClAllModulesInit(); |
| 264 | 262 |
| 265 if (argc != 3) { | 263 if (argc != 3) { |
| 266 NaClLog(LOG_FATAL, | 264 NaClLog(LOG_FATAL, |
| 267 "Expected 2 arguments: <executable-filename> <crash-type>\n"); | 265 "Expected 2 arguments: <executable-filename> <crash-type>\n"); |
| 268 } | 266 } |
| 269 | 267 |
| 270 g_crash_type = argv[2]; | 268 g_crash_type = argv[2]; |
| 271 | 269 |
| 272 NaClFileNameForValgrind(argv[1]); | |
| 273 CHECK(GioMemoryFileSnapshotCtor(&gio_file, argv[1])); | |
| 274 CHECK(NaClAppCtor(&app)); | 270 CHECK(NaClAppCtor(&app)); |
| 275 CHECK(NaClAppLoadFile((struct Gio *) &gio_file, &app) == LOAD_OK); | 271 CHECK(NaClAppLoadFileFromFilename(&app, argv[1]) == LOAD_OK); |
| 276 NaClAppInitialDescriptorHookup(&app); | 272 NaClAppInitialDescriptorHookup(&app); |
| 277 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK); | 273 CHECK(NaClAppPrepareToLaunch(&app) == LOAD_OK); |
| 278 | 274 |
| 279 NaClAddSyscall(NACL_sys_test_syscall_1, JumpToZeroCrashSyscall); | 275 NaClAddSyscall(NACL_sys_test_syscall_1, JumpToZeroCrashSyscall); |
| 280 | 276 |
| 281 RegisterHandlers(); | 277 RegisterHandlers(); |
| 282 | 278 |
| 283 CHECK(NaClCreateMainThread(&app, argc - 1, argv + 1, NULL)); | 279 CHECK(NaClCreateMainThread(&app, argc - 1, argv + 1, NULL)); |
| 284 NaClWaitForMainThreadToExit(&app); | 280 NaClWaitForMainThreadToExit(&app); |
| 285 | 281 |
| 286 NaClLog(LOG_ERROR, "We did not expect the test program to exit cleanly\n"); | 282 NaClLog(LOG_ERROR, "We did not expect the test program to exit cleanly\n"); |
| 287 return 1; | 283 return 1; |
| 288 } | 284 } |
| OLD | NEW |