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 <pthread.h> | 7 #include <pthread.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
| 12 #include "native_client/src/include/arm_sandbox.h" |
| 13 #include "native_client/src/include/nacl_macros.h" |
12 #include "native_client/src/include/nacl_assert.h" | 14 #include "native_client/src/include/nacl_assert.h" |
13 #include "native_client/tests/common/register_set.h" | 15 #include "native_client/tests/common/register_set.h" |
14 | 16 |
15 | 17 |
16 /* This variable is used for testing memory accesses. */ | 18 /* This variable is used for testing memory accesses. */ |
17 char g_example_var[] = "some_debug_stub_test_data"; | 19 char g_example_var[] = "some_debug_stub_test_data"; |
18 | 20 |
19 volatile uint32_t g_main_thread_var = 0; | 21 volatile uint32_t g_main_thread_var = 0; |
20 volatile uint32_t g_child_thread_var = 0; | 22 volatile uint32_t g_child_thread_var = 0; |
21 | 23 |
22 | 24 |
23 /* | 25 /* |
24 * Inline assembly is not allowed to define symbols (in case it gets | 26 * Inline assembly is not allowed to define symbols (in case it gets |
25 * instantiated multiple times), so we must define this symbol using | 27 * instantiated multiple times), so we must define this symbol using |
26 * top-level assembly. | 28 * top-level assembly. |
27 */ | 29 */ |
28 #if defined(__i386__) || defined(__x86_64__) | 30 #if defined(__i386__) || defined(__x86_64__) |
29 __asm__(".pushsection .text, \"ax\", @progbits\n" | 31 __asm__(".pushsection .text, \"ax\", @progbits\n" |
30 "fault_addr:\n" | 32 "fault_addr:\n" |
31 "hlt\n" | 33 "hlt\n" |
32 ".popsection\n"); | 34 ".popsection\n"); |
33 #elif defined(__arm__) | 35 #elif defined(__arm__) |
34 __asm__(".pushsection .text, \"ax\", %progbits\n" | 36 __asm__(".pushsection .text, \"ax\", %progbits\n" |
35 "fault_addr:\n" | 37 "fault_addr:\n" |
36 "bkpt 0x7777\n" | 38 ".word " NACL_TO_STRING(NACL_INSTR_ABORT_NOW) "\n" |
37 ".popsection\n"); | 39 ".popsection\n"); |
38 #else | 40 #else |
39 # error Update fault_addr for other architectures | 41 # error Update fault_addr for other architectures |
40 #endif | 42 #endif |
41 | 43 |
42 void set_registers_and_stop() { | 44 void set_registers_and_stop() { |
43 struct NaClSignalContext regs; | 45 struct NaClSignalContext regs; |
44 memset(®s, 0, sizeof(regs)); | 46 memset(®s, 0, sizeof(regs)); |
45 | 47 |
46 /* | 48 /* |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 /* We avoid using int3 because of a Mac OS X kernel bug. */ | 182 /* We avoid using int3 because of a Mac OS X kernel bug. */ |
181 __asm__("hlt"); | 183 __asm__("hlt"); |
182 #elif defined(__arm__) | 184 #elif defined(__arm__) |
183 /* | 185 /* |
184 * Arrange the breakpoint so that the test can skip over it by | 186 * Arrange the breakpoint so that the test can skip over it by |
185 * jumping to the next bundle. This means we never have to set the | 187 * jumping to the next bundle. This means we never have to set the |
186 * program counter to within a bundle, which could be unsafe, | 188 * program counter to within a bundle, which could be unsafe, |
187 * because BKPTs guard data literals in the ARM sandbox. | 189 * because BKPTs guard data literals in the ARM sandbox. |
188 */ | 190 */ |
189 __asm__(".p2align 4\n" | 191 __asm__(".p2align 4\n" |
190 "bkpt 0x7777\n" | 192 ".word " NACL_TO_STRING(NACL_INSTR_BREAKPOINT) "\n" |
191 ".p2align 4\n"); | 193 ".p2align 4\n"); |
192 #else | 194 #else |
193 # error Unsupported architecture | 195 # error Unsupported architecture |
194 #endif | 196 #endif |
195 } | 197 } |
196 | 198 |
197 void *child_thread_func(void *thread_arg) { | 199 void *child_thread_func(void *thread_arg) { |
198 for (;;) { | 200 for (;;) { |
199 g_child_thread_var++; | 201 g_child_thread_var++; |
200 breakpoint(); | 202 breakpoint(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (strcmp(argv[1], "test_interrupt") == 0) { | 246 if (strcmp(argv[1], "test_interrupt") == 0) { |
245 test_interrupt(); | 247 test_interrupt(); |
246 return 0; | 248 return 0; |
247 } | 249 } |
248 if (strcmp(argv[1], "test_suspending_threads") == 0) { | 250 if (strcmp(argv[1], "test_suspending_threads") == 0) { |
249 test_suspending_threads(); | 251 test_suspending_threads(); |
250 return 0; | 252 return 0; |
251 } | 253 } |
252 return 1; | 254 return 1; |
253 } | 255 } |
OLD | NEW |