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

Side by Side Diff: tests/toolchain/stack_frame.cc

Issue 12256018: [MIPS] Add remaining parts for building tests for MIPS (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Minor cleanup. Created 7 years, 9 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/toolchain/eh_return.c ('k') | tests/trusted_crash/crash_in_syscall/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 /* 7 /*
8 * This tests execises __builtin_dwarf_cfa() 8 * This tests execises __builtin_dwarf_cfa()
9 * 9 *
10 * NOTE: because of fun pointer casting we need to disable -pedantic. 10 * NOTE: because of fun pointer casting we need to disable -pedantic.
(...skipping 23 matching lines...) Expand all
34 if (i % 8 == 7) printf("\n"); 34 if (i % 8 == 7) printf("\n");
35 } 35 }
36 } 36 }
37 37
38 38
39 void* GetReturnAddress(void* frame_end) { 39 void* GetReturnAddress(void* frame_end) {
40 #if defined(__native_client__) 40 #if defined(__native_client__)
41 41
42 #if defined(__arm__) 42 #if defined(__arm__)
43 return ((void**)frame_end)[-1]; 43 return ((void**)frame_end)[-1];
44 #elif defined(__mips__)
45 return ((void**)frame_end)[-1];
44 #elif defined(__i386__) 46 #elif defined(__i386__)
45 return ((void**)frame_end)[-1]; 47 return ((void**)frame_end)[-1];
46 #elif defined(__x86_64__) 48 #elif defined(__x86_64__)
47 /* NOTE: a call pushes 64 bits but we only care about the first 32 */ 49 /* NOTE: a call pushes 64 bits but we only care about the first 32 */
48 return ((void**)frame_end)[-2]; 50 return ((void**)frame_end)[-2];
49 #else 51 #else
50 #error "unknown arch" 52 #error "unknown arch"
51 #endif 53 #endif
52 54
53 #else /* !defined(__native_client__) */ 55 #else /* !defined(__native_client__) */
(...skipping 30 matching lines...) Expand all
84 } 86 }
85 87
86 /* NOTE: we dump the frame for this invocation at the beginning of the next */ 88 /* NOTE: we dump the frame for this invocation at the beginning of the next */
87 printf("frame [%p, %p[\n", cfa, old_cfa); 89 printf("frame [%p, %p[\n", cfa, old_cfa);
88 printf("framesize %d\n", frame_size); 90 printf("framesize %d\n", frame_size);
89 printf("return %p\n", return_address); 91 printf("return %p\n", return_address);
90 DumpMemory(cfa, frame_size); 92 DumpMemory(cfa, frame_size);
91 93
92 // TODO(sehr): change those to 16 94 // TODO(sehr): change those to 16
93 ASSERT(frame_size % 8 == 0, "ERRRO: bad frame size"); 95 ASSERT(frame_size % 8 == 0, "ERRRO: bad frame size");
94 ASSERT((long) cfa % 8 == 0, "ERRRO: bad frame pointer"); 96 ASSERT((int) cfa % 8 == 0, "ERRRO: bad frame pointer");
95 97
96 if (n == NUM_ITERS) { 98 if (n == NUM_ITERS) {
97 // main()'s stackframe may be non-standard due to the startup code 99 // main()'s stackframe may be non-standard due to the startup code
98 } else if (n == NUM_ITERS - 1) { 100 } else if (n == NUM_ITERS - 1) {
99 // first stack frame for recurse() - return address inside main() 101 // first stack frame for recurse() - return address inside main()
100 ASSERT(FUNPTR2PTR(main) < return_address, 102 ASSERT(FUNPTR2PTR(main) < return_address,
101 "ERROR: return address is not within main()"); 103 "ERROR: return address is not within main()");
102 } else { 104 } else {
103 // recurse() calling itself 105 // recurse() calling itself
104 ASSERT(FUNPTR2PTR(recurse) < return_address && 106 ASSERT(FUNPTR2PTR(recurse) < return_address &&
(...skipping 22 matching lines...) Expand all
127 int main(int argc, char* argv[]) { 129 int main(int argc, char* argv[]) {
128 printf("&main: %p\n", FUNPTR2PTR(main)); 130 printf("&main: %p\n", FUNPTR2PTR(main));
129 printf("&recurse: %p\n", FUNPTR2PTR(recurse)); 131 printf("&recurse: %p\n", FUNPTR2PTR(recurse));
130 ASSERT(FUNPTR2PTR(recurse) < FUNPTR2PTR(main), 132 ASSERT(FUNPTR2PTR(recurse) < FUNPTR2PTR(main),
131 "ERROR: this test assumes that main() follows recurse()\n"); 133 "ERROR: this test assumes that main() follows recurse()\n");
132 134
133 unsigned char* cfa = (unsigned char*) __builtin_dwarf_cfa(); 135 unsigned char* cfa = (unsigned char*) __builtin_dwarf_cfa();
134 recurse(NUM_ITERS, cfa); 136 recurse(NUM_ITERS, cfa);
135 return 55; 137 return 55;
136 } 138 }
OLDNEW
« no previous file with comments | « tests/toolchain/eh_return.c ('k') | tests/trusted_crash/crash_in_syscall/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698