public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: David Faust <david.faust@oracle.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG
Date: Thu, 25 Apr 2024 20:45:34 +0200	[thread overview]
Message-ID: <87h6fp7035.fsf@oracle.com> (raw)
In-Reply-To: <20240425172320.7967-1-david.faust@oracle.com> (David Faust's message of "Thu, 25 Apr 2024 10:23:20 -0700")


Hi David.
OK.  Thanks for the patch.

> BTF is the standard debug info used with BPF programs, so it makes sense
> to default to BTF rather than DWARF.
>
> Tested on x86_64-linux-gnu host for bpf-unknown-none target.
>
> 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.
> ---
>  gcc/config/bpf/bpf.h                           |  5 +++++
>  .../gcc.target/bpf/bpf-debug-options-1.c       | 17 +++++++++++++++++
>  .../gcc.target/bpf/bpf-debug-options-2.c       | 18 ++++++++++++++++++
>  .../gcc.target/bpf/bpf-debug-options-3.c       | 14 ++++++++++++++
>  gcc/testsuite/gcc.target/bpf/core-options-4.c  |  4 ++++
>  5 files changed, 58 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/bpf/bpf-debug-options-1.c
>  create mode 100644 gcc/testsuite/gcc.target/bpf/bpf-debug-options-2.c
>  create mode 100644 gcc/testsuite/gcc.target/bpf/bpf-debug-options-3.c
>  create mode 100644 gcc/testsuite/gcc.target/bpf/core-options-4.c
>
> 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:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 17:23 David Faust
2024-04-25 18:45 ` Jose E. Marchesi [this message]

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=87h6fp7035.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=david.faust@oracle.com \
    --cc=gcc-patches@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: link
Be 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).