1/* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 1998-2020 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18/* 19 * Test program for trace action commands 20 */ 21 22#include <string.h> 23 24#include "trace-common.h" 25 26static char gdb_char_test; 27static short gdb_short_test; 28static long gdb_long_test; 29static char gdb_arr_test[25]; 30static struct GDB_STRUCT_TEST 31{ 32 char c; 33 short s; 34 long l; 35 int bfield : 11; /* collect bitfield */ 36 char arr[25]; 37 struct GDB_STRUCT_TEST *next; 38} gdb_struct1_test, gdb_struct2_test, *gdb_structp_test, **gdb_structpp_test; 39 40static union GDB_UNION_TEST 41{ 42 char c; 43 short s; 44 long l; 45 int bfield : 11; /* collect bitfield */ 46 char arr[4]; 47 union GDB_UNION_TEST *next; 48} gdb_union1_test; 49 50void gdb_recursion_test (int, int, int, int, int, int, int); 51/* This function pointer is used to force the function to be called via 52 the global entry instead of local entry on ppc64le; otherwise, breakpoints 53 set at the global entry (i.e., '*foo') will not be hit. */ 54typedef void (*gdb_recursion_test_fp) (int, int, int, int, int, int, int); 55gdb_recursion_test_fp gdb_recursion_test_ptr = gdb_recursion_test; 56 57void gdb_recursion_test (int depth, 58 int q1, 59 int q2, 60 int q3, 61 int q4, 62 int q5, 63 int q6) 64{ /* gdb_recursion_test line 0 */ 65 int q = q1; /* gdbtestline 1 */ 66 67 q1 = q2; /* gdbtestline 2 */ 68 q2 = q3; /* gdbtestline 3 */ 69 q3 = q4; /* gdbtestline 4 */ 70 q4 = q5; /* gdbtestline 5 */ 71 q5 = q6; /* gdbtestline 6 */ 72 q6 = q; /* gdbtestline 7 */ 73 if (depth--) /* gdbtestline 8 */ 74 gdb_recursion_test_ptr (depth, q1, q2, q3, q4, q5, q6); /* gdbtestline 9 */ 75} 76 77 78unsigned long gdb_c_test( unsigned long *parm ) 79 80{ 81 char *p = "gdb_c_test"; 82 char *ridiculously_long_variable_name_with_equally_long_string_assignment; 83 register long local_reg = 7; 84 static unsigned long local_static, local_static_sizeof; 85 long local_long; 86 unsigned long *stack_ptr; 87 unsigned long end_of_stack; 88 89 ridiculously_long_variable_name_with_equally_long_string_assignment = 90 "ridiculously long variable name with equally long string assignment"; 91 local_static = 9; 92 local_static_sizeof = sizeof (struct GDB_STRUCT_TEST); 93 local_long = local_reg + 1; 94 stack_ptr = (unsigned long *) &local_long; 95 end_of_stack = 96 (unsigned long) &stack_ptr + sizeof(stack_ptr) + sizeof(end_of_stack) - 1; 97 98 gdb_char_test = gdb_struct1_test.c = (char) ((long) parm[1] & 0xff); 99 gdb_short_test = gdb_struct1_test.s = (short) ((long) parm[2] & 0xffff); 100 gdb_long_test = gdb_struct1_test.l = (long) ((long) parm[3] & 0xffffffff); 101 gdb_union1_test.l = (long) parm[4]; 102 gdb_arr_test[0] = gdb_struct1_test.arr[0] = (char) ((long) parm[1] & 0xff); 103 gdb_arr_test[1] = gdb_struct1_test.arr[1] = (char) ((long) parm[2] & 0xff); 104 gdb_arr_test[2] = gdb_struct1_test.arr[2] = (char) ((long) parm[3] & 0xff); 105 gdb_arr_test[3] = gdb_struct1_test.arr[3] = (char) ((long) parm[4] & 0xff); 106 gdb_arr_test[4] = gdb_struct1_test.arr[4] = (char) ((long) parm[5] & 0xff); 107 gdb_arr_test[5] = gdb_struct1_test.arr[5] = (char) ((long) parm[6] & 0xff); 108 gdb_struct1_test.bfield = 144; 109 gdb_struct1_test.next = &gdb_struct2_test; 110 gdb_structp_test = &gdb_struct1_test; 111 gdb_structpp_test = &gdb_structp_test; 112 113 gdb_recursion_test_ptr (3, (long) parm[1], (long) parm[2], (long) parm[3], 114 (long) parm[4], (long) parm[5], (long) parm[6]); 115 116 gdb_char_test = gdb_short_test = gdb_long_test = 0; 117 gdb_structp_test = (void *) 0; 118 gdb_structpp_test = (void *) 0; 119 memset ((char *) &gdb_struct1_test, 0, sizeof (gdb_struct1_test)); 120 memset ((char *) &gdb_struct2_test, 0, sizeof (gdb_struct2_test)); 121 local_static_sizeof = 0; 122 local_static = 0; 123 return ( (unsigned long) 0 ); 124} 125 126void gdb_asm_test (void) 127{ 128} 129 130static void begin () /* called before anything else */ 131{ 132} 133 134static void end () /* called after everything else */ 135{ 136} 137 138int 139main (argc, argv, envp) 140 int argc; 141 char *argv[], **envp; 142{ 143 int i; 144 unsigned long myparms[10]; 145 146 FAST_TRACEPOINT_LABEL (fast_tracepoint_loc); 147 148 begin (); 149 for (i = 0; i < sizeof (myparms) / sizeof (myparms[0]); i++) 150 myparms[i] = i; 151 152 gdb_c_test (&myparms[0]); 153 154 end (); 155 return 0; 156} 157 158