public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH V4 5/5] Enable BTF generation in the BPF backend
Date: Tue,  9 Mar 2021 11:04:02 +0100	[thread overview]
Message-ID: <20210309100402.16632-6-jose.marchesi@oracle.com> (raw)
In-Reply-To: <20210309100402.16632-1-jose.marchesi@oracle.com>

This patch changes the BPF GCC backend in order to use the DWARF debug
hooks and therefore enables the user to generate BTF debugging
information with -gbtf.  Generating BTF is crucial when compiling BPF
programs, since the CO-RE (compile-once, run-everwhere) mechanism
used by the kernel BPF loader relies on it.

Note that since in eBPF it is not possible to unwind frames due to the
restrictive nature of the target architecture, we are disabling the
generation of CFA in this target.

2021-01-22  David Faust <david.faust@oracle.com>

	* config/bpf/bpf.c (bpf_expand_prologue): Do not mark insns as
	frame related.
	(bpf_expand_epilogue): Likewise.
	* config/bpf/bpf.h (DWARF2_FRAME_INFO): Define to 0.
	Do not define DBX_DEBUGGING_INFO.
---
 gcc/config/bpf/bpf.c |  4 ----
 gcc/config/bpf/bpf.h | 12 ++----------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
index 126d4a2798d..e635f9edb40 100644
--- a/gcc/config/bpf/bpf.c
+++ b/gcc/config/bpf/bpf.c
@@ -349,7 +349,6 @@ bpf_expand_prologue (void)
 						      hard_frame_pointer_rtx,
 						      fp_offset - 8));
 		  insn = emit_move_insn (mem, gen_rtx_REG (DImode, regno));
-		  RTX_FRAME_RELATED_P (insn) = 1;
 		  fp_offset -= 8;
 		}
 	    }
@@ -364,7 +363,6 @@ bpf_expand_prologue (void)
     {
       insn = emit_move_insn (stack_pointer_rtx,
 			     hard_frame_pointer_rtx);
-      RTX_FRAME_RELATED_P (insn) = 1;
 
       if (size > 0)
 	{
@@ -372,7 +370,6 @@ bpf_expand_prologue (void)
 					 gen_rtx_PLUS (Pmode,
 						       stack_pointer_rtx,
 						       GEN_INT (-size))));
-	  RTX_FRAME_RELATED_P (insn) = 1;
 	}
     }
 }
@@ -412,7 +409,6 @@ bpf_expand_epilogue (void)
 						      hard_frame_pointer_rtx,
 						      fp_offset - 8));
 		  insn = emit_move_insn (gen_rtx_REG (DImode, regno), mem);
-		  RTX_FRAME_RELATED_P (insn) = 1;
 		  fp_offset -= 8;
 		}
 	    }
diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
index 9e2f5260900..ef0123b56a6 100644
--- a/gcc/config/bpf/bpf.h
+++ b/gcc/config/bpf/bpf.h
@@ -235,17 +235,9 @@ enum reg_class
 
 /**** Debugging Info ****/
 
-/* We cannot support DWARF2 because of the limitations of eBPF.  */
+/* In eBPF it is not possible to unwind frames. Disable CFA.  */
 
-/* elfos.h insists in using DWARF.  Undo that here.  */
-#ifdef DWARF2_DEBUGGING_INFO
-# undef DWARF2_DEBUGGING_INFO
-#endif
-#ifdef PREFERRED_DEBUGGING_TYPE
-# undef PREFERRED_DEBUGGING_TYPE
-#endif
-
-#define DBX_DEBUGGING_INFO
+#define DWARF2_FRAME_INFO 0
 
 /**** Stack Layout and Calling Conventions.  */
 
-- 
2.25.0.2.g232378479e


      parent reply	other threads:[~2021-03-09 10:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 10:03 [PATCH V4 0/5] Support for the CTF and BTF debug formats Jose E. Marchesi
2021-03-09 10:03 ` [PATCH V4 1/5] Add new function lang_GNU_GIMPLE Jose E. Marchesi
2021-03-09 10:03 ` [PATCH V4 2/5] CTF/BTF debug formats Jose E. Marchesi
2021-03-09 10:04 ` [PATCH V4 3/5] CTF/BTF testsuites Jose E. Marchesi
2021-03-09 10:04 ` [PATCH V4 4/5] CTF/BTF documentation Jose E. Marchesi
2021-03-09 10:04 ` 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=20210309100402.16632-6-jose.marchesi@oracle.com \
    --to=jose.marchesi@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).