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

Side by Side Diff: tests/exception_test/exception_test.c

Issue 544003002: NonSFI mode: Enable compiling exception_test for NonSFI NaCl on ARM (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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 <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <setjmp.h> 10 #include <setjmp.h>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 longjmp(g_jmp_buf, 1); 115 longjmp(g_jmp_buf, 1);
116 } 116 }
117 117
118 void simple_exception_handler(struct NaClExceptionContext *regs) { 118 void simple_exception_handler(struct NaClExceptionContext *regs) {
119 return_from_exception_handler(); 119 return_from_exception_handler();
120 } 120 }
121 121
122 void exception_handler(struct NaClExceptionContext *context); 122 void exception_handler(struct NaClExceptionContext *context);
123 REGS_SAVER_FUNC_NOPROTO(exception_handler, exception_handler_wrapped); 123 REGS_SAVER_FUNC_NOPROTO(exception_handler, exception_handler_wrapped);
124 124
125 __attribute__((__used__))
125 void exception_handler_wrapped(struct NaClSignalContext *entry_regs) { 126 void exception_handler_wrapped(struct NaClSignalContext *entry_regs) {
126 struct NaClExceptionContext *context = 127 struct NaClExceptionContext *context =
127 (struct NaClExceptionContext *) RegsGetArg1(entry_regs); 128 (struct NaClExceptionContext *) RegsGetArg1(entry_regs);
128 struct NaClExceptionPortableContext *portable = 129 struct NaClExceptionPortableContext *portable =
129 nacl_exception_context_get_portable(context); 130 nacl_exception_context_get_portable(context);
130 131
131 printf("handler called\n"); 132 printf("handler called\n");
132 133
133 assert(context->size == (uintptr_t) (portable + 1) - (uintptr_t) context); 134 assert(context->size == (uintptr_t) (portable + 1) - (uintptr_t) context);
134 assert(context->portable_context_size == 135 assert(context->portable_context_size ==
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (!setjmp(g_jmp_buf)) { 320 if (!setjmp(g_jmp_buf)) {
320 __asm__("hlt"); 321 __asm__("hlt");
321 exit(1); 322 exit(1);
322 } 323 }
323 printf("Testing ud2a (an illegal instruction)...\n"); 324 printf("Testing ud2a (an illegal instruction)...\n");
324 if (!setjmp(g_jmp_buf)) { 325 if (!setjmp(g_jmp_buf)) {
325 __asm__("ud2a"); 326 __asm__("ud2a");
326 exit(1); 327 exit(1);
327 } 328 }
328 printf("Testing integer division by zero...\n"); 329 printf("Testing integer division by zero...\n");
330 #if 0
329 if (!setjmp(g_jmp_buf)) { 331 if (!setjmp(g_jmp_buf)) {
330 uint32_t result; 332 uint32_t result;
331 __asm__ volatile("idivb %1" 333 __asm__ volatile("idivb %1"
332 : "=a"(result) 334 : "=a"(result)
333 : "r"((uint8_t) 0), "a"((uint16_t) 1)); 335 : "r"((uint8_t) 0), "a"((uint16_t) 1));
334 exit(1); 336 exit(1);
335 } 337 }
336 #endif 338 #endif
339 #endif
337 340
338 /* Clear the jmp_buf to prevent it from being reused accidentally. */ 341 /* Clear the jmp_buf to prevent it from being reused accidentally. */
339 memset(g_jmp_buf, 0, sizeof(g_jmp_buf)); 342 memset(g_jmp_buf, 0, sizeof(g_jmp_buf));
340 } 343 }
341 344
342 345
343 #if defined(__i386__) || defined(__x86_64__) 346 #if 0 && (defined(__i386__) || defined(__x86_64__))
344 347
345 int get_x86_direction_flag(void); 348 int get_x86_direction_flag(void);
346 349
347 void test_get_x86_direction_flag(void) { 350 void test_get_x86_direction_flag(void) {
348 /* 351 /*
349 * Sanity check: Ensure that get_x86_direction_flag() works. We 352 * Sanity check: Ensure that get_x86_direction_flag() works. We
350 * avoid calling assert() with the flag set, because that might not 353 * avoid calling assert() with the flag set, because that might not
351 * work. 354 * work.
352 */ 355 */
353 assert(get_x86_direction_flag() == 0); 356 assert(get_x86_direction_flag() == 0);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 int TestMain(void) { 400 int TestMain(void) {
398 RUN_TEST(test_exceptions_minimally); 401 RUN_TEST(test_exceptions_minimally);
399 RUN_TEST(test_exception_stack_alignments); 402 RUN_TEST(test_exception_stack_alignments);
400 RUN_TEST(test_getting_previous_handler); 403 RUN_TEST(test_getting_previous_handler);
401 RUN_TEST(test_invalid_handlers); 404 RUN_TEST(test_invalid_handlers);
402 /* pthread_join() is broken under qemu-arm. */ 405 /* pthread_join() is broken under qemu-arm. */
403 if (getenv("UNDER_QEMU_ARM") == NULL) 406 if (getenv("UNDER_QEMU_ARM") == NULL)
404 RUN_TEST(test_exceptions_on_non_main_thread); 407 RUN_TEST(test_exceptions_on_non_main_thread);
405 RUN_TEST(test_catching_various_exception_types); 408 RUN_TEST(test_catching_various_exception_types);
406 409
407 #if defined(__i386__) || defined(__x86_64__) 410 #if 0 && (defined(__i386__) || defined(__x86_64__))
408 RUN_TEST(test_get_x86_direction_flag); 411 RUN_TEST(test_get_x86_direction_flag);
409 RUN_TEST(test_unsetting_x86_direction_flag); 412 RUN_TEST(test_unsetting_x86_direction_flag);
410 #endif 413 #endif
411 414
412 fprintf(stderr, "** intended_exit_status=0\n"); 415 fprintf(stderr, "** intended_exit_status=0\n");
413 return 0; 416 return 0;
414 } 417 }
415 418
416 int main(void) { 419 int main(void) {
417 return RunTests(TestMain); 420 return RunTests(TestMain);
418 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698