public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Faust <david.faust@oracle.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 3/7] ctfc: add function to lookup CTF ID of a TREE type
Date: Wed,  4 Aug 2021 10:54:07 -0700	[thread overview]
Message-ID: <20210804175411.6783-4-david.faust@oracle.com> (raw)
In-Reply-To: <20210804175411.6783-1-david.faust@oracle.com>

Add a new function, ctf_lookup_tree_type, to return the CTF type ID
associated with a type via its is TREE node. The function is exposed via
a prototype in ctfc.h.

gcc/ChangeLog:

	* ctfc.c (ctf_lookup_tree_type): New function.
	* ctfc.h: Likewise.
---
 gcc/ctfc.c | 16 ++++++++++++++++
 gcc/ctfc.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/gcc/ctfc.c b/gcc/ctfc.c
index db6ba030301..73c118e3d49 100644
--- a/gcc/ctfc.c
+++ b/gcc/ctfc.c
@@ -791,6 +791,22 @@ ctf_add_sou (ctf_container_ref ctfc, uint32_t flag, const char * name,
   return type;
 }
 
+/* Given a TREE_TYPE node, return the CTF type ID for that type.  */
+
+ctf_id_t
+ctf_lookup_tree_type (ctf_container_ref ctfc, const tree type)
+{
+  dw_die_ref die = lookup_type_die (type);
+  if (die == NULL)
+    return CTF_NULL_TYPEID;
+
+  ctf_dtdef_ref dtd = ctf_dtd_lookup (ctfc, die);
+  if (dtd == NULL)
+    return CTF_NULL_TYPEID;
+
+  return dtd->dtd_type;
+}
+
 /* Check if CTF for TYPE has already been generated.  Mainstay for
    de-duplication.  If CTF type already exists, returns TRUE and updates
    the TYPE_ID for the caller.  */
diff --git a/gcc/ctfc.h b/gcc/ctfc.h
index 825570d807e..14180c1e5de 100644
--- a/gcc/ctfc.h
+++ b/gcc/ctfc.h
@@ -430,6 +430,8 @@ extern int ctf_add_function_arg (ctf_container_ref, dw_die_ref,
 extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t,
 			     dw_die_ref, unsigned int);
 
+extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree);
+
 /* CTF section does not emit location information; at this time, location
    information is needed for BTF CO-RE use-cases.  */
 
-- 
2.32.0


  parent reply	other threads:[~2021-08-04 17:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 17:54 [PATCH 0/7] BPF CO-RE Support David Faust
2021-08-04 17:54 ` [PATCH 1/7] dwarf: externalize lookup_type_die David Faust
2021-08-05  9:07   ` Richard Biener
2021-08-04 17:54 ` [PATCH 2/7] ctfc: externalize ctf_dtd_lookup David Faust
2021-08-04 17:54 ` David Faust [this message]
2021-08-04 17:54 ` [PATCH 4/7] btf: expose get_btf_id David Faust
2021-08-26 10:01   ` Richard Biener
2021-08-04 17:54 ` [PATCH 5/7] bpf: BPF CO-RE support David Faust
2021-08-10 15:11   ` Jose E. Marchesi
2021-08-04 17:54 ` [PATCH 6/7] bpf testsuite: Add BPF CO-RE tests David Faust
2021-08-10 15:12   ` Jose E. Marchesi
2021-08-04 17:54 ` [PATCH 7/7] doc: BPF CO-RE documentation David Faust
2021-08-26 10:01   ` Richard Biener

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=20210804175411.6783-4-david.faust@oracle.com \
    --to=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).