From: Nick Alcock Date: Tue, 2 Jun 2020 20:09:49 +0000 (+0100) Subject: libctf: add ctf_type_kind_forwarded X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b15cbb7891f6b8b185fed41e5e6ecea0a6a6c36;p=binutils-gdb.git 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. --- diff --git a/include/ChangeLog b/include/ChangeLog index 2acc42a0149..18b0b0b84c6 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2020-07-22 Nick Alcock + + * ctf-api.h (ctf_type_kind_forwarded): New. + 2020-07-22 Nick Alcock * ctf-api.c (ctf_type_name_raw): New. diff --git a/include/ctf-api.h b/include/ctf-api.h index 363b5c258ca..87446a5f7d1 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -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 *); diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 1754baf83db..949e9d047b8 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,7 @@ +2020-07-22 Nick Alcock + + * ctf-types.c (ctf_type_kind_forwarded): New. + 2020-07-22 Nick Alcock * ctf-types.c (ctf_type_name_raw): New. diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index ce3890c33a6..d8f848cf893 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. */ diff --git a/libctf/libctf.ver b/libctf/libctf.ver index 30a0b087bd6..b8c5133d3f9 100644 --- a/libctf/libctf.ver +++ b/libctf/libctf.ver @@ -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;