gdb/doc/
[external/binutils.git] / gdb / testsuite / gdb.trace / actions.c
1 /*
2  * Test program for trace action commands
3  */
4
5 #include <string.h>
6
7 static char   gdb_char_test;
8 static short  gdb_short_test;
9 static long   gdb_long_test;
10 static char   gdb_arr_test[25];
11 static struct GDB_STRUCT_TEST
12 {
13   char   c;
14   short  s;
15   long   l;
16   int    bfield : 11;   /* collect bitfield */
17   char   arr[25];
18   struct GDB_STRUCT_TEST *next;
19 } gdb_struct1_test, gdb_struct2_test, *gdb_structp_test, **gdb_structpp_test;
20
21 static union GDB_UNION_TEST
22 {
23   char   c;
24   short  s;
25   long   l;
26   int    bfield : 11;   /* collect bitfield */
27   char   arr[4];
28   union GDB_UNION_TEST *next;
29 } gdb_union1_test;
30
31 void gdb_recursion_test (int, int, int, int,  int,  int,  int);
32
33 void gdb_recursion_test (int depth, 
34                          int q1, 
35                          int q2, 
36                          int q3, 
37                          int q4, 
38                          int q5, 
39                          int q6)
40 {       /* gdb_recursion_test line 0 */
41   int q = q1;                                           /* gdbtestline 1 */
42
43   q1 = q2;                                              /* gdbtestline 2 */
44   q2 = q3;                                              /* gdbtestline 3 */
45   q3 = q4;                                              /* gdbtestline 4 */
46   q4 = q5;                                              /* gdbtestline 5 */
47   q5 = q6;                                              /* gdbtestline 6 */
48   q6 = q;                                               /* gdbtestline 7 */
49   if (depth--)                                          /* gdbtestline 8 */
50     gdb_recursion_test (depth, q1, q2, q3, q4, q5, q6); /* gdbtestline 9 */
51 }
52
53
54 unsigned long   gdb_c_test( unsigned long *parm )
55
56 {
57    char *p = "gdb_c_test";
58    char *ridiculously_long_variable_name_with_equally_long_string_assignment;
59    register long local_reg = 7;
60    static unsigned long local_static, local_static_sizeof;
61    long local_long;
62    unsigned long *stack_ptr;
63    unsigned long end_of_stack;
64
65    ridiculously_long_variable_name_with_equally_long_string_assignment = 
66      "ridiculously long variable name with equally long string assignment";
67    local_static = 9;
68    local_static_sizeof = sizeof (struct GDB_STRUCT_TEST);
69    local_long = local_reg + 1;
70    stack_ptr  = (unsigned long *) &local_long;
71    end_of_stack = 
72      (unsigned long) &stack_ptr + sizeof(stack_ptr) + sizeof(end_of_stack) - 1;
73
74    gdb_char_test   = gdb_struct1_test.c = (char)   ((long) parm[1] & 0xff);
75    gdb_short_test  = gdb_struct1_test.s = (short)  ((long) parm[2] & 0xffff);
76    gdb_long_test   = gdb_struct1_test.l = (long)   ((long) parm[3] & 0xffffffff);
77    gdb_union1_test.l = (long) parm[4];
78    gdb_arr_test[0] = gdb_struct1_test.arr[0] = (char) ((long) parm[1] & 0xff);
79    gdb_arr_test[1] = gdb_struct1_test.arr[1] = (char) ((long) parm[2] & 0xff);
80    gdb_arr_test[2] = gdb_struct1_test.arr[2] = (char) ((long) parm[3] & 0xff);
81    gdb_arr_test[3] = gdb_struct1_test.arr[3] = (char) ((long) parm[4] & 0xff);
82    gdb_arr_test[4] = gdb_struct1_test.arr[4] = (char) ((long) parm[5] & 0xff);
83    gdb_arr_test[5] = gdb_struct1_test.arr[5] = (char) ((long) parm[6] & 0xff);
84    gdb_struct1_test.bfield = 144;
85    gdb_struct1_test.next = &gdb_struct2_test;
86    gdb_structp_test      = &gdb_struct1_test;
87    gdb_structpp_test     = &gdb_structp_test;
88
89    gdb_recursion_test (3, (long) parm[1], (long) parm[2], (long) parm[3],
90                        (long) parm[4], (long) parm[5], (long) parm[6]);
91
92    gdb_char_test = gdb_short_test = gdb_long_test = 0;
93    gdb_structp_test  = (void *) 0;
94    gdb_structpp_test = (void *) 0;
95    memset ((char *) &gdb_struct1_test, 0, sizeof (gdb_struct1_test));
96    memset ((char *) &gdb_struct2_test, 0, sizeof (gdb_struct2_test));
97    local_static_sizeof = 0;
98    local_static = 0;
99    return ( (unsigned long) 0 );
100 }
101
102 static void gdb_asm_test (void)
103 {
104 }
105
106 static void begin ()    /* called before anything else */
107 {
108 }
109
110 static void end ()      /* called after everything else */
111 {
112 }
113
114 int
115 main (argc, argv, envp)
116      int argc;
117      char *argv[], **envp;
118 {
119   int i;
120   unsigned long myparms[10];
121
122   begin ();
123   for (i = 0; i < sizeof (myparms) / sizeof (myparms[0]); i++)
124     myparms[i] = i;
125
126   gdb_c_test (&myparms[0]);
127
128   end ();
129   return 0;
130 }
131