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

Side by Side Diff: tests/debug_stub/debugger_test.c

Issue 107313005: [MIPS] Add support for debug stub test (Closed) Base URL: http://git.chromium.org/native_client/src/native_client.git@master
Patch Set: Modify SingleSteppingWorks(). Created 6 years, 11 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
« no previous file with comments | « tests/debug_stub/debug_stub_test.py ('k') | tests/debug_stub/nacl.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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>
(...skipping 19 matching lines...) Expand all
30 #if defined(__i386__) || defined(__x86_64__) 30 #if defined(__i386__) || defined(__x86_64__)
31 __asm__(".pushsection .text, \"ax\", @progbits\n" 31 __asm__(".pushsection .text, \"ax\", @progbits\n"
32 "fault_addr:\n" 32 "fault_addr:\n"
33 "hlt\n" 33 "hlt\n"
34 ".popsection\n"); 34 ".popsection\n");
35 #elif defined(__arm__) 35 #elif defined(__arm__)
36 __asm__(".pushsection .text, \"ax\", %progbits\n" 36 __asm__(".pushsection .text, \"ax\", %progbits\n"
37 "fault_addr:\n" 37 "fault_addr:\n"
38 ".word " NACL_TO_STRING(NACL_INSTR_ARM_BREAKPOINT) "\n" 38 ".word " NACL_TO_STRING(NACL_INSTR_ARM_BREAKPOINT) "\n"
39 ".popsection\n"); 39 ".popsection\n");
40 #elif defined(__mips__)
41 __asm__(".pushsection .text, \"ax\", %progbits\n"
42 "fault_addr:\n"
43 ".word 0x0000000d\n" /* Break instruction on MIPS. */
44 ".popsection\n");
40 #else 45 #else
41 # error Update fault_addr for other architectures 46 # error Update fault_addr for other architectures
42 #endif 47 #endif
43 48
44 void set_registers_and_stop(void) { 49 void set_registers_and_stop(void) {
45 struct NaClSignalContext regs; 50 struct NaClSignalContext regs;
46 memset(&regs, 0, sizeof(regs)); 51 memset(&regs, 0, sizeof(regs));
47 52
48 /* 53 /*
49 * We set most registers to fixed values before faulting, so that we 54 * We set most registers to fixed values before faulting, so that we
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * Skip r9 because it is not supposed to be settable or readable by 98 * Skip r9 because it is not supposed to be settable or readable by
94 * untrusted code. 99 * untrusted code.
95 */ 100 */
96 regs.r10 = 0xa000000b; 101 regs.r10 = 0xa000000b;
97 regs.r11 = 0xb000000c; 102 regs.r11 = 0xb000000c;
98 regs.r12 = 0xc000000d; 103 regs.r12 = 0xc000000d;
99 /* stack_ptr's test value must be within the sandbox address space. */ 104 /* stack_ptr's test value must be within the sandbox address space. */
100 regs.stack_ptr = 0x12345678; 105 regs.stack_ptr = 0x12345678;
101 regs.lr = 0xe000000f; 106 regs.lr = 0xe000000f;
102 regs.cpsr = (1 << 29) | (1 << 27); /* C and Q flags */ 107 regs.cpsr = (1 << 29) | (1 << 27); /* C and Q flags */
108 #elif defined(__mips__)
109 /* Skip zero register because it cannot be set. */
110 regs.at = 0x11000220;
111 regs.v0 = 0x22000330;
112 regs.v1 = 0x33000440;
113 regs.a0 = 0x44000550;
114 regs.a1 = 0x55000660;
115 regs.a2 = 0x66000770;
116 regs.a3 = 0x77000880;
117 regs.t0 = 0x88000990;
118 regs.t1 = 0x99000aa0;
119 regs.t2 = 0xaa000bb0;
120 regs.t3 = 0xbb000cc0;
121 regs.t4 = 0xcc000dd0;
122 regs.t5 = 0xdd000ee0;
123 /* Skip t6, t7 and t8, because they cannot be set by untrusted code. */
124 regs.s0 = 0x11100222;
125 regs.s1 = 0x22200333;
126 regs.s2 = 0x33300444;
127 regs.s3 = 0x44400555;
128 regs.s4 = 0x55500666;
129 regs.s5 = 0x66600777;
130 regs.s6 = 0x77700888;
131 regs.s7 = 0x88800999;
132 regs.t9 = 0xaaa00bbb;
133 /* Skip k0 and k1 registers, since they can be changed by kernel. */
134 regs.global_ptr = 0xddd00eee;
135 regs.stack_ptr = 0x2ee00fff;
136 regs.frame_ptr = 0xfff00000;
137 regs.return_addr = 0x0a0a0a0a;
103 #else 138 #else
104 # error Update set_registers_and_stop for other architectures 139 # error Update set_registers_and_stop for other architectures
105 #endif 140 #endif
106 JUMP_WITH_REGS(&regs, fault_addr); 141 JUMP_WITH_REGS(&regs, fault_addr);
107 } 142 }
108 143
109 void test_jump_to_address_zero(void) { 144 void test_jump_to_address_zero(void) {
110 /* 145 /*
111 * "volatile" tells Clang/LLVM not to optimize this call away and 146 * "volatile" tells Clang/LLVM not to optimize this call away and
112 * replace it with an illegal instruction, which produces different 147 * replace it with an illegal instruction, which produces different
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ".byte 0x81, 0xeb, 0x14, 0x9f, 0x04, 0x08\n" /* sub $0x8049f14,%ebx */ 184 ".byte 0x81, 0xeb, 0x14, 0x9f, 0x04, 0x08\n" /* sub $0x8049f14,%ebx */
150 ".byte 0x5b\n"); /* pop %ebx */ 185 ".byte 0x5b\n"); /* pop %ebx */
151 #elif defined(__x86_64__) 186 #elif defined(__x86_64__)
152 __asm__( 187 __asm__(
153 ".byte 0xf4\n" /* hlt */ 188 ".byte 0xf4\n" /* hlt */
154 ".byte 0x53\n" /* push %rbx */ 189 ".byte 0x53\n" /* push %rbx */
155 ".byte 0x48, 0x39, 0xd8\n" /* cmp %rbx,%rax */ 190 ".byte 0x48, 0x39, 0xd8\n" /* cmp %rbx,%rax */
156 ".byte 0x48, 0x83, 0xeb, 0x01\n" /* sub $0x1,%rbx */ 191 ".byte 0x48, 0x83, 0xeb, 0x01\n" /* sub $0x1,%rbx */
157 ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n" /* nopw 0x0(%rax,%rax,1) */ 192 ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n" /* nopw 0x0(%rax,%rax,1) */
158 ".byte 0x5b\n"); /* pop %rbx */ 193 ".byte 0x5b\n"); /* pop %rbx */
159 #elif defined(__arm__) 194 #elif defined(__arm__) || defined(__mips__)
160 printf("Single-stepping is not supported on ARM\n"); 195 printf("Single-stepping is not supported on ARM and MIPS.\n");
161 exit(1); 196 exit(1);
162 #else 197 #else
163 # error Update test_single_step for other architectures 198 # error Update test_single_step for other architectures
164 #endif 199 #endif
165 } 200 }
166 201
167 void test_interrupt(void) { 202 void test_interrupt(void) {
168 /* 203 /*
169 * 'volatile' is needed for clang optimizer to get this right. 204 * 'volatile' is needed for clang optimizer to get this right.
170 * TODO(robertm): http://code.google.com/p/nativeclient/issues/detail?id=2912 205 * TODO(robertm): http://code.google.com/p/nativeclient/issues/detail?id=2912
(...skipping 11 matching lines...) Expand all
182 #elif defined(__arm__) 217 #elif defined(__arm__)
183 /* 218 /*
184 * Arrange the breakpoint so that the test can skip over it by 219 * 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 220 * jumping to the next bundle. This means we never have to set the
186 * program counter to within a bundle, which could be unsafe, 221 * program counter to within a bundle, which could be unsafe,
187 * because BKPTs guard data literals in the ARM sandbox. 222 * because BKPTs guard data literals in the ARM sandbox.
188 */ 223 */
189 __asm__(".p2align 4\n" 224 __asm__(".p2align 4\n"
190 ".word " NACL_TO_STRING(NACL_INSTR_ARM_BREAKPOINT) "\n" 225 ".word " NACL_TO_STRING(NACL_INSTR_ARM_BREAKPOINT) "\n"
191 ".p2align 4\n"); 226 ".p2align 4\n");
227 #elif defined(__mips__)
228 __asm__(".p2align 4\n"
229 ".word 0x0000000d\n" /* Break instruction on MIPS. */
230 ".p2align 4\n");
192 #else 231 #else
193 # error Unsupported architecture 232 # error Unsupported architecture
194 #endif 233 #endif
195 } 234 }
196 235
197 void *child_thread_func(void *thread_arg) { 236 void *child_thread_func(void *thread_arg) {
198 for (;;) { 237 for (;;) {
199 g_child_thread_var++; 238 g_child_thread_var++;
200 breakpoint(); 239 breakpoint();
201 } 240 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (strcmp(argv[1], "test_interrupt") == 0) { 283 if (strcmp(argv[1], "test_interrupt") == 0) {
245 test_interrupt(); 284 test_interrupt();
246 return 0; 285 return 0;
247 } 286 }
248 if (strcmp(argv[1], "test_suspending_threads") == 0) { 287 if (strcmp(argv[1], "test_suspending_threads") == 0) {
249 test_suspending_threads(); 288 test_suspending_threads();
250 return 0; 289 return 0;
251 } 290 }
252 return 1; 291 return 1;
253 } 292 }
OLDNEW
« no previous file with comments | « tests/debug_stub/debug_stub_test.py ('k') | tests/debug_stub/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698