| 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 <assert.h> | 7 #include <assert.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <alloca.h> | 9 #include <alloca.h> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 int local_var = arg - 1; | 47 int local_var = arg - 1; |
| 48 global_var = local_var; | 48 global_var = local_var; |
| 49 /* | 49 /* |
| 50 * Force using frame pointer for this function by calling alloca. | 50 * Force using frame pointer for this function by calling alloca. |
| 51 * This allows to test skipping %esp modifying instructions when they | 51 * This allows to test skipping %esp modifying instructions when they |
| 52 * are located in the middle of the function. | 52 * are located in the middle of the function. |
| 53 */ | 53 */ |
| 54 global_ptr = alloca(arg); | 54 global_ptr = alloca(arg); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int test_call_from_gdb(int arg) { |
| 58 global_var = 2 * arg; |
| 59 return 3 * arg; |
| 60 } |
| 61 |
| 57 int main(int argc, char **argv) { | 62 int main(int argc, char **argv) { |
| 58 assert(argc >= 2); | 63 assert(argc >= 2); |
| 59 | 64 |
| 60 if (strcmp(argv[1], "break_inside_function") == 0) { | 65 if (strcmp(argv[1], "break_inside_function") == 0) { |
| 61 test_two_line_function(1); | 66 test_two_line_function(1); |
| 62 return 0; | 67 return 0; |
| 63 } | 68 } |
| 64 if (strcmp(argv[1], "stepi_after_break") == 0) { | 69 if (strcmp(argv[1], "stepi_after_break") == 0) { |
| 65 test_stepi_after_break(); | 70 test_stepi_after_break(); |
| 66 return 0; | 71 return 0; |
| 67 } | 72 } |
| 68 if (strcmp(argv[1], "print_symbol") == 0) { | 73 if (strcmp(argv[1], "print_symbol") == 0) { |
| 69 return test_print_symbol(); | 74 return test_print_symbol(); |
| 70 } | 75 } |
| 71 if (strcmp(argv[1], "stack_trace") == 0) { | 76 if (strcmp(argv[1], "stack_trace") == 0) { |
| 72 nested_calls(1); | 77 nested_calls(1); |
| 73 return 0; | 78 return 0; |
| 74 } | 79 } |
| 75 if (strcmp(argv[1], "step_from_func_start") == 0) { | 80 if (strcmp(argv[1], "step_from_func_start") == 0) { |
| 76 global_var = 0; | 81 global_var = 0; |
| 77 test_step_from_function_start(2); | 82 test_step_from_function_start(2); |
| 78 return 0; | 83 return 0; |
| 79 } | 84 } |
| 85 if (strcmp(argv[1], "call_from_gdb") == 0) { |
| 86 /* Call function so that it doesn't get optimized away. */ |
| 87 return test_call_from_gdb(0); |
| 88 } |
| 80 return 1; | 89 return 1; |
| 81 } | 90 } |
| OLD | NEW |