public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9222] btf: add BTF_KIND_FUNC traversal function.
@ 2024-02-28 19:24 Cupertino Miranda
  0 siblings, 0 replies; only message in thread
From: Cupertino Miranda @ 2024-02-28 19:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:69a3ce49bda929e1ffbc1fc1123f5f2485ec944d

commit r14-9222-g69a3ce49bda929e1ffbc1fc1123f5f2485ec944d
Author: Cupertino Miranda <cupertino.miranda@oracle.com>
Date:   Mon Feb 12 17:36:21 2024 +0000

    btf: add BTF_KIND_FUNC traversal function.
    
    The patch adds a traversal function to traverse all BTF_KIND_FUNC nodes
    with a callback function. Used for .BTF.ext section content creation.
    
    gcc/ChangeLog:
    
            * btfout.cc (output_btf_func_types): Use FOR_EACH_VEC_ELT.
            (traverse_btf_func_types): Define function.
            * ctfc.h (funcs_traverse_callback): Typedef for function
            prototype.
            (traverse_btf_func_types): Add prototype.

Diff:
---
 gcc/btfout.cc | 22 ++++++++++++++++++++--
 gcc/ctfc.h    |  3 +++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index 7e114e22444..7aabd99f3e7 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -1276,8 +1276,10 @@ output_btf_types (ctf_container_ref ctfc)
 static void
 output_btf_func_types (ctf_container_ref ctfc)
 {
-  for (size_t i = 0; i < vec_safe_length (funcs); i++)
-    btf_asm_func_type (ctfc, (*funcs)[i], i);
+  ctf_dtdef_ref ref;
+  unsigned i;
+  FOR_EACH_VEC_ELT (*funcs, i, ref)
+    btf_asm_func_type (ctfc, ref, i);
 }
 
 /* Output all BTF_KIND_DATASEC records.  */
@@ -1452,4 +1454,20 @@ btf_finalize (void)
   tu_ctfc = NULL;
 }
 
+/* Traversal function for all BTF_KIND_FUNC type records.  */
+
+bool
+traverse_btf_func_types (funcs_traverse_callback callback, void *data)
+{
+  ctf_dtdef_ref ref;
+  unsigned i;
+  FOR_EACH_VEC_ELT (*funcs, i, ref)
+    {
+      bool stop = callback (ref, data);
+      if (stop == true)
+	return true;
+    }
+  return false;
+}
+
 #include "gt-btfout.h"
diff --git a/gcc/ctfc.h b/gcc/ctfc.h
index 7aac57edac5..fa188bf2f5a 100644
--- a/gcc/ctfc.h
+++ b/gcc/ctfc.h
@@ -441,6 +441,9 @@ extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t,
 extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree);
 extern ctf_id_t get_btf_id (ctf_id_t);
 
+typedef bool (*funcs_traverse_callback) (ctf_dtdef_ref, void *);
+bool traverse_btf_func_types (funcs_traverse_callback, void *);
+
 /* CTF section does not emit location information; at this time, location
    information is needed for BTF CO-RE use-cases.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-28 19:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28 19:24 [gcc r14-9222] btf: add BTF_KIND_FUNC traversal function Cupertino Miranda

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).