aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-types.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-02 21:09:49 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:37 +0100
commit9b15cbb7891f6b8b185fed41e5e6ecea0a6a6c36 (patch)
treef63eea374097ed96af2fb1e2df12648438688265 /libctf/ctf-types.c
parent01d9317436cd824306b9856861408a40bf8da36a (diff)
downloadgdb-9b15cbb7891f6b8b185fed41e5e6ecea0a6a6c36.zip
gdb-9b15cbb7891f6b8b185fed41e5e6ecea0a6a6c36.tar.gz
gdb-9b15cbb7891f6b8b185fed41e5e6ecea0a6a6c36.tar.bz2
libctf: add ctf_type_kind_forwarded
This is just like ctf_type_kind, except that forwards get the type of the thing being pointed to rather than CTF_K_FORWARD. include/ * ctf-api.h (ctf_type_kind_forwarded): New. libctf/ * ctf-types.c (ctf_type_kind_forwarded): New.
Diffstat (limited to 'libctf/ctf-types.c')
-rw-r--r--libctf/ctf-types.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index ce3890c..d8f848c 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -677,6 +677,26 @@ ctf_type_kind (ctf_file_t *fp, ctf_id_t type)
return kind;
}
+/* Return the kind of this type, except, for forwards, return the kind of thing
+ this is a forward to. */
+int
+ctf_type_kind_forwarded (ctf_file_t *fp, ctf_id_t type)
+{
+ int kind;
+ const ctf_type_t *tp;
+
+ if ((kind = ctf_type_kind (fp, type)) < 0)
+ return -1; /* errno is set for us. */
+
+ if (kind != CTF_K_FORWARD)
+ return kind;
+
+ if ((tp = ctf_lookup_by_id (&fp, type)) == NULL)
+ return -1; /* errno is set for us. */
+
+ return tp->ctt_type;
+}
+
/* If the type is one that directly references another type (such as POINTER),
then return the ID of the type to which it refers. */