Debian Codegraph @

gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c

raw
1 /* Test BTF generation for BTF_KIND_TYPEDEF records.
2
3 7 typedef records are expected. We expect the following types (among others):
4 [1] int 'int' size=4 offset=0 bits=32 SIGNED
5 [2] typedef 'my_int' type=1
6 [3] typedef 'foo_int' type=1
7 [4] typedef 'bar_int' type=1
8 ..
9 [6] typedef 'CBAR' type=5
10 ..
11 [8] typedef 'CBARP' type=7
12 [9] struct '_node' size=16
13 ..
14 [11] typedef 'node_t' type=9
15 [12] struct '_arena'
16 ..
17 [15] typedef 'arena_t' type=12
18 [16] var 'a' type=2 linkage=1 (global)
19 [17] var 'suitcase' type=15 linkage=1 (global)
20 [18] var 'b' type=3 linkage=1 (global)
21 [19] var 'c' type=4 linkage=1 (global)
22 [20] var 'd' type=11 linkage=1 (global)
23 [21] var 'destination' type=6 linkage=1 (global)
24 [22] var 'ticket' type=8 linkage=1 (global)
25
26 Note that the order of the variables is not guaranteed, so we do not check
27 particular variables have exactly the right typedef. Instead, we check:
28 1. 7 typedef records are generated, along with the correct strings for them.
29 2. There is one variable pointing to each typedef. */
30
31 /* { dg-do compile } */
32 /* { dg-options "-O0 -gbtf -dA" } */
33
34 /* { dg-final { scan-assembler-times "\[\t \]0x8000000\[\t \]+\[^\n\]*btt_info" 7 } } */
35
36 /* { dg-final { scan-assembler-times "ascii \"my_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
37 /* { dg-final { scan-assembler-times "ascii \"foo_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
38 /* { dg-final { scan-assembler-times "ascii \"bar_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
39 /* { dg-final { scan-assembler-times "ascii \"CBAR.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
40 /* { dg-final { scan-assembler-times "ascii \"CBARP.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
41 /* { dg-final { scan-assembler-times "ascii \"node_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
42 /* { dg-final { scan-assembler-times "ascii \"arena_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
43
44 /* { dg-final { scan-assembler "BTF_KIND_VAR 'a'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'my_int'" } } */
45 /* { dg-final { scan-assembler "BTF_KIND_VAR 'b'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'foo_int'" } } */
46 /* { dg-final { scan-assembler "BTF_KIND_VAR 'c'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'bar_int'" } } */
47 /* { dg-final { scan-assembler "BTF_KIND_VAR 'd'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'node_t'" } } */
48 /* { dg-final { scan-assembler "BTF_KIND_VAR 'destination'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'CBAR'" } } */
49 /* { dg-final { scan-assembler "BTF_KIND_VAR 'ticket'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'CBARP'" } } */
50 /* { dg-final { scan-assembler "BTF_KIND_VAR 'suitcase'\[\\r\\n\]+\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\\(BTF_KIND_TYPEDEF 'arena_t'" } } */
51
52 typedef int my_int;
53 typedef int foo_int;
54 typedef int bar_int;
55
56 typedef const bar_int CBAR;
57 typedef const bar_int * CBARP;
58
59 typedef struct _node
60 {
61 foo_int name_off;
62 bar_int info;
63 struct _node * next;
64 } node_t;
65
66
67 typedef struct _arena
68 {
69 node_t nodes[16];
70 my_int vardata;
71 bar_int flags;
72 } arena_t;
73
74 my_int a;
75 foo_int b;
76 bar_int c;
77 node_t d;
78
79 CBAR destination;
80 CBARP ticket = &destination;
81
82 arena_t suitcase;