aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-04-24 11:03:37 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-05-28 17:08:14 +0100
commit316afdb130346e44622229793d1fb8d391059f8d (patch)
tree869ce03acfa79331cb89475282a11ca7e1cdb7e4 /include
parent143dce8481f09f60704ab52b98cf8fe6d8b29fc9 (diff)
downloadgdb-316afdb130346e44622229793d1fb8d391059f8d.zip
gdb-316afdb130346e44622229793d1fb8d391059f8d.tar.gz
gdb-316afdb130346e44622229793d1fb8d391059f8d.tar.bz2
libctf: core type lookup
Finally we get to the functions used to actually look up and enumerate properties of types in a container (names, sizes, members, what type a pointer or cv-qual references, determination of whether two types are assignment-compatible, etc). With a very few exceptions these do not work for types newly added via ctf_add_*(): they only work on types in read-only containers, or types added before the most recent call to ctf_update(). This also adds support for lookup of "variables" (string -> type ID mappings) and for generation of C type names corresponding to a type ID. libctf/ * ctf-decl.c: New file. * ctf-types.c: Likewise. * ctf-impl.h: New declarations. include/ * ctf-api.h (ctf_visit_f): New definition. (ctf_member_f): Likewise. (ctf_enum_f): Likewise. (ctf_variable_f): Likewise. (ctf_type_f): Likewise. (ctf_type_isparent): Likewise. (ctf_type_ischild): Likewise. (ctf_type_resolve): Likewise. (ctf_type_aname): Likewise. (ctf_type_lname): Likewise. (ctf_type_name): Likewise. (ctf_type_sizee): Likewise. (ctf_type_align): Likewise. (ctf_type_kind): Likewise. (ctf_type_reference): Likewise. (ctf_type_pointer): Likewise. (ctf_type_encoding): Likewise. (ctf_type_visit): Likewise. (ctf_type_cmp): Likewise. (ctf_type_compat): Likewise. (ctf_member_info): Likewise. (ctf_array_info): Likewise. (ctf_enum_name): Likewise. (ctf_enum_value): Likewise. (ctf_member_iter): Likewise. (ctf_enum_iter): Likewise. (ctf_type_iter): Likewise. (ctf_variable_iter): Likewise.
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog31
-rw-r--r--include/ctf-api.h36
2 files changed, 67 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index e8e80f8..b935cb4 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,5 +1,36 @@
2019-05-28 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-api.h (ctf_visit_f): New definition.
+ (ctf_member_f): Likewise.
+ (ctf_enum_f): Likewise.
+ (ctf_variable_f): Likewise.
+ (ctf_type_f): Likewise.
+ (ctf_type_isparent): Likewise.
+ (ctf_type_ischild): Likewise.
+ (ctf_type_resolve): Likewise.
+ (ctf_type_aname): Likewise.
+ (ctf_type_lname): Likewise.
+ (ctf_type_name): Likewise.
+ (ctf_type_sizee): Likewise.
+ (ctf_type_align): Likewise.
+ (ctf_type_kind): Likewise.
+ (ctf_type_reference): Likewise.
+ (ctf_type_pointer): Likewise.
+ (ctf_type_encoding): Likewise.
+ (ctf_type_visit): Likewise.
+ (ctf_type_cmp): Likewise.
+ (ctf_type_compat): Likewise.
+ (ctf_member_info): Likewise.
+ (ctf_array_info): Likewise.
+ (ctf_enum_name): Likewise.
+ (ctf_enum_value): Likewise.
+ (ctf_member_iter): Likewise.
+ (ctf_enum_iter): Likewise.
+ (ctf_type_iter): Likewise.
+ (ctf_variable_iter): Likewise.
+
+2019-05-28 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-api.h (struct bfd): New forward.
(ctf_fdopen): New.
(ctf_bfdopen): Likewise.
diff --git a/include/ctf-api.h b/include/ctf-api.h
index ee68efe..023c890 100644
--- a/include/ctf-api.h
+++ b/include/ctf-api.h
@@ -206,6 +206,13 @@ enum
/* These typedefs are used to define the signature for callback functions
that can be used with the iteration and visit functions below. */
+typedef int ctf_visit_f (const char *name, ctf_id_t type, unsigned long offset,
+ int depth, void *arg);
+typedef int ctf_member_f (const char *name, ctf_id_t membtype,
+ unsigned long offset, void *arg);
+typedef int ctf_enum_f (const char *name, int val, void *arg);
+typedef int ctf_variable_f (const char *name, ctf_id_t type, void *arg);
+typedef int ctf_type_f (ctf_id_t type, void *arg);
typedef int ctf_archive_member_f (ctf_file_t *fp, const char *name, void *arg);
typedef int ctf_archive_raw_member_f (const char *name, const void *content,
size_t len, void *arg);
@@ -250,6 +257,8 @@ extern int ctf_arc_write (const char *, ctf_file_t **, size_t,
extern ctf_file_t *ctf_parent_file (ctf_file_t *);
extern const char *ctf_parent_name (ctf_file_t *);
extern void ctf_parent_name_set (ctf_file_t *, const char *);
+extern int ctf_type_isparent (ctf_file_t *, ctf_id_t);
+extern int ctf_type_ischild (ctf_file_t *, ctf_id_t);
extern int ctf_import (ctf_file_t *, ctf_file_t *);
extern int ctf_setmodel (ctf_file_t *, int);
@@ -260,6 +269,32 @@ extern void *ctf_getspecific (ctf_file_t *);
extern int ctf_errno (ctf_file_t *);
extern const char *ctf_errmsg (int);
+
+extern ctf_id_t ctf_type_resolve (ctf_file_t *, ctf_id_t);
+extern char *ctf_type_aname (ctf_file_t *, ctf_id_t);
+extern ssize_t ctf_type_lname (ctf_file_t *, ctf_id_t, char *, size_t);
+extern char *ctf_type_name (ctf_file_t *, ctf_id_t, char *, size_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 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 *);
+extern int ctf_type_visit (ctf_file_t *, ctf_id_t, ctf_visit_f *, void *);
+extern int ctf_type_cmp (ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
+extern int ctf_type_compat (ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
+
+extern int ctf_member_info (ctf_file_t *, ctf_id_t, const char *,
+ ctf_membinfo_t *);
+extern int ctf_array_info (ctf_file_t *, ctf_id_t, ctf_arinfo_t *);
+
+extern const char *ctf_enum_name (ctf_file_t *, ctf_id_t, int);
+extern int ctf_enum_value (ctf_file_t *, ctf_id_t, const char *, int *);
+
+extern int ctf_member_iter (ctf_file_t *, ctf_id_t, ctf_member_f *, void *);
+extern int ctf_enum_iter (ctf_file_t *, ctf_id_t, ctf_enum_f *, void *);
+extern int ctf_type_iter (ctf_file_t *, ctf_type_f *, void *);
+extern int ctf_variable_iter (ctf_file_t *, ctf_variable_f *, void *);
extern int ctf_archive_iter (const ctf_archive_t *, ctf_archive_member_f *,
void *);
/* This function alone does not currently operate on CTF files masquerading
@@ -268,6 +303,7 @@ extern int ctf_archive_iter (const ctf_archive_t *, ctf_archive_member_f *,
to deal with non-archives at all. */
extern int ctf_archive_raw_iter (const ctf_archive_t *,
ctf_archive_raw_member_f *, void *);
+
extern ctf_id_t ctf_add_array (ctf_file_t *, uint32_t,
const ctf_arinfo_t *);
extern ctf_id_t ctf_add_const (ctf_file_t *, uint32_t, ctf_id_t);