* [PATCH] btf: improve btf-datasec-3.c test [PR 114642]
@ 2024-04-08 21:01 David Faust
2024-04-09 18:05 ` Indu Bhagat
0 siblings, 1 reply; 2+ messages in thread
From: David Faust @ 2024-04-08 21:01 UTC (permalink / raw)
To: gcc-patches
This test failed on powerpc --target_board=unix'{-m32}' because two
variables were not placed in sections where the test silently (and
incorrectly) assumed they would be.
The important thing for the test is only that BTF_KIND_DATASEC entries
are NOT generated for the extern variable declarations without an
explicit section attribute. Make the test more robust by placing the
non-extern variables in explicit sections, and invert the checks to
more accurately verify what we care about in this test.
Tested on x86_64-linux-gnu and x86_64-linux-gnu host for
powerpc64-linux-gnu and bpf-unkown-none targets.
OK?
gcc/testsuite/
PR testsuite/114642
* gcc.dg/debug/btf/btf-datasec-3.c: Make test more robust on different
architectures.
---
gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
index 297340cabfa..6b127aa14da 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
@@ -7,22 +7,22 @@
extern int VERSION __attribute__((section (".version")));
-extern int test_bss1;
-extern int test_data1;
+extern int ext1;
+extern int ext2;
-int test_bss2;
-int test_data2 = 2;
+int var1 __attribute__((section (".sec_a")));
+int var2 __attribute__((section (".sec_b"))) = 2;
int
foo (void)
{
- test_bss2 = VERSION;
- return test_bss1 + test_data1 + test_data2;
+ ext2 = VERSION;
+ return ext1 + var1 + var2;
}
/* There should be 3 DATASEC entries total. Of the extern decls, only VERSION
has a known section; entries are not created for the other two. */
/* { dg-final { scan-assembler-times "bts_type" 3 } } */
-/* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'test_data2'\\)" 1 } } */
-/* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'test_bss2'\\)" 1 } } */
/* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'VERSION'\\)" 1 } } */
+/* { dg-final { scan-assembler-not "bts_type: \\(BTF_KIND_VAR 'ext1'\\)" } } */
+/* { dg-final { scan-assembler-not "bts_type: \\(BTF_KIND_VAR 'ext2'\\)" } } */
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] btf: improve btf-datasec-3.c test [PR 114642]
2024-04-08 21:01 [PATCH] btf: improve btf-datasec-3.c test [PR 114642] David Faust
@ 2024-04-09 18:05 ` Indu Bhagat
0 siblings, 0 replies; 2+ messages in thread
From: Indu Bhagat @ 2024-04-09 18:05 UTC (permalink / raw)
To: David Faust, gcc-patches
On 4/8/24 2:01 PM, David Faust wrote:
> This test failed on powerpc --target_board=unix'{-m32}' because two
> variables were not placed in sections where the test silently (and
> incorrectly) assumed they would be.
>
> The important thing for the test is only that BTF_KIND_DATASEC entries
> are NOT generated for the extern variable declarations without an
> explicit section attribute. Make the test more robust by placing the
> non-extern variables in explicit sections, and invert the checks to
> more accurately verify what we care about in this test.
>
> Tested on x86_64-linux-gnu and x86_64-linux-gnu host for
> powerpc64-linux-gnu and bpf-unkown-none targets.
>
> OK?
>
Hi David,
LGTM.
I see that we have btf-datasec-1.c testcase for checking the case when
vars are in sections .rodata/.bss/.data.
Thanks
> gcc/testsuite/
> PR testsuite/114642
> * gcc.dg/debug/btf/btf-datasec-3.c: Make test more robust on different
> architectures.
> ---
> gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
> index 297340cabfa..6b127aa14da 100644
> --- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
> +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-3.c
> @@ -7,22 +7,22 @@
>
> extern int VERSION __attribute__((section (".version")));
>
> -extern int test_bss1;
> -extern int test_data1;
> +extern int ext1;
> +extern int ext2;
>
> -int test_bss2;
> -int test_data2 = 2;
> +int var1 __attribute__((section (".sec_a")));
> +int var2 __attribute__((section (".sec_b"))) = 2;
>
> int
> foo (void)
> {
> - test_bss2 = VERSION;
> - return test_bss1 + test_data1 + test_data2;
> + ext2 = VERSION;
> + return ext1 + var1 + var2;
> }
>
> /* There should be 3 DATASEC entries total. Of the extern decls, only VERSION
> has a known section; entries are not created for the other two. */
> /* { dg-final { scan-assembler-times "bts_type" 3 } } */
> -/* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'test_data2'\\)" 1 } } */
> -/* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'test_bss2'\\)" 1 } } */
> /* { dg-final { scan-assembler-times "bts_type: \\(BTF_KIND_VAR 'VERSION'\\)" 1 } } */
> +/* { dg-final { scan-assembler-not "bts_type: \\(BTF_KIND_VAR 'ext1'\\)" } } */
> +/* { dg-final { scan-assembler-not "bts_type: \\(BTF_KIND_VAR 'ext2'\\)" } } */
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-09 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08 21:01 [PATCH] btf: improve btf-datasec-3.c test [PR 114642] David Faust
2024-04-09 18:05 ` Indu Bhagat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).