1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* Test program partial trace data visualization. */
26 typedef struct TEST_STRUCT
{
38 struct small_struct_b
: public small_struct
42 typedef int test_array
[4];
44 /* Global variables to be collected. */
50 test_struct globalstruct
;
53 small_struct g_smallstruct
;
54 small_struct_b g_smallstruct_b
;
58 const char g_const_string
[] = "hello world";
59 char g_string_unavail
[sizeof (g_const_string
)];
60 char g_string_partial
[sizeof (g_const_string
)];
61 const char *g_string_p
;
63 /* Used to check that <unavailable> is not the same as 0 in array
64 element repetitions. */
72 struct tuple tarray
[8];
89 static StructA static_struct_a
;
100 StructRef (unsigned int val
) : ref(d
) {}
111 struct StructB struct_b
;
112 struct StructA
StructB::static_struct_a
;
114 StructRef
g_structref(0x12345678);
115 StructRef
*g_structref_p
= &g_structref
;
118 /* Test functions. */
121 begin () /* called before anything else */
126 end () /* called after everything else */
135 i
+= globalc
+ globali
+ globalf
+ globald
;
136 i
+= globalstruct
.memberc
+ globalstruct
.memberi
;
137 i
+= globalstruct
.memberf
+ globalstruct
.memberd
;
140 return i
; /* set globals_test_func tracepoint here */
144 main (int argc
, char **argv
, char **envp
)
147 test_struct mystruct
;
151 /* Assign collectable values to global variables. */
156 globalstruct
.memberc
= 81;
157 globalstruct
.memberi
= 82;
158 globalstruct
.memberf
= 83.3;
159 globalstruct
.memberd
= 84.4;
160 globalp
= &globalstruct
;
162 for (i
= 0; i
< 15; i
++)
165 mystruct
.memberc
= 101;
166 mystruct
.memberi
= 102;
167 mystruct
.memberf
= 103.3;
168 mystruct
.memberd
= 104.4;
175 memset (&struct_b
, 0xaa, sizeof struct_b
);
176 memset (&struct_b
.static_struct_a
, 0xaa, sizeof struct_b
.static_struct_a
);
177 struct_b
.string
= g_const_string
;
178 memcpy (g_string_unavail
, g_const_string
, sizeof (g_const_string
));
179 memcpy (g_string_partial
, g_const_string
, sizeof (g_const_string
));
180 g_string_p
= g_const_string
;
182 /* Call test functions, so they can be traced and data collected. */
184 i
+= globals_test_func ();
186 /* Set 'em back to zero, so that the collected values will be
187 distinctly different from the "realtime" (end of test) values. */
193 globalstruct
.memberc
= 0;
194 globalstruct
.memberi
= 0;
195 globalstruct
.memberf
= 0;
196 globalstruct
.memberd
= 0;
198 for (i
= 0; i
< 15; i
++)
201 memset (&struct_b
, 0, sizeof struct_b
);
202 memset (&struct_b
.static_struct_a
, 0, sizeof struct_b
.static_struct_a
);
203 struct_b
.string
= NULL
;
204 memset (g_string_unavail
, 0, sizeof (g_string_unavail
));
205 memset (g_string_partial
, 0, sizeof (g_string_partial
));
210 g_structref
.clear ();
211 g_structref_p
= NULL
;