public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-10135] bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG
@ 2024-04-25 18:57 David Faust
0 siblings, 0 replies; only message in thread
From: David Faust @ 2024-04-25 18:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1604f7cebc49220e47d584615bcd91b1fdc1267f
commit r14-10135-g1604f7cebc49220e47d584615bcd91b1fdc1267f
Author: David Faust <david.faust@oracle.com>
Date: Wed Apr 24 15:01:02 2024 -0700
bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG
BTF is the standard debug info used with BPF programs, so it makes sense
to default to BTF rather than DWARF.
gcc/
* config/bpf/bpf.h (PREFERRED_DEBUGGING_TYPE): Set to BTF_DEBUG.
gcc/testsuite/
* gcc.target/bpf/bpf-debug-options-1.c: New test.
* gcc.target/bpf/bpf-debug-options-2.c: Likewise.
* gcc.target/bpf/bpf-debug-options-3.c: Likewise.
* gcc.target/bpf/core-options-4.c: Likewise.
Diff:
---
gcc/config/bpf/bpf.h | 5 +++++
gcc/testsuite/gcc.target/bpf/bpf-debug-options-1.c | 17 +++++++++++++++++
gcc/testsuite/gcc.target/bpf/bpf-debug-options-2.c | 18 ++++++++++++++++++
gcc/testsuite/gcc.target/bpf/bpf-debug-options-3.c | 14 ++++++++++++++
gcc/testsuite/gcc.target/bpf/core-options-4.c | 4 ++++
5 files changed, 58 insertions(+)
diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
index c67e17526bf..e163fbf688d 100644
--- a/gcc/config/bpf/bpf.h
+++ b/gcc/config/bpf/bpf.h
@@ -245,6 +245,11 @@ enum reg_class
/**** Debugging Info ****/
+/* Use BTF debug info by default. */
+
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE BTF_DEBUG
+
/* In eBPF it is not possible to unwind frames. Disable CFA. */
#define DWARF2_FRAME_INFO 0
diff --git a/gcc/testsuite/gcc.target/bpf/bpf-debug-options-1.c b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-1.c
new file mode 100644
index 00000000000..409466c4ead
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-1.c
@@ -0,0 +1,17 @@
+/* Default to BTF debug info. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return a->x;
+}
+
+/* { dg-final { scan-assembler-not "DWARF version" } } */
+/* { dg-final { scan-assembler "btf_version" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/bpf-debug-options-2.c b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-2.c
new file mode 100644
index 00000000000..03bde12315b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-2.c
@@ -0,0 +1,18 @@
+/* -g defaults to BTF, which in turn implies -mco-re. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return __builtin_preserve_access_index (a->x);
+}
+
+/* { dg-final { scan-assembler-not "DWARF version" } } */
+/* { dg-final { scan-assembler "btf_version" } } */
+/* { dg-final { scan-assembler "btfext_version" } } */
diff --git a/gcc/testsuite/gcc.target/bpf/bpf-debug-options-3.c b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-3.c
new file mode 100644
index 00000000000..d41790e0928
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/bpf-debug-options-3.c
@@ -0,0 +1,14 @@
+/* Using -g does not incorrectly force CO-RE enabled. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA -mno-co-re" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return __builtin_preserve_access_index (a->x); /* { dg-error "BPF CO-RE is required" } */
+}
diff --git a/gcc/testsuite/gcc.target/bpf/core-options-4.c b/gcc/testsuite/gcc.target/bpf/core-options-4.c
new file mode 100644
index 00000000000..fde4195da42
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/core-options-4.c
@@ -0,0 +1,4 @@
+/* -g implies BTF, -gtoggle turns it off. CO-RE should not work. */
+/* { dg-do compile } */
+/* { dg-options "-g -mco-re -gtoggle" } */
+/* { dg-excess-errors "BPF CO-RE requires BTF debugging information" } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-25 18:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 18:57 [gcc r14-10135] bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG David Faust
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).