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

Side by Side Diff: tests/gdb/gdb_test_guest.c

Issue 10826183: GDB: Test that we can step inside function. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 <string.h> 8 #include <string.h>
9 #include <alloca.h>
9 10
10 int global_var; 11 int global_var;
12 volatile void *global_ptr;
11 13
12 void test_two_line_function(int arg) { 14 void test_two_line_function(int arg) {
13 global_var = arg - 1; 15 global_var = arg - 1;
14 global_var = arg; 16 global_var = arg;
15 } 17 }
16 18
17 void test_stepi_after_break() { 19 void test_stepi_after_break() {
18 /* Something meaningful to step through. */ 20 /* Something meaningful to step through. */
19 global_var = 0; 21 global_var = 0;
20 } 22 }
(...skipping 12 matching lines...) Expand all
33 } 35 }
34 36
35 int test_print_symbol() { 37 int test_print_symbol() {
36 int local_var = 3; 38 int local_var = 3;
37 global_var = 2 + local_var * 0; /* Use local variable to prevent warning. */ 39 global_var = 2 + local_var * 0; /* Use local variable to prevent warning. */
38 set_global_var(1); 40 set_global_var(1);
39 nested_calls(1); 41 nested_calls(1);
40 return global_var; 42 return global_var;
41 } 43 }
42 44
45 /* A function with non-trivial prolog. */
46 void test_step_from_function_start(int arg) {
47 int local_var = arg - 1;
48 global_var = local_var;
49 /*
50 * Force using frame pointer for this function by calling alloca.
51 * This allows to test skipping %esp modifying instructions when they
52 * are located in the middle of the function.
53 */
54 global_ptr = alloca(arg);
55 }
56
43 int main(int argc, char **argv) { 57 int main(int argc, char **argv) {
44 assert(argc >= 2); 58 assert(argc >= 2);
45 59
46 if (strcmp(argv[1], "break_inside_function") == 0) { 60 if (strcmp(argv[1], "break_inside_function") == 0) {
47 test_two_line_function(1); 61 test_two_line_function(1);
48 return 0; 62 return 0;
49 } 63 }
50 if (strcmp(argv[1], "stepi_after_break") == 0) { 64 if (strcmp(argv[1], "stepi_after_break") == 0) {
51 test_stepi_after_break(); 65 test_stepi_after_break();
52 return 0; 66 return 0;
53 } 67 }
54 if (strcmp(argv[1], "print_symbol") == 0) { 68 if (strcmp(argv[1], "print_symbol") == 0) {
55 return test_print_symbol(); 69 return test_print_symbol();
56 } 70 }
57 if (strcmp(argv[1], "stack_trace") == 0) { 71 if (strcmp(argv[1], "stack_trace") == 0) {
58 nested_calls(1); 72 nested_calls(1);
59 return 0; 73 return 0;
60 } 74 }
75 if (strcmp(argv[1], "step_from_func_start") == 0) {
76 global_var = 0;
77 test_step_from_function_start(2);
78 return 0;
79 }
61 return 1; 80 return 1;
62 } 81 }
OLDNEW
« no previous file with comments | « TOOL_REVISIONS ('k') | tests/gdb/nacl.scons » ('j') | tests/gdb/step_from_func_start.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698