public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Faust <dfaust@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-10135] bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG Date: Thu, 25 Apr 2024 18:57:48 +0000 (GMT) [thread overview] Message-ID: <20240425185748.5CE5B3858D20@sourceware.org> (raw) 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" } */
reply other threads:[~2024-04-25 18:57 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240425185748.5CE5B3858D20@sourceware.org \ --to=dfaust@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).