]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: add ctf_type_kind_forwarded
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Jun 2020 20:09:49 +0000 (21:09 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 16:57:37 +0000 (17:57 +0100)
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.

include/ChangeLog
include/ctf-api.h
libctf/ChangeLog
libctf/ctf-types.c
libctf/libctf.ver

index 2acc42a0149dd2f7cb1abaf78b674ab9e80004c0..18b0b0b84c64247f5bfc3e58362d613b0c428b1c 100644 (file)
@@ -1,3 +1,7 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-api.h (ctf_type_kind_forwarded): New.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-api.c (ctf_type_name_raw): New.
index 363b5c258ca654c83f592673c50f0bc74e07a041..87446a5f7d1b63ac7d02229efae1469830cd8c9d 100644 (file)
@@ -328,6 +328,7 @@ extern const char *ctf_type_name_raw (ctf_file_t *, ctf_id_t);
 extern ssize_t ctf_type_size (ctf_file_t *, ctf_id_t);
 extern ssize_t ctf_type_align (ctf_file_t *, ctf_id_t);
 extern int ctf_type_kind (ctf_file_t *, ctf_id_t);
+extern int ctf_type_kind_forwarded (ctf_file_t *, ctf_id_t);
 extern ctf_id_t ctf_type_reference (ctf_file_t *, ctf_id_t);
 extern ctf_id_t ctf_type_pointer (ctf_file_t *, ctf_id_t);
 extern int ctf_type_encoding (ctf_file_t *, ctf_id_t, ctf_encoding_t *);
index 1754baf83db289d7ed384f8277bf1e9ea8fe2843..949e9d047b89b25f8a79957892cb5b0059c9b0b6 100644 (file)
@@ -1,3 +1,7 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-types.c (ctf_type_kind_forwarded): New.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-types.c (ctf_type_name_raw): New.
index ce3890c33a68f7e7be10ad1a462072911dafbc22..d8f848cf893e5cc0f3d44b6adce198a554d195dd 100644 (file)
@@ -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.  */
 
index 30a0b087bd657b13e5512f9b8c216a40835271b3..b8c5133d3f9436920589078775e946206f32bb1b 100644 (file)
@@ -63,6 +63,7 @@ LIBCTF_1.0 {
        ctf_type_size;
        ctf_type_align;
        ctf_type_kind;
+       ctf_type_kind_forwarded;
        ctf_type_reference;
        ctf_type_pointer;
        ctf_type_encoding;