CTF/BTF testsuites
This commit adds a new testsuite for the CTF debug format. 2021-06-28 Indu Bhagat <indu.bhagat@oracle.com> David Faust <david.faust@oracle.com> gcc/testsuite/ * lib/gcc-dg.exp (gcc-dg-frontend-supports-ctf): New procedure. (gcc-dg-debug-runtest): Add -gctf support. * gcc.dg/debug/btf/btf-1.c: New test. * gcc.dg/debug/btf/btf-2.c: Likewise. * gcc.dg/debug/btf/btf-anonymous-struct-1.c: Likewise. * gcc.dg/debug/btf/btf-anonymous-union-1.c: Likewise. * gcc.dg/debug/btf/btf-array-1.c: Likewise. * gcc.dg/debug/btf/btf-bitfields-1.c: Likewise. * gcc.dg/debug/btf/btf-bitfields-2.c: Likewise. * gcc.dg/debug/btf/btf-bitfields-3.c: Likewise. * gcc.dg/debug/btf/btf-cvr-quals-1.c: Likewise. * gcc.dg/debug/btf/btf-enum-1.c: Likewise. * gcc.dg/debug/btf/btf-forward-1.c: Likewise. * gcc.dg/debug/btf/btf-function-1.c: Likewise. * gcc.dg/debug/btf/btf-function-2.c: Likewise. * gcc.dg/debug/btf/btf-int-1.c: Likewise. * gcc.dg/debug/btf/btf-pointers-1.c: Likewise. * gcc.dg/debug/btf/btf-struct-1.c: Likewise. * gcc.dg/debug/btf/btf-typedef-1.c: Likewise. * gcc.dg/debug/btf/btf-union-1.c: Likewise. * gcc.dg/debug/btf/btf-variables-1.c: Likewise. * gcc.dg/debug/btf/btf.exp: Likewise. * gcc.dg/debug/ctf/ctf-1.c: Likewise. * gcc.dg/debug/ctf/ctf-2.c: Likewise. * gcc.dg/debug/ctf/ctf-anonymous-struct-1.c: Likewise. * gcc.dg/debug/ctf/ctf-anonymous-union-1.c: Likewise. * gcc.dg/debug/ctf/ctf-array-1.c: Likewise. * gcc.dg/debug/ctf/ctf-array-2.c: Likewise. * gcc.dg/debug/ctf/ctf-array-3.c: Likewise. * gcc.dg/debug/ctf/ctf-array-4.c: Likewise. * gcc.dg/debug/ctf/ctf-attr-mode-1.c: Likewise. * gcc.dg/debug/ctf/ctf-attr-used-1.c: Likewise. * gcc.dg/debug/ctf/ctf-bitfields-1.c: Likewise. * gcc.dg/debug/ctf/ctf-bitfields-2.c: Likewise. * gcc.dg/debug/ctf/ctf-bitfields-3.c: Likewise. * gcc.dg/debug/ctf/ctf-bitfields-4.c: Likewise. * gcc.dg/debug/ctf/ctf-complex-1.c: Likewise. * gcc.dg/debug/ctf/ctf-cvr-quals-1.c: Likewise. * gcc.dg/debug/ctf/ctf-cvr-quals-2.c: Likewise. * gcc.dg/debug/ctf/ctf-cvr-quals-3.c: Likewise. * gcc.dg/debug/ctf/ctf-cvr-quals-4.c: Likewise. * gcc.dg/debug/ctf/ctf-enum-1.c: Likewise. * gcc.dg/debug/ctf/ctf-enum-2.c: Likewise. * gcc.dg/debug/ctf/ctf-file-scope-1.c: Likewise. * gcc.dg/debug/ctf/ctf-float-1.c: Likewise. * gcc.dg/debug/ctf/ctf-forward-1.c: Likewise. * gcc.dg/debug/ctf/ctf-forward-2.c: Likewise. * gcc.dg/debug/ctf/ctf-func-index-1.c: Likewise. * gcc.dg/debug/ctf/ctf-function-pointers-1.c: Likewise. * gcc.dg/debug/ctf/ctf-function-pointers-2.c: Likewise. * gcc.dg/debug/ctf/ctf-function-pointers-3.c: Likewise. * gcc.dg/debug/ctf/ctf-functions-1.c: Likewise. * gcc.dg/debug/ctf/ctf-int-1.c: Likewise. * gcc.dg/debug/ctf/ctf-objt-index-1.c: Likewise. * gcc.dg/debug/ctf/ctf-pointers-1.c: Likewise. * gcc.dg/debug/ctf/ctf-pointers-2.c: Likewise. * gcc.dg/debug/ctf/ctf-preamble-1.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-1.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-2.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-3.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-4.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-5.c: Likewise. * gcc.dg/debug/ctf/ctf-skip-types-6.c: Likewise. * gcc.dg/debug/ctf/ctf-str-table-1.c: Likewise. * gcc.dg/debug/ctf/ctf-struct-1.c: Likewise. * gcc.dg/debug/ctf/ctf-struct-2.c: Likewise. * gcc.dg/debug/ctf/ctf-struct-array-1.c: Likewise. * gcc.dg/debug/ctf/ctf-struct-pointer-1.c: Likewise. * gcc.dg/debug/ctf/ctf-struct-pointer-2.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-1.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-2.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-3.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-struct-1.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-struct-2.c: Likewise. * gcc.dg/debug/ctf/ctf-typedef-struct-3.c: Likewise. * gcc.dg/debug/ctf/ctf-union-1.c: Likewise. * gcc.dg/debug/ctf/ctf-variables-1.c: Likewise. * gcc.dg/debug/ctf/ctf-variables-2.c: Likewise. * gcc.dg/debug/ctf/ctf.exp: Likewise.
This commit is contained in:
parent
b7e215a8ee
commit
c1f76af469
91 changed files with 2376 additions and 15 deletions
6
gcc/testsuite/gcc.dg/debug/btf/btf-1.c
Normal file
6
gcc/testsuite/gcc.dg/debug/btf/btf-1.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-gbtf" } */
|
||||
|
||||
void func(void)
|
||||
{
|
||||
}
|
10
gcc/testsuite/gcc.dg/debug/btf/btf-2.c
Normal file
10
gcc/testsuite/gcc.dg/debug/btf/btf-2.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* Check the BTF header information. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0xeb9f.*btf_magic" 1} } */
|
||||
/* { dg-final { scan-assembler-times "0x1.*btf_version" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "0.*btf_flags" 1 } } */
|
||||
|
||||
int foo;
|
23
gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c
Normal file
23
gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Test BTF generation of anonymous struct.
|
||||
|
||||
We expect two BTF struct records:
|
||||
- struct foo, with two fields "a" and "bar"
|
||||
- struct <anonymous> with one field "b"
|
||||
|
||||
The anonymous struct should have a name of 0, pointing to the null string
|
||||
at the start of the string table. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Struct type with 2 members (struct foo). */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* Struct type with 1 member (anon struct). */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */
|
||||
|
||||
struct foo
|
||||
{
|
||||
int a;
|
||||
struct { int b; } bar;
|
||||
} myfoo;
|
23
gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c
Normal file
23
gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Test BTF generation of anonymous union.
|
||||
|
||||
We expect a named struct type and an anonymous union type record to
|
||||
be generated. The anonymous union record should have a name of 0,
|
||||
pointing to the null string at the start of the string table. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Struct type with 1 member. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* Union type with 2 members. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */
|
||||
|
||||
struct foo
|
||||
{
|
||||
union
|
||||
{
|
||||
int value;
|
||||
char ascii;
|
||||
};
|
||||
} myfoo;
|
31
gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c
Normal file
31
gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* BTF generation for array type.
|
||||
|
||||
Unsized arrays are encoded with a 0 for the number of elements.
|
||||
|
||||
In this testcase, 5 distinct BTF records for arrays are expected
|
||||
b1 : cta_nelems = 2
|
||||
c1 : cta_nelems = 3
|
||||
a1 : cta_nelems = 2, 5
|
||||
buf : cta_nelems = 0. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x3000000\[\t \]+\[^\n\]*btt_info" 5 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*bta_nelems" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*bta_nelems" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*bta_nelems" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*bta_nelems" 1 } } */
|
||||
|
||||
int b1[2] = {0,1};
|
||||
int c1[5] = {0,1,2,3,4};
|
||||
int a1[2][3] = { {3,4,5}, {2,3,4} };
|
||||
|
||||
/* Variable length struct using arrays. */
|
||||
struct my_array
|
||||
{
|
||||
int flags;
|
||||
int length;
|
||||
int buf[];
|
||||
} my_array_obj;
|
34
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c
Normal file
34
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Basic tests for BTF bitfields.
|
||||
|
||||
The structure containing bitfield members should be marked with KIND_FLAG=1
|
||||
The bitfield member offsets should be encoded as:
|
||||
(bit_size << 24) | bit_offset
|
||||
- (0xa << 24) | 0x20
|
||||
- (0x7 << 24) | 0x2a
|
||||
- (0x13 << 24) | 0x40 - note that this is aligned to 0x40. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x84000004\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xa000020\[\t \]+\[^\n\]*btm_offset" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x700002a\[\t \]+\[^\n\]*btm_offset" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x13000040\[\t \]+\[^\n\]*btm_offset" 1 } } */
|
||||
|
||||
struct bitt {
|
||||
int a;
|
||||
unsigned int bitfield_a : 10;
|
||||
unsigned int bitfield_b : 7;
|
||||
unsigned int bitfield_c : 19;
|
||||
} bitty;
|
||||
|
||||
struct no_bitt {
|
||||
int a;
|
||||
int b;
|
||||
} no_bitty;
|
||||
|
||||
int main ()
|
||||
{
|
||||
return bitty.bitfield_b + bitty.a;
|
||||
}
|
26
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c
Normal file
26
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test BTF generation for struct with 0 size bitfield.
|
||||
|
||||
We expect a struct with 2 members to be generated. The size 0 bitfield
|
||||
should not have any entry in the member list. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Struct with bitfield members, and 2 members. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x84000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* Bitfield size 31 (0x1f) at offset 0. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1f000000\[\t \]+\[^\n\]*btm_offset" 1 } } */
|
||||
|
||||
/* Bitfield size 32 (0x20) at offset 32. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x20000020\[\t \]+\[^\n\]*btm_offset" 1 } } */
|
||||
|
||||
/* Only 2 members. */
|
||||
/* { dg-final { scan-assembler-times "btm_name" 2 } } */
|
||||
|
||||
struct foo
|
||||
{
|
||||
unsigned a : 31;
|
||||
unsigned : 0;
|
||||
unsigned c : 32;
|
||||
} myfoo;
|
43
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c
Normal file
43
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* Test BTF generation for enum-type bitfields
|
||||
|
||||
It is allowed to have a bitfield type be an enum type.
|
||||
We expect the following types:
|
||||
|
||||
[1] enum 'foo'(1U#B) size=4U#B
|
||||
'BAR' value=0
|
||||
'BAZ' value=1
|
||||
'QUZ' value=2
|
||||
'QUX' value=3
|
||||
[2] int 'unsigned int' size=4 offset=0 bits=32
|
||||
[3] struct 'bitt' size=4
|
||||
member 'f' type=1 bitfield_size=2 bit_offset=0
|
||||
member 'data' type=2 bitfield_size=14 bit_offset=2
|
||||
*/
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Enum with 4 members. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* Struct with bitfield members, and 2 members. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x84000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* Bitfield "f" points to type ID 1. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*btm_type" 1 } } */
|
||||
|
||||
/* Bitfield "data" points to type ID 2. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*btm_type" 1 } } */
|
||||
|
||||
enum foo
|
||||
{
|
||||
BAR = 0,
|
||||
BAZ = 1,
|
||||
QUZ = 2,
|
||||
QUX = 3
|
||||
};
|
||||
|
||||
struct bitt
|
||||
{
|
||||
enum foo f : 2;
|
||||
unsigned data : 14;
|
||||
} bitty;
|
23
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c
Normal file
23
gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Test BTF generation for non-representable bitfields.
|
||||
|
||||
Due to the limitations of BTF, we only have 24 bits in which to store
|
||||
the bitfield offset (in bits, from the beginning of the struct).
|
||||
|
||||
In this test, we construct a structure such that the bitfield will have
|
||||
an offset so large as to be unrepresentable in BTF. We expect that the
|
||||
resulting BTF will describe the rest of the structure, ignoring the
|
||||
non-representable bitfield. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Struct with 3 members and no bitfield (kind_flag not set). */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000003\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
struct bigly
|
||||
{
|
||||
int a;
|
||||
int b[((0xffffff + 1) / (8 * sizeof (int)))];
|
||||
unsigned unsup : 7;
|
||||
char c;
|
||||
} big;
|
52
gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c
Normal file
52
gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Test BTF generation of BTF_KIND_{CONST,VOLATILE,RESTRICT} records.
|
||||
|
||||
BTF const, volatile and restrict records are nameless type records pointing
|
||||
to the type they modify.
|
||||
|
||||
Types:
|
||||
[1] int 'int' size=4U offset=0 bits=32 SIGNED
|
||||
[2] const <anonymous> type=1
|
||||
[3] volatile <anonymous> type=1
|
||||
[4] const <anonymous> type=3
|
||||
[5] ptr <anonymous> type=1
|
||||
[6] restrict <anonymous> type=5
|
||||
[7] ptr <anonymous> type=2
|
||||
[8] restrict <anonymous> type=7
|
||||
|
||||
Note:
|
||||
- Type id 3 describes a volatile int.
|
||||
- Type id 2 describes a const int.
|
||||
- Type id 4 describes a const volatile int by modifying id 3.
|
||||
- Type id 6 describes a restrict pointer to int.
|
||||
- Type id 8 describes a restrict pointer to const int.
|
||||
*/
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
|
||||
/* types 5 and 7 are pointers, to 'int' and 'const int' respectively. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 2 } } */
|
||||
|
||||
/* type 3 has VOLATILE qualifier */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x9000000\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* types 2 and 4 have CONST qualifier. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xa000000\[\t \]+\[^\n\]*btt_info" 2 } } */
|
||||
|
||||
/* types 6 and 8 have RESTRICT qualifier. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xb000000\[\t \]+\[^\n\]*btt_info" 2 } } */
|
||||
|
||||
const int a = 10;
|
||||
|
||||
volatile int b;
|
||||
|
||||
int * restrict c;
|
||||
|
||||
const volatile int d = 20;
|
||||
|
||||
const int * restrict e;
|
||||
|
||||
const int * f;
|
||||
int const * g;
|
45
gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
Normal file
45
gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* BTF generation of BTF_KIND_DATASEC records.
|
||||
|
||||
We expect 3 DATASEC records: one for each of .data, .rodata and .bss.
|
||||
.rodata: the consts; c,e,my_cstruct
|
||||
.bss: a,b,bigarr
|
||||
.data: d
|
||||
|
||||
The type IDs of the variables placed in each section are not deterministic
|
||||
so we cannot check them.
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Check for two DATASEC entries with vlen 3, and one with vlen 1. */
|
||||
/* { dg-final { scan-assembler-times "0xf000003\[\t \]+\[^\n\]*btt_info" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "0xf000001\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* The offset entry for each variable in a DATSEC should be 0 at compile time. */
|
||||
/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 7 } } */
|
||||
|
||||
/* Check that strings for each DATASEC have been added to the BTF string table. */
|
||||
/* { dg-final { scan-assembler-times "ascii \".data.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \".rodata.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \".bss.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
|
||||
|
||||
int a;
|
||||
long long b;
|
||||
const long unsigned int c;
|
||||
|
||||
int d = 137;
|
||||
|
||||
const int e = -55;
|
||||
|
||||
int bigarr[20][10];
|
||||
|
||||
struct c_struct {
|
||||
long x;
|
||||
char c;
|
||||
};
|
||||
|
||||
const struct c_struct my_cstruct = {
|
||||
99,
|
||||
'?'
|
||||
};
|
30
gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c
Normal file
30
gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Test BTF generation for enums. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6000003\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"QAD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"QED.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"QOD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"QUD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"YES.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"NO.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"IDUNNO.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "bte_value" 7 } } */
|
||||
|
||||
enum foo
|
||||
{
|
||||
QAD,
|
||||
QED,
|
||||
QOD,
|
||||
QUD,
|
||||
} a;
|
||||
|
||||
enum barsigned
|
||||
{
|
||||
YES=1000,
|
||||
NO=-1000,
|
||||
IDUNNO=0,
|
||||
} b;
|
24
gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c
Normal file
24
gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Test BTF generation of forwards.
|
||||
|
||||
Check that the KIND_FLAG (bit 31) of btt_info is set (1) for the forward to
|
||||
union, and not set (0) for forward to struct. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x87000000\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x7000000\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
typedef struct _fwd_st
|
||||
{
|
||||
struct unk_struct_type *data[4];
|
||||
} fwd_st_t;
|
||||
|
||||
fwd_st_t struct_container;
|
||||
|
||||
typedef struct _fwd_un
|
||||
{
|
||||
union unk_union_type *options[4];
|
||||
} fwd_un_t;
|
||||
|
||||
fwd_un_t union_container;
|
18
gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c
Normal file
18
gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Test BTF generation for functions.
|
||||
|
||||
We expect to see one BTF_KIND_FUNC_PROTO with 2 named arguments.
|
||||
The parameter names should appear in the auxilliary string table. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xd000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_name" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_type" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"alpha.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"bravo.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
|
||||
|
||||
int funfoo (int alpha, long bravo)
|
||||
{
|
||||
return 0;
|
||||
}
|
18
gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c
Normal file
18
gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Test BTF generation for functions with varargs.
|
||||
|
||||
We expect one BTF_KIND_FUNC_PROTO with two arguments. The second argument
|
||||
should have "farg_name" and "farg_type" both of 0, representing varargs. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xd000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_name" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_type" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_name" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_type" 1 } } */
|
||||
|
||||
int fmt (const char * format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
22
gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c
Normal file
22
gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Test BTF generation for a function with an unrepresentable parameter.
|
||||
|
||||
BTF has no encoding for floating point types, among others. Function
|
||||
parameters of unrepresentable types are emitted as 'void' types.
|
||||
|
||||
We expect one BTF_KIND_FUNC_PROTO with 3 parameters, one of which
|
||||
has type_id=0. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xd000003\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_name" 3 } } */
|
||||
/* { dg-final { scan-assembler-times "farg_type" 3 } } */
|
||||
|
||||
/* Exactly one function parameter should have type_id=0. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_type" 1 } } */
|
||||
|
||||
int foo (int a, float f, long b)
|
||||
{
|
||||
return 0;
|
||||
}
|
44
gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
Normal file
44
gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* Tests for BTF integer base types.
|
||||
|
||||
0 f ff 00 ff
|
||||
| 0 | encoding | offset | 00 | bits |
|
||||
encoding:
|
||||
signed 1 << 24
|
||||
char 2 << 24
|
||||
|
||||
All offsets in this test should be 0.
|
||||
This test does _not_ check number of bits, as it may vary between targets.
|
||||
*/
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Check for 8 BTF_KIND_INT types. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 8 } } */
|
||||
|
||||
/* Check the signed/char flags, but not bit size. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 3 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x20000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x30000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
|
||||
|
||||
/* Check that there is a string entry for each type name. */
|
||||
/* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"signed char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"short unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"short int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"long unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"long int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
|
||||
unsigned char a = 11;
|
||||
signed char b = -22;
|
||||
|
||||
unsigned short c = 33;
|
||||
signed short d = 44;
|
||||
|
||||
unsigned int e = 55;
|
||||
signed int f = -66;
|
||||
|
||||
unsigned long int g = 77;
|
||||
signed long int h = 88;
|
25
gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c
Normal file
25
gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Test BTF generation for pointer types.
|
||||
|
||||
Two pointer types are expected:
|
||||
- int *
|
||||
- struct st *
|
||||
*/
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"st.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
|
||||
int foo = 10;
|
||||
int *pfoo = &foo;
|
||||
|
||||
struct st
|
||||
{
|
||||
int a;
|
||||
int *pb;
|
||||
struct st * next;
|
||||
};
|
||||
|
||||
struct st * bar;
|
13
gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c
Normal file
13
gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Test BTF generation for pointers to void.
|
||||
|
||||
In this test, we expect that the pointer references type ID 0, the reserved
|
||||
void typeid, and that no intermediate type is generated for void. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 0 } } */
|
||||
|
||||
void *ptr;
|
22
gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c
Normal file
22
gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Test BTF generation of struct type.
|
||||
|
||||
Two BTF_KIND_STRUCT records are expected.
|
||||
- struct foo with 3 members
|
||||
- struct data with 2 members */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000003\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "btm_name" 5 } } */
|
||||
|
||||
struct foo
|
||||
{
|
||||
int after;
|
||||
int before;
|
||||
struct {
|
||||
unsigned short n_valid;
|
||||
int set[10];
|
||||
} data;
|
||||
} my_foo;
|
19
gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c
Normal file
19
gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Test BTF generation for struct type with a member which refers to an
|
||||
unsupported type.
|
||||
|
||||
BTF does not support floating point types (among other things). When
|
||||
generating BTF for a struct (or union) type, members which refer to
|
||||
unsupported types should be skipped. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Expect a struct with only 2 members - 'f' should not be present. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
|
||||
struct with_float
|
||||
{
|
||||
int a;
|
||||
float f;
|
||||
char c;
|
||||
} instance;
|
82
gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c
Normal file
82
gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* Test BTF generation for BTF_KIND_TYPEDEF records.
|
||||
|
||||
7 typedef records are expected. We expect the following types (among others):
|
||||
[1] int 'int' size=4 offset=0 bits=32 SIGNED
|
||||
[2] typedef 'my_int' type=1
|
||||
[3] typedef 'foo_int' type=1
|
||||
[4] typedef 'bar_int' type=1
|
||||
..
|
||||
[6] typedef 'CBAR' type=5
|
||||
..
|
||||
[8] typedef 'CBARP' type=7
|
||||
[9] struct '_node' size=16
|
||||
..
|
||||
[11] typedef 'node_t' type=9
|
||||
[12] struct '_arena'
|
||||
..
|
||||
[15] typedef 'arena_t' type=12
|
||||
[16] var 'a' type=2 linkage=1 (global)
|
||||
[17] var 'suitcase' type=15 linkage=1 (global)
|
||||
[18] var 'b' type=3 linkage=1 (global)
|
||||
[19] var 'c' type=4 linkage=1 (global)
|
||||
[20] var 'd' type=11 linkage=1 (global)
|
||||
[21] var 'destination' type=6 linkage=1 (global)
|
||||
[22] var 'ticket' type=8 linkage=1 (global)
|
||||
|
||||
Note that the order of the variables is not guaranteed, so we do not check
|
||||
particular variables have exactly the right typedef. Instead, we check:
|
||||
1. 7 typedef records are generated, along with the correct strings for them.
|
||||
2. There is one variable pointing to each typedef. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x8000000\[\t \]+\[^\n\]*btt_info" 7 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"my_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"bar_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"CBAR.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"CBARP.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"node_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"arena_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xb\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*btv_type" 1 } } */
|
||||
|
||||
typedef int my_int;
|
||||
typedef int foo_int;
|
||||
typedef int bar_int;
|
||||
|
||||
typedef const bar_int CBAR;
|
||||
typedef const bar_int * CBARP;
|
||||
|
||||
typedef struct _node
|
||||
{
|
||||
foo_int name_off;
|
||||
bar_int info;
|
||||
struct _node * next;
|
||||
} node_t;
|
||||
|
||||
|
||||
typedef struct _arena
|
||||
{
|
||||
node_t nodes[16];
|
||||
my_int vardata;
|
||||
bar_int flags;
|
||||
} arena_t;
|
||||
|
||||
my_int a;
|
||||
foo_int b;
|
||||
bar_int c;
|
||||
node_t d;
|
||||
|
||||
CBAR destination;
|
||||
CBARP ticket = &destination;
|
||||
|
||||
arena_t suitcase;
|
16
gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c
Normal file
16
gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* Test BTF generation for union type. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* One union type with 4 members */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5000004\[\t \]+\[^\n\]*btt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "btm_name" 4 } } */
|
||||
|
||||
union onion
|
||||
{
|
||||
int redness;
|
||||
char *name;
|
||||
unsigned short freshness;
|
||||
unsigned short flavor;
|
||||
} my_onion;
|
33
gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c
Normal file
33
gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* BTF generation for variables. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* We expect 6 variables */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 6 } } */
|
||||
|
||||
unsigned int x1;
|
||||
|
||||
struct st
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
union {
|
||||
long int value;
|
||||
struct st * pointer;
|
||||
} bar;
|
||||
|
||||
enum
|
||||
{
|
||||
FOO = 0,
|
||||
BAR = 2,
|
||||
BAZ,
|
||||
} lala;
|
||||
|
||||
int arr[10][20];
|
||||
|
||||
unsigned long * plong;
|
||||
|
||||
struct st st_inst;
|
27
gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c
Normal file
27
gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* BTF generation for variables with removed type.
|
||||
|
||||
BTF does not support floating point types, so no representation for the type
|
||||
'float' will be emitted. In this test, we check to also ensure that the
|
||||
variable 'bar' is not emitted, as it references a type that is not supported
|
||||
in BTF. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* We expect only 3 variables. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 3 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"baz.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"myst.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
|
||||
|
||||
int foo;
|
||||
float bar;
|
||||
int baz[10];
|
||||
|
||||
struct st
|
||||
{
|
||||
int a;
|
||||
int b : 6;
|
||||
int c : 2;
|
||||
} myst;
|
36
gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c
Normal file
36
gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Test BTF generation for static versus global variables.
|
||||
|
||||
BTF_KIND_VAR types represeting variables are followed by a 32-bit
|
||||
"linkage", which can take one of currently two valid values:
|
||||
0 = static
|
||||
1 = global
|
||||
|
||||
In this test, make a few static and a few global variables, and ensure
|
||||
they are noted with the correct "linkage" values. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gbtf -dA" } */
|
||||
|
||||
/* Expect 6 variables. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 6 } } */
|
||||
|
||||
/* 3 global, 3 static. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btv_linkage" 3 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*btv_linkage" 3 } } */
|
||||
|
||||
int a;
|
||||
|
||||
static long b;
|
||||
|
||||
struct foo {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct foo g_foo;
|
||||
|
||||
static struct foo s_foo;
|
||||
|
||||
static unsigned int s_arr [10][5];
|
||||
|
||||
unsigned int g_arr [20];
|
41
gcc/testsuite/gcc.dg/debug/btf/btf.exp
Normal file
41
gcc/testsuite/gcc.dg/debug/btf/btf.exp
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GCC; see the file COPYING3. If not see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
# GCC testsuite that uses the `dg.exp' driver.
|
||||
|
||||
# Load support procs.
|
||||
load_lib gcc-dg.exp
|
||||
|
||||
# Disable on ptx (in sync with DWARF testsuite)
|
||||
if { [istarget nvptx-*-*] } {
|
||||
return
|
||||
}
|
||||
|
||||
# If a testcase doesn't have special options, use these.
|
||||
global DEFAULT_CFLAGS
|
||||
if ![info exists DEFAULT_CFLAGS] then {
|
||||
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
|
||||
}
|
||||
|
||||
# Initialize `dg'.
|
||||
dg-init
|
||||
|
||||
# Main loop.
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
|
||||
"" $DEFAULT_CFLAGS
|
||||
|
||||
# All done.
|
||||
dg-finish
|
6
gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c
Normal file
6
gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
void func(void)
|
||||
{
|
||||
}
|
10
gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c
Normal file
10
gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* A LEVEL of 0 with -gctf turns off CTF debug info generation. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf0 -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0xdff2.*CTF preamble magic number" 0} } */
|
||||
/* { dg-final { scan-assembler-times "0x4.*CTF preamble version" 0 } } */
|
||||
/* { dg-final { scan-assembler-times "0.*CTF preamble flags" 0 } } */
|
||||
|
||||
const char * _CONTEXT_NAME = "foobar";
|
23
gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c
Normal file
23
gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Test compilation and CTF generation of anonymous structs. An anonymous
|
||||
struct type is encoded as no-name CTF struct type.
|
||||
|
||||
For this testcase, a single CTF anonymous struct is expected.
|
||||
struct {} : ctt_name = 0 (point to offset 0 in the CTF string table to
|
||||
denote empty string)
|
||||
|
||||
Two CTF struct records should be generated in total.
|
||||
struct a : ctt_info = 0x1a000002 (2 fields)
|
||||
struct {} : ctt_info = 0x1a000001 (1 field) */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "0x1a000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "0x1a000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
struct a
|
||||
{
|
||||
struct { int b1; } a1;
|
||||
int a2;
|
||||
} my_a;
|
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c
Normal file
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test compilation and CTF generation of anonymous union. An anonymous union
|
||||
is encoded as no-name CTF union type.
|
||||
|
||||
For this testcase, a single CTF anonymous union is expected.
|
||||
struct {} : ctt_name = 0 (point to offset 0 in the CTF string table to
|
||||
denote empty string)
|
||||
|
||||
Two CTF struct records should be generated in total.
|
||||
struct anon_union : ctt_info = 0x1a000001 (1 field)
|
||||
union {} : ctt_info = 0x1e000002 (2 fields) */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "0x1a000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "0x1e000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
struct anon_union
|
||||
{
|
||||
union
|
||||
{
|
||||
char name;
|
||||
int value;
|
||||
};
|
||||
} my_anon_u;
|
31
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c
Normal file
31
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* CTF generation for array type.
|
||||
|
||||
Unsized arrays are encoded with a 0 for the number of elements.
|
||||
|
||||
In this testcase, 5 distinct CTF records for arrays are expected
|
||||
b1 : cta_nelems = 2
|
||||
c1 : cta_nelems = 3
|
||||
a1 : cta_nelems = 2, 5
|
||||
buf : cta_nelems = 0. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cta_nelems" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
|
||||
int b1[2] = {0,1};
|
||||
int c1[5] = {0,1,2,3,4};
|
||||
int a1[2][3] = { {3,4,5}, {2,3,4} };
|
||||
|
||||
/* Variable length struct using arrays. */
|
||||
struct my_array
|
||||
{
|
||||
int flags;
|
||||
int length;
|
||||
int buf[];
|
||||
} my_array_obj;
|
38
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c
Normal file
38
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* CTF generation for unsized arrays.
|
||||
|
||||
Unsized arrays are encoded with a 0 for the number of elements. The type
|
||||
of array index is the INT type.
|
||||
|
||||
TBD_CTF_FORMAT_OPEN_ISSUES (1) -
|
||||
This testcase makes a note of the case of a probable misrepresentation.
|
||||
See Note 1 and Note 2 below.
|
||||
|
||||
In the CTF section, these types are encoded as :
|
||||
|
||||
Variables:
|
||||
_CTF_NEWSTR -> 7: const char [0] (size 0x0)
|
||||
_CTF_SECTION -> 6: const char [5] (size 0x5)
|
||||
b1 -> 2: int [0] (size 0x0)
|
||||
b2 -> 3: int [0] (size 0x0)
|
||||
|
||||
Note 1 : There is misrepresentation in that b1 and b2 are specified
|
||||
differently by the user.
|
||||
Note 2 : It is arguable though whether the representation for
|
||||
_CTF_NEWSTR is incorrect. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 3 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
|
||||
static int b1[] = {};
|
||||
|
||||
int b2[0];
|
||||
|
||||
const char _CTF_SECTION[] = ".ctf";
|
||||
|
||||
extern const char _CTF_NEWSTR[];
|
||||
const char _CTF_NEWSTR[] = "ctfinfo";
|
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c
Normal file
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* CTF generation for variable length arrays.
|
||||
|
||||
In this testcase, a specific flavor of vla appears in the function
|
||||
signature.
|
||||
|
||||
TBD_CTF_FORMAT_OPEN_ISSUES (1) -
|
||||
This testcase makes a note of another case of a probable misrepresentation.
|
||||
See ctf-array-2.c for some context on how vla's are a case of a probable
|
||||
misrepresentation in CTF. Nevertheless, compilation should not fail. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
int foo (int a, int b[a][a])
|
||||
{
|
||||
return b[a-1][a-3];
|
||||
}
|
13
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c
Normal file
13
gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* CTF generation for array type.
|
||||
|
||||
Test CTF generation for single element arrays. In this testcase, one CTF
|
||||
record for array is expected with cta_nelems = 1. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
|
||||
int b[1];
|
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c
Normal file
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Test CTF generation works well with ((mode)) attribute.
|
||||
|
||||
In this testcase, CTF should report type of bqi to be an enum and
|
||||
not an int. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"B1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"B2.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"B3.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "cte_value" 3} } */
|
||||
|
||||
/* There are no better/direct methods to assert that the CTF for typedef of
|
||||
enum has been added. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x22000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*ctv_typeidx" 1} } */
|
||||
|
||||
typedef enum { B1 = 1, B2 = 2, B3 = 3 } B;
|
||||
B __attribute__ ((mode (QI))) bqi;
|
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c
Normal file
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Test CTF generation works well with ((used)) function attribute.
|
||||
|
||||
This attribute, attached to a function, means that code must be emitted for
|
||||
the function even if it appears that the function is not referenced. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O2 -gctf -dA" } */
|
||||
|
||||
/* These should be true for higher optimization levels. */
|
||||
/* { dg-final { scan-assembler-times "ascii \"keep_this.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"lose_this.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
|
||||
|
||||
static int lose_this(int a)
|
||||
{
|
||||
return a + 2;
|
||||
}
|
||||
|
||||
__attribute__((used))
|
||||
static int keep_this(double a)
|
||||
{
|
||||
return a * 2;
|
||||
}
|
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c
Normal file
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* CTF generation for bitfields.
|
||||
|
||||
In this testcase, two slices are expected - one for enum and the other for
|
||||
int. CTF slices are unnamed records. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_bits" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*cts_bits" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 2 } } */
|
||||
|
||||
enum color
|
||||
{
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
YELLOW,
|
||||
ORANGE,
|
||||
BLACK
|
||||
};
|
||||
|
||||
struct quickcolor
|
||||
{
|
||||
enum color col:3;
|
||||
int brushid:2;
|
||||
int strokes;
|
||||
};
|
||||
|
||||
struct quickcolor qc;
|
39
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c
Normal file
39
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* The bitfield type (int) may be shared, but slices are not de-duplicated.
|
||||
|
||||
In this testcase, it is expected to see a total of 6 CTF slices and 2 CTF
|
||||
integer types for the bitfields - unsigned long long and signed long long.
|
||||
|
||||
cts_offset is the offset of the bitfield into a machine word.
|
||||
TBD - hardcoding cts_offset checks into the testcase will cause it to break
|
||||
across targets with different BIT_PER_WORD. Is there a way to add
|
||||
cts_offset related checks in the testcase? */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*cts_type" 3 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 3 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*cts_bits" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x21\[\t \]+\[^\n\]*cts_bits" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x10\[\t \]+\[^\n\]*cts_bits" 2 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"long long unsigned int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"long long int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
struct fields
|
||||
{
|
||||
unsigned long long u1 : 15;
|
||||
unsigned long long u2 : 33;
|
||||
unsigned long long u3 : 16;
|
||||
signed long long s1 : 15;
|
||||
signed long long s2 : 33;
|
||||
signed long long s3 : 16;
|
||||
} flags;
|
||||
|
||||
int i = 33;
|
||||
|
||||
int main ()
|
||||
{
|
||||
return flags.u1 + i;
|
||||
}
|
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c
Normal file
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* The bool bitfield type. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*cts_bits" 2 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"_Bool.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct open_file {
|
||||
bool mmapped:1;
|
||||
bool released:1;
|
||||
} of;
|
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c
Normal file
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* The zero sized bitfield.
|
||||
|
||||
In this testcase, two slices are expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 2 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cts_bits" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xa\[\t \]+\[^\n\]*cts_bits" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ctm_name" 2 } } */
|
||||
struct foo
|
||||
{
|
||||
int a:5;
|
||||
unsigned:0;
|
||||
int b:10;
|
||||
} foome;
|
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c
Normal file
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* Tests for CTF complex base types.
|
||||
|
||||
CTF does not have representation for complex integer types.
|
||||
|
||||
This testcase has a mix of C constructs containing COMPLEX_TYPE. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-require-effective-target libc_has_complex_functions } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"complex double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"complex long double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"complex float.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
double complex z1 = I * I;
|
||||
|
||||
const long double complex z2 = I * I;
|
||||
|
||||
float complex z4 = 1+2.11*I;
|
65
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c
Normal file
65
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Test compilation of stubs with various qualifiers - const, restrict and
|
||||
volatile.
|
||||
|
||||
Testcase includes a std header to allow testing of shared types across
|
||||
files. Only one CTF record for int is expected.
|
||||
|
||||
CTF records for CVR qualifiers are no-name records. In this testcase, there
|
||||
are 5 qualifiers across constructs. 2 more no-name CTF records correspond to
|
||||
CTF pointer records.
|
||||
|
||||
TYPEID: name string (size) -> ref TYPEID : ref name string (size) -> ...
|
||||
|
||||
Types:
|
||||
1: long int (size 0x8)
|
||||
2: long unsigned int (size 0x8)
|
||||
3: size_t (size 0x8) -> 2: long unsigned int (size 0x8)
|
||||
4: int (size 0x4)
|
||||
5: const int (size 0x4) -> 4: int (size 0x4)
|
||||
6: volatile const int (size 0x4) -> 5: const int (size 0x4) -> 4: int (size 0x4)
|
||||
7: long long int (size 0x8)
|
||||
8: long double (size 0x10)
|
||||
9: int * (size 0x8) -> 4: int (size 0x4)
|
||||
a: int *restrict (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
|
||||
b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
|
||||
c: const int *restrict (size 0x8) -> b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
|
||||
d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
|
||||
e: const INTP (size 0x8) -> d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
|
||||
f: void (size 0x0)
|
||||
10: void (*) (size_t, int *restrict, const int *restrict) (size 0x0)
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 7 } } */
|
||||
|
||||
/* type id 9, b have POINTER type. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
/* type id 5, e have CONST qualifier. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
/* type id a, c have RESTRICT qualifier. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x36000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
/* type id 6 has VOLATILE qualifier. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2e000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
const volatile int a = 5;
|
||||
int *restrict b;
|
||||
|
||||
const int * i;
|
||||
int const * j;
|
||||
|
||||
typedef int * INTP;
|
||||
const INTP int_p;
|
||||
|
||||
void foo (size_t n, int *restrict p, const int *restrict q)
|
||||
{
|
||||
while (n-- > 0)
|
||||
*p++ = *q++;
|
||||
}
|
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c
Normal file
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Test compilation of stubs with various expressions involving const
|
||||
qualifier.
|
||||
|
||||
In this testcase, a single CTF record for const int is expected. A total of
|
||||
two const qualifier CTF records are expected (const int and const struct
|
||||
s1). */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
struct mystruct
|
||||
{
|
||||
struct
|
||||
{
|
||||
int a;
|
||||
const int b;
|
||||
} s1;
|
||||
char * name;
|
||||
} my_a;
|
||||
|
||||
struct s1
|
||||
{
|
||||
int i;
|
||||
const int ci;
|
||||
} s;
|
||||
|
||||
const struct s1 cs;
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Test compilation of stubs with various expressions involving const and
|
||||
volatile qualifiers.
|
||||
|
||||
In this testcase, it is expected to have const and volatile CTF
|
||||
records. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2e000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 3 } } */
|
||||
/* Two arrays. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
|
||||
const volatile unsigned char vicar = 11;
|
||||
|
||||
const volatile unsigned char * vicarage = &vicar;
|
||||
|
||||
volatile float vilify[2];
|
||||
|
||||
const volatile char victor = 'Y';
|
||||
|
||||
const volatile char vindictive[2];
|
23
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c
Normal file
23
gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Test compilation of stubs with various qualifiers - const, restrict and
|
||||
volatile.
|
||||
|
||||
CTF records for CVR qualifiers are no-name records. In this testcase, there
|
||||
is 1 const qualifier. 1 more no-name CTF record corresponds to the CTF
|
||||
pointer record. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
typedef const struct howto_struct howto_type;
|
||||
|
||||
typedef struct entry
|
||||
{
|
||||
int addend;
|
||||
howto_type *howto;
|
||||
} how_ent;
|
||||
|
||||
how_ent hent;
|
7
gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c
Normal file
7
gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* Verify that CTF debug info can co-exist with dwarf. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf -gdwarf -dA" } */
|
||||
/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
|
||||
|
||||
void func (void)
|
||||
{ }
|
7
gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c
Normal file
7
gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* Verify that CTF debug info can co-exist with dwarf. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gdwarf -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
|
||||
|
||||
void func (void)
|
||||
{ }
|
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c
Normal file
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* CTF generation for enums. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"RED.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"GREEN.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"BLUE.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"YELLOW.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "cte_value" 4} } */
|
||||
|
||||
|
||||
enum foo_color
|
||||
{
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
YELLOW
|
||||
};
|
||||
|
||||
enum foo_color my_color;
|
27
gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c
Normal file
27
gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* CTF generation for enums.
|
||||
|
||||
CTF represents enum values with an int32_t. For enum values not
|
||||
representable with int32_t data type, the compiler skips adding CTF for
|
||||
them. This will be fixed soon in the CTF format.
|
||||
TBD_CTF_REPRESENTATION_LIMIT.
|
||||
|
||||
In this testcase, CTF for enumerator GFS_MONOTONIC will not be generated. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"GFS_MONOTONIC.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"GFS_RUNTIME.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"GFS_STATIC.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "cte_value" 2} } */
|
||||
|
||||
|
||||
enum gomp_schedule_type
|
||||
{
|
||||
GFS_RUNTIME,
|
||||
GFS_STATIC,
|
||||
GFS_MONOTONIC = 0x80000000U
|
||||
};
|
||||
|
||||
enum gomp_schedule_type gsch_type;
|
||||
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* CTF is not generated for entities not at file-scope. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"SFOO.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"gfoo.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
int foo (int n)
|
||||
{
|
||||
typedef struct { int a[n]; } SFOO;
|
||||
|
||||
SFOO a;
|
||||
__attribute__ ((noinline)) SFOO gfoo (void) { return a; }
|
||||
|
||||
a.a[0] = 1;
|
||||
a.a[9] = 2;
|
||||
|
||||
SFOO b;
|
||||
b = gfoo ();
|
||||
|
||||
return b.a[0] == 1 && b.a[9] == 2;
|
||||
}
|
||||
|
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c
Normal file
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* Tests for CTF float base types.
|
||||
- Verify that there is a single record for the base types. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"float.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"long double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
float a;
|
||||
float b = 33;
|
||||
|
||||
double c = 44;
|
||||
double d = 45;
|
||||
|
||||
long double e;
|
40
gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c
Normal file
40
gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* CTF forward type is generated for forward declarations of types in C.
|
||||
|
||||
Check that the ctf-kind of CTF_K_FOWARD type is CTF_K_STRUCT or CTF_K_UNION.
|
||||
For forward types, the compiler encodes the CTF kind in the ctt_type field.
|
||||
CTF_K_FORWARD is used as the CTF type as usual in the ctt_info. */
|
||||
|
||||
/* Note - A value of 6 in "ctt_size or ctt_type" appears twice in this
|
||||
testcase. This might be misconstrued as 2 CTK_K_FORWARD records of struct
|
||||
type. The second assembler tag is due to a ref type in a CVR CTF record.
|
||||
TBD - perhaps a more robust string pattern is needed. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x26000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*ctt_size or ctt_type" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x7\[\t \]+\[^\n\]*ctt_size or ctt_type" 2 } } */
|
||||
|
||||
typedef struct __locale_struct
|
||||
{
|
||||
struct __locale_data *__locales[13]; /* forward struct type. */
|
||||
|
||||
const int *__ctype_toupper;
|
||||
const char *__names[13];
|
||||
} *__locale_t;
|
||||
|
||||
typedef __locale_t locale_t;
|
||||
|
||||
locale_t loc;
|
||||
|
||||
typedef struct __inter_struct
|
||||
{
|
||||
union __inter_data * __inters[13]; /* forward union type. */
|
||||
|
||||
const int * __ctype_kind;
|
||||
} * __inter_t;
|
||||
|
||||
typedef __inter_t inter_t;
|
||||
|
||||
inter_t inter;
|
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c
Normal file
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* CTF forward type is generated for forward declarations of enum types in C.
|
||||
|
||||
Check that the ctf-kind of CTF_K_FOWARD type is CTF_K_ENUM.
|
||||
For forward types, the compiler encodes the CTF kind in the ctt_type field.
|
||||
CTF_K_FORWARD is used as the CTF type as usual in the ctt_info. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x26000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*ctt_size or ctt_type" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"vibgyor.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
enum vibgyor;
|
||||
|
||||
char * (*get_color_name) (enum vibgyor);
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* CTF function index sub-section.
|
||||
|
||||
A function index sub-section in the CTF section contains the offset to the
|
||||
string name of the global function symbols. The number of entries in the
|
||||
func info section and the func index section are always the same.
|
||||
|
||||
In this testcase, 2 records in the function index section are expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "funcinfo_name" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "funcinfo_func_type" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
int foo (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bar (int a)
|
||||
{
|
||||
return 33 + a;
|
||||
}
|
24
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c
Normal file
24
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* CTF generation of function pointers. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"__foo_fn.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"destroy.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"func.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
int (*func) (int *, char);
|
||||
|
||||
typedef int (*__foo_fn) (void *__cookie, char *__buf, int __nbytes);
|
||||
|
||||
typedef struct object
|
||||
{
|
||||
int myint;
|
||||
char mychar;
|
||||
void (*destroy)(struct object *);
|
||||
} object_t;
|
||||
|
||||
object_t myobj;
|
||||
__foo_fn fooit;
|
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c
Normal file
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* CTF generation of function pointers.
|
||||
|
||||
In this testcase, there is a single function type expected for two
|
||||
different function pointer types. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"rcu_callback_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"func.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
struct callback_head {
|
||||
struct callback_head *next;
|
||||
void (*func) (struct callback_head *head);
|
||||
} __attribute__ (( aligned (sizeof (void *))));
|
||||
#define rcu_head callback_head
|
||||
|
||||
struct callback_head chead;
|
||||
|
||||
typedef void (*rcu_callback_t) (struct rcu_head *head);
|
||||
|
||||
rcu_callback_t rcb;
|
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c
Normal file
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* CTF generation of function pointers.
|
||||
|
||||
In this testcase, there is a single function type expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_init_callback.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"fn.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
struct foo;
|
||||
|
||||
typedef void (* foo_init_callback) (struct foo *f1);
|
||||
|
||||
struct foo
|
||||
{
|
||||
/* Function to call to initialize. */
|
||||
foo_init_callback fn;
|
||||
};
|
||||
|
||||
struct foo f;
|
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c
Normal file
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* CTF generation of function pointers.
|
||||
|
||||
In this testcase, Type de-duplication of function type is exercised. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"var_assign_func_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
struct variable;
|
||||
|
||||
typedef struct variable *var_assign_func_t (struct variable *);
|
||||
|
||||
typedef struct variable {
|
||||
var_assign_func_t *assign_func;
|
||||
} shell_var_t;
|
||||
|
||||
shell_var_t a;
|
34
gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c
Normal file
34
gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* CTF generation for functions with varargs or otherwise.
|
||||
|
||||
In this testcase, it is expected to see one CTF_K_FUNCTION record with two
|
||||
function arguments. The second function argument with a value of 0
|
||||
corresponds to the ellipsis.
|
||||
|
||||
Example CTF section excerpt on x86_64 :
|
||||
|
||||
.long 0x5 # ctt_name (name = format)
|
||||
.long 0x16000002 # ctt_info (CTF_K_FUNCTION with 2 arguments)
|
||||
.long 0x2 # ctt_size or ctt_type (return typeID)
|
||||
.long 0x2 # dtu_argv (TypeID of the First argument)
|
||||
.long 0 # dtu_argv (TypeID of the second argument)
|
||||
.ascii "\0" # ctf_string
|
||||
.ascii "int\0" # ctf_string
|
||||
.ascii "format\0" # ctf_string
|
||||
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x16000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "dtu_argv" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*dtu_argv" 1 } } */
|
||||
|
||||
int foo (void);
|
||||
|
||||
int bar (int);
|
||||
|
||||
int * format (int * fmt, ...)
|
||||
{
|
||||
return fmt;
|
||||
}
|
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c
Normal file
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Tests for CTF integer base types.
|
||||
- Verify that there is a single record for the base types. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"short int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"long int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
int a;
|
||||
int b = 33;
|
||||
|
||||
short int c = 44;
|
||||
short int d = 45;
|
||||
|
||||
long int e = 90;
|
||||
long int f;
|
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c
Normal file
30
gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* CTF objext index sub-section.
|
||||
|
||||
An object index sub-section in the CTF section contains the offset to the
|
||||
string name of the global object symbols. The number of entries in the
|
||||
obj info section and objt index section are always the same.
|
||||
|
||||
In this testcase, 4 records in the object index section are expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "objtinfo_name" 4 } } */
|
||||
/* { dg-final { scan-assembler-times "objtinfo_var_type" 4 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"a.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"b.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"a1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"d_instance.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
static int b = 33;
|
||||
|
||||
int a = 44;
|
||||
int a1[2] = {22, 33};
|
||||
|
||||
struct d
|
||||
{
|
||||
int d1;
|
||||
int d2;
|
||||
};
|
||||
|
||||
struct d d_instance;
|
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c
Normal file
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* CTF generation for pointer types.
|
||||
|
||||
In this testcase, two CTF pointer type records are expected
|
||||
- int *
|
||||
- struct foo_struct *
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_struct.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
|
||||
|
||||
int b = 44;
|
||||
int * a = &b;
|
||||
|
||||
struct foo_struct
|
||||
{
|
||||
int bar_mem_1;
|
||||
int bar_mem_2;
|
||||
float d;
|
||||
struct foo_struct *next;
|
||||
};
|
||||
|
||||
struct foo_struct * node;
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* CTF generation for pointer types.
|
||||
|
||||
In this testcase, de-duplication of pointer types is exercised. The
|
||||
compostition of structs in this testcase is such that when adding CTF for
|
||||
pointer type (link), the pointed-to-type type already adds the pointer to
|
||||
struct link.
|
||||
|
||||
In this testcase, one CTF pointer type record is expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
struct link;
|
||||
|
||||
typedef struct items {
|
||||
struct link * link;
|
||||
int str;
|
||||
} itemslist;
|
||||
|
||||
itemslist il;
|
||||
|
||||
struct link { struct link * next; };
|
||||
|
11
gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c
Normal file
11
gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Verify the CTF preamble in the CTF section. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
|
||||
/* { dg-final { scan-assembler "0x4.*CTF preamble version" } } */
|
||||
/* { dg-final { scan-assembler "0.*CTF preamble flags" } } */
|
||||
|
||||
void func (void)
|
||||
{
|
||||
}
|
38
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c
Normal file
38
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
An explicit CTF type with kind CTF_K_UNKNOWN is created for types that do
|
||||
not have representation in CTF. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"unknown.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
/* { dg-require-effective-target libc_has_complex_functions } */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
|
||||
La_x86_64_xmm a1;
|
||||
|
||||
/* GCC also supports complex integer data types. */
|
||||
complex char a;
|
||||
complex signed char b;
|
||||
complex unsigned char c;
|
||||
complex short int d;
|
||||
complex short unsigned int e;
|
||||
complex int f;
|
||||
complex unsigned int g;
|
||||
complex long int h;
|
||||
complex long unsigned int i;
|
||||
complex long long int j;
|
||||
|
||||
enum gomp_schedule_type
|
||||
{
|
||||
GFS_RUNTIME,
|
||||
GFS_STATIC,
|
||||
GFS_MONOTONIC = 0x80000000U
|
||||
};
|
||||
|
||||
enum gomp_schedule_type gsch_type;
|
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c
Normal file
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip IEEE interchange and extended formats for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for IEEE interchange and extended formats.
|
||||
|
||||
CTF records for variables do exist, however. The referenced type is
|
||||
CTF_TYPE_NULLID. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
/* { dg-require-effective-target float16 } */
|
||||
|
||||
_Float16 f16;
|
20
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c
Normal file
20
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip IEEE interchange and extended formats for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for IEEE interchange and extended formats.
|
||||
|
||||
CTF records for variables and pointer do exist, however. The referenced
|
||||
type is CTF_TYPE_NULLID. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
/* { dg-require-effective-target float32 } */
|
||||
/* { dg-require-effective-target float32x } */
|
||||
|
||||
_Float32 f32;
|
||||
_Float32x f32x;
|
||||
_Float32 * f32p;
|
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c
Normal file
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip IEEE interchange and extended formats for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for IEEE interchange and extended formats.
|
||||
|
||||
CTF records for variables and pointer do exist, however. The referenced
|
||||
type is CTF_TYPE_NULLID. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
/* { dg-require-effective-target float64 } */
|
||||
/* { dg-require-effective-target float64x } */
|
||||
|
||||
_Float64 f64;
|
||||
_Float64x f64x;
|
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c
Normal file
19
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip IEEE interchange and extended formats for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for IEEE interchange and extended formats.
|
||||
|
||||
CTF records for variables and pointer do exist, however. The referenced
|
||||
type is CTF_TYPE_NULLID. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
|
||||
/* { dg-require-effective-target float128 } */
|
||||
/* { dg-require-effective-target float128x } */
|
||||
|
||||
_Float128 f128;
|
||||
_Float128x f128x;
|
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c
Normal file
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip Decimal Floating Point format types for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for Decimal floating point format.
|
||||
|
||||
CTF records for variables do exist, however. The referenced type is
|
||||
CTF_TYPE_NULLID. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf" } */
|
||||
/* { dg-require-effective-target dfp } */
|
||||
|
||||
_Decimal32 d32;
|
||||
_Decimal64 d64;
|
||||
_Decimal128 d128;
|
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c
Normal file
18
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* CTF does not have representation for some types at this time. These types
|
||||
are skipped in the CTF generation phase in the compiler.
|
||||
|
||||
Skip IEEE interchange and extended formats for CTF generation.
|
||||
|
||||
In this testcase, CTF records for types are not added as CTF has no
|
||||
representation for IEEE interchange and extended formats. This testcase
|
||||
checks that CTF generation skips the 128-bit float gracefully, when code
|
||||
generation is for a 32-bit environment. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-gctf -m32" } */
|
||||
|
||||
/* { dg-require-effective-target float128 } */
|
||||
/* { dg-require-effective-target float128x } */
|
||||
|
||||
_Float128 f128;
|
||||
_Float128x f128x;
|
27
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c
Normal file
27
gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* CTF does not have representation for _Atomic qualifier. This qualifier is
|
||||
skipped in the CTF generation phase in the compiler.
|
||||
|
||||
In this testcase, CTF records for the _Atomic qualifier are not added as
|
||||
CTF has no representation for it. CTF records for the underlying type are,
|
||||
however, added. So, CTF records for typedef, const and the underlying
|
||||
struct are expected. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1a000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ctm_name" 3 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"comp_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"comp_type_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"c1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
typedef struct comp_type
|
||||
{
|
||||
int a;
|
||||
float b;
|
||||
char c;
|
||||
} comp_type_t;
|
||||
|
||||
_Atomic const comp_type_t c1;
|
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c
Normal file
26
gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* CTF String Table as generated by the compiler is expected to have only a
|
||||
single empty string. Just an optimization by the compiler, it is not
|
||||
mandated by the CTF format. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "ascii \".0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
union wait
|
||||
{
|
||||
int w_status;
|
||||
struct
|
||||
{
|
||||
int __w_termsig;
|
||||
int __w_coredump;
|
||||
} __wait_terminated;
|
||||
struct
|
||||
{
|
||||
int __w_stopval;
|
||||
int __w_stopsig;
|
||||
} __wait_stopped;
|
||||
};
|
||||
|
||||
typedef union { union wait * __uptr; int * iptr; } __WAIT_STATUS;
|
||||
|
||||
__WAIT_STATUS waitstatus;
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Test compilation of struct type.
|
||||
|
||||
In this testcase, two CTF_K_STRUCT records are expected
|
||||
struct a : ctt_info = 0x1a000004 (4 field members)
|
||||
struct b : ctt_into = 0x1a000002 (2 field members)
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1a000004\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1a000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ctm_name" 6 } } */
|
||||
|
||||
struct a
|
||||
{
|
||||
int d1;
|
||||
int d2;
|
||||
float c;
|
||||
struct b
|
||||
{
|
||||
int time;
|
||||
int wall;
|
||||
} b1;
|
||||
} my_a;
|
32
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c
Normal file
32
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Test for compilation of self-referntial structs.
|
||||
|
||||
Further, the compiler is expected to generate a single CTF struct type for
|
||||
struct dmx_dtdef (due to Type de-duplication at CTF generation). */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"dmx_dtdef.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"dtd_name.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"dtd_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"dmx_dtdef_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
struct link
|
||||
{
|
||||
struct link * next;
|
||||
} * s_link;
|
||||
|
||||
typedef long dmx_id_t;
|
||||
|
||||
typedef struct dmx_dtdef
|
||||
{
|
||||
char * dtd_name;
|
||||
dmx_id_t dtd_type;
|
||||
} dmx_dtdef_t;
|
||||
|
||||
typedef struct dmx_bundle
|
||||
{
|
||||
dmx_id_t dmb_type;
|
||||
dmx_dtdef_t * dmb_dtd;
|
||||
} dmx_bundle_t;
|
||||
|
||||
dmx_bundle_t dbt;
|
65
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c
Normal file
65
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Test Compilation of mixed constructs containing structs and arrays.
|
||||
|
||||
Further, the compiler is expected to generate a single CTF struct type for
|
||||
struct cmodel (due to Type de-duplication at the time of CTF generation).
|
||||
|
||||
const qualifier in fields of structs should be processed. It appears as a
|
||||
no-name CTF record with appropriate ctt_info. In this testcase, there are
|
||||
two const qualifiers - const char and const struct cmodel. However, due to
|
||||
way the debug information is represented in DWARF die, 3 const qualifier
|
||||
records appear in the CTF section.
|
||||
|
||||
<1><e1>: Abbrev Number: 14 (DW_TAG_typedef)
|
||||
<e2> DW_AT_name : (indirect string, offset: 0x114): cmodel_t
|
||||
<e9> DW_AT_type : <0x9a>
|
||||
<1><ed>: Abbrev Number: 13 (DW_TAG_const_type)
|
||||
<ee> DW_AT_type : <0xe1>
|
||||
<1><f2>: Abbrev Number: 4 (DW_TAG_array_type)
|
||||
<f3> DW_AT_type : <0xed>
|
||||
<f7> DW_AT_sibling : <0x102>
|
||||
|
||||
<2><101>: Abbrev Number: 0
|
||||
<1><102>: Abbrev Number: 13 (DW_TAG_const_type)
|
||||
<103> DW_AT_type : <0xf2>
|
||||
<1><107>: Abbrev Number: 15 (DW_TAG_variable)
|
||||
<108> DW_AT_name : (indirect string, offset: 0x57): _models
|
||||
<10f> DW_AT_type : <0x102>
|
||||
<1><11d>: Abbrev Number: 0
|
||||
|
||||
This results in:
|
||||
|
||||
_models -> e: const const cmodel_t [3] (size 0x30) -> d: const cmodel_t [3] (size 0x30)
|
||||
|
||||
Deemed as acceptable for now. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ascii \"cmodel.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"cname.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"cpointer.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"cmodel_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
/* 3 const records are expected. */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 3 } } */
|
||||
|
||||
struct a
|
||||
{
|
||||
int a1[2];
|
||||
struct { int b[3]; } a2;
|
||||
};
|
||||
|
||||
struct a my_a;
|
||||
|
||||
typedef struct cmodel
|
||||
{
|
||||
const char *cname;
|
||||
int ccode;
|
||||
int cpointer;
|
||||
} cmodel_t;
|
||||
|
||||
static const cmodel_t _models[] = {
|
||||
{"ILP32", 0, 4},
|
||||
{"LP64", 0, 8},
|
||||
{"", 0, 0}
|
||||
};
|
15
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c
Normal file
15
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* CTF generation for struct type in presence of DWARF2.
|
||||
|
||||
In case of DWARF2, the data member location is an expression containing
|
||||
the location. CTF generation feeds off DWARF dies; this testcase tests
|
||||
that the location expr is handled. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA -gdwarf-2" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*cta_nelems" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctm_offset" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*ctm_offset" 1 } } */
|
||||
|
||||
static struct ranges {int from, to;} lim_regs[] = {{ 16, 7}, { 16, 6}, { 20, 7},{ 20, 6}};
|
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c
Normal file
21
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* This tests the following scenario:
|
||||
|
||||
1. struct foo;
|
||||
2. struct foo *a_foo;
|
||||
3. struct foo { int bar; };
|
||||
4. void baz (struct foo *f) { f->bar = 0; }
|
||||
|
||||
At 2. a forward for struct foo is generated and at 3. the struct
|
||||
type is fully defined. When a pointer to foo is encountered at 4.,
|
||||
an additional CTF type for the completed struct shall be emitted as
|
||||
well. The linker will deduplicate both types. */
|
||||
|
||||
struct foo;
|
||||
struct foo *a_foo;
|
||||
struct foo { int bar; };
|
||||
void baz (struct foo *f) { f->bar = 0; }
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]\"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c
Normal file
22
gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* This tests the following scenario:
|
||||
|
||||
1. struct foo;
|
||||
2. struct foo *a_foo;
|
||||
3. struct foo { int bar; };
|
||||
4. void baz (struct foo **f) { f->bar = 0; }
|
||||
|
||||
At 2. a forward for struct foo is generated and at 3. the struct
|
||||
type is fully defined. When a pointer to a pointer to foo is
|
||||
encountered at 4., an additional CTF type for the completed struct
|
||||
shall be emitted as well. The linker will deduplicate both
|
||||
types. */
|
||||
|
||||
struct foo;
|
||||
struct foo *a_foo;
|
||||
struct foo { int bar; };
|
||||
void baz (struct foo **f) { (*f)->bar = 0; }
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]\"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
68
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c
Normal file
68
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* CTF_K_TYPEDEF record generation.
|
||||
|
||||
In this testcase, 7 typedef records are expected.
|
||||
|
||||
Further, the declared variables must be of type typedef
|
||||
|
||||
Variables:
|
||||
a -> 2: my_int (size 0x4) -> 1: int (size 0x4)
|
||||
b -> 3: bar_int (size 0x4) -> 1: int (size 0x4)
|
||||
c -> 4: foo_int (size 0x4) -> 1: int (size 0x4)
|
||||
d -> 7: my_array (size 0x8) -> 5: struct (size 0x8)
|
||||
e -> 9: CINT (size 0x4) -> 8: const int (size 0x4) -> 1: int (size 0x4)
|
||||
f -> c: CINTP (size 0x8) -> b: const int * (size 0x8) -> a: const int (size 0x4) -> 1: int (size 0x4)
|
||||
g -> f: my_node_t (size 0x8) -> d: struct my_node (size 0x8)
|
||||
|
||||
There is no direct way to check that the variables are of type typedef.
|
||||
So in this testcase, we simply check that:
|
||||
1. The typedef records are generated (Check for 7 specific ctt_info, and
|
||||
check for the ascii strings for the typedef names).
|
||||
2. The ctv_typeidx are distinct (each pointing to a specfic unique type).
|
||||
Note that if variables were not of type typedef, ctv_typeidx will not be
|
||||
unique (type of a, b, c will all point to int); hence, the check.
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 7 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"my_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"bar_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"my_array.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"CINT.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"CINTP.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"my_node_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x9\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xa\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xc\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
|
||||
typedef int my_int;
|
||||
typedef int bar_int;
|
||||
typedef int foo_int;
|
||||
|
||||
typedef struct { int a[2]; } my_array;
|
||||
|
||||
typedef const int CINT;
|
||||
typedef const int * CINTP;
|
||||
|
||||
typedef struct my_node
|
||||
{
|
||||
int flags;
|
||||
char value;
|
||||
} my_node_t;
|
||||
|
||||
my_int a;
|
||||
bar_int b;
|
||||
foo_int c;
|
||||
|
||||
my_array d;
|
||||
CINT e = 3;
|
||||
CINTP f = &e;
|
||||
|
||||
my_node_t g;
|
20
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c
Normal file
20
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* CTF_K_TYPEDEF record generation.
|
||||
|
||||
In this testcase, typedef of type void should be generated. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_void_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"void.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
typedef void foo_void_type;
|
||||
|
||||
struct bar
|
||||
{
|
||||
int a;
|
||||
foo_void_type *b;
|
||||
};
|
||||
|
||||
struct bar c;
|
24
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c
Normal file
24
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Type de-duplication of CTF_K_TYPEDEF records.
|
||||
|
||||
In this testcase, a single CTF record for typedef is expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
|
||||
|
||||
typedef struct foo foo_type;
|
||||
|
||||
struct bar
|
||||
{
|
||||
struct foo * f1;
|
||||
foo_type * f2;
|
||||
};
|
||||
|
||||
struct testme {
|
||||
struct bar * b1;
|
||||
};
|
||||
|
||||
struct testme * t1;
|
14
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c
Normal file
14
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
typedef struct my_int
|
||||
{
|
||||
int upper;
|
||||
int lower;
|
||||
struct bitmask
|
||||
{
|
||||
int flags;
|
||||
} my_mask;
|
||||
} my_int_t;
|
||||
|
||||
my_int_t mit;
|
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c
Normal file
17
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Test compilation of typedef composition in structs. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int day, month, year;
|
||||
} Date;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Date filedDate, fixedDate;
|
||||
int severity;
|
||||
} BugRef;
|
||||
|
||||
BugRef CR2112;
|
32
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c
Normal file
32
gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Test CTF generation for a typedef instantiation with CVR quals.
|
||||
|
||||
Caveat: There is no direct way to test that the type of foo is
|
||||
"const my_int_t" via scanning the assembly. This test instead
|
||||
checks for the presence of some of the CTF constructs involved
|
||||
individually. Specifically, it checks for CTF const record and
|
||||
CTF typedef record.
|
||||
|
||||
Variables:
|
||||
foo -> 4: const my_int_t (size 0x8) -> 3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
|
||||
|
||||
Types:
|
||||
1: struct my_int (size 0x8)
|
||||
2: int (size 0x4)
|
||||
3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
|
||||
4: const my_int_t (size 0x8) -> 3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
|
||||
*/
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
|
||||
typedef struct my_int
|
||||
{
|
||||
int upper;
|
||||
int lower;
|
||||
} my_int_t;
|
||||
|
||||
const my_int_t foo = {10, 20};
|
14
gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c
Normal file
14
gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* CTF generation for union type. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
/* { dg-final { scan-assembler-times "\[\t \]0x1e000004\[\t \]+\[^\n\]*ctt_info" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "ctm_name" 4 } } */
|
||||
|
||||
union c
|
||||
{
|
||||
int c1;
|
||||
int c2;
|
||||
int c3;
|
||||
int c4;
|
||||
} my_u_c;
|
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c
Normal file
25
gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* CTF generation for global variables.
|
||||
|
||||
In this testcase, 7 records in the variable info section are expected. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ctv_name" 7 } } */
|
||||
|
||||
float var1;
|
||||
double var2;
|
||||
long double var3;
|
||||
|
||||
char ascii = 'a';
|
||||
|
||||
int a = 33;
|
||||
int a1[2] = {22, 33};
|
||||
|
||||
struct d
|
||||
{
|
||||
int d1;
|
||||
int d2;
|
||||
};
|
||||
|
||||
struct d d_instance;
|
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c
Normal file
16
gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* CTF generation for static variables inside a function.
|
||||
|
||||
In this testcase, CTF record for bstatic is NOT expected. CTF generation
|
||||
is only carried out for variables at file-scope or global-scope. */
|
||||
|
||||
/* { dg-do compile ) */
|
||||
/* { dg-options "-O0 -gctf -dA" } */
|
||||
|
||||
/* { dg-final { scan-assembler-times "ctv_name" 0 } } */
|
||||
/* { dg-final { scan-assembler-times "ascii \"bstatic.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
|
||||
|
||||
int foo (int a)
|
||||
{
|
||||
static int bstatic = 3;
|
||||
return a + bstatic;
|
||||
}
|
41
gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
Normal file
41
gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GCC; see the file COPYING3. If not see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
# GCC testsuite that uses the `dg.exp' driver.
|
||||
|
||||
# Load support procs.
|
||||
load_lib gcc-dg.exp
|
||||
|
||||
# Disable on ptx (in sync with DWARF testsuite)
|
||||
if { [istarget nvptx-*-*] } {
|
||||
return
|
||||
}
|
||||
|
||||
# If a testcase doesn't have special options, use these.
|
||||
global DEFAULT_CFLAGS
|
||||
if ![info exists DEFAULT_CFLAGS] then {
|
||||
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
|
||||
}
|
||||
|
||||
# Initialize `dg'.
|
||||
dg-init
|
||||
|
||||
# Main loop.
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
|
||||
"" $DEFAULT_CFLAGS
|
||||
|
||||
# All done.
|
||||
dg-finish
|
|
@ -621,6 +621,22 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } {
|
|||
}
|
||||
}
|
||||
|
||||
# Check if frontend has CTF support
|
||||
proc gcc-dg-frontend-supports-ctf { target_compile trivial } {
|
||||
global srcdir subdir
|
||||
|
||||
set comp_output [$target_compile \
|
||||
"$srcdir/$subdir/$trivial" "trivial.S" assembly \
|
||||
"additional_flags=-gctf"]
|
||||
if { ! [string match \
|
||||
"*CTF debug info requested, but not supported for * frontend*" \
|
||||
$comp_output] } {
|
||||
remove-build-file "trivial.S"
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check if the target system supports the debug format
|
||||
proc gcc-dg-target-supports-debug-format { target_compile trivial type } {
|
||||
global srcdir subdir
|
||||
|
@ -639,21 +655,30 @@ proc gcc-dg-target-supports-debug-format { target_compile trivial type } {
|
|||
proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
|
||||
if ![info exists DEBUG_TORTURE_OPTIONS] {
|
||||
set DEBUG_TORTURE_OPTIONS ""
|
||||
foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+} {
|
||||
if [expr [gcc-dg-target-supports-debug-format \
|
||||
$target_compile $trivial $type]] {
|
||||
foreach level {1 "" 3} {
|
||||
if { ($type == "-gdwarf-2") && ($level != "") } {
|
||||
lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
|
||||
foreach opt $opt_opts {
|
||||
lappend DEBUG_TORTURE_OPTIONS \
|
||||
[list "${type}" "-g${level}" "$opt" ]
|
||||
}
|
||||
} else {
|
||||
lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
|
||||
foreach opt $opt_opts {
|
||||
lappend DEBUG_TORTURE_OPTIONS \
|
||||
[list "${type}${level}" "$opt" ]
|
||||
foreach type {-gctf -gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+} {
|
||||
if { $type == "-gctf" } {
|
||||
if [expr [gcc-dg-frontend-supports-ctf \
|
||||
$target_compile $trivial]] {
|
||||
# At this time, running tests with various opt levels or
|
||||
# ctf debug info levels does not add value.
|
||||
lappend DEBUG_TORTURE_OPTIONS [list "${type}"]
|
||||
}
|
||||
} else {
|
||||
if [expr [gcc-dg-target-supports-debug-format \
|
||||
$target_compile $trivial $type]] {
|
||||
foreach level {1 "" 3} {
|
||||
if { ($type == "-gdwarf-2") && ($level != "") } {
|
||||
lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
|
||||
foreach opt $opt_opts {
|
||||
lappend DEBUG_TORTURE_OPTIONS \
|
||||
[list "${type}" "-g${level}" "$opt" ]
|
||||
}
|
||||
} else {
|
||||
lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
|
||||
foreach opt $opt_opts {
|
||||
lappend DEBUG_TORTURE_OPTIONS \
|
||||
[list "${type}${level}" "$opt" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -698,6 +723,15 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
|
|||
set doit 0
|
||||
}
|
||||
|
||||
# These tests check for information which is not emitted for CTF
|
||||
# as CTF type information is emitted for entities at file and
|
||||
# global scope only.
|
||||
if { ([string match {*/debug-[126].c} "$nshort"] \
|
||||
|| [string match {*/enum-[12].C} "$nshort"] ) \
|
||||
&& [string match "*ctf*" "$flags"] } {
|
||||
set doit 0
|
||||
}
|
||||
|
||||
if { $doit } {
|
||||
verbose -log "Testing $nshort, $flags" 1
|
||||
dg-test $test $flags ""
|
||||
|
|
Loading…
Add table
Reference in a new issue