aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-open.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
committerNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
commit139633c307eb6f5746ea04f94a0b6382e51bccb9 (patch)
tree6c070eeecd42d5c5bc93041be7fcc1279495a266 /libctf/ctf-open.c
parentcbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378 (diff)
downloadgdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.zip
gdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.tar.gz
gdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.tar.bz2
libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_t
The naming of the ctf_file_t type in libctf is a historical curiosity. Back in the Solaris days, CTF dictionaries were originally generated as a separate file and then (sometimes) merged into objects: hence the datatype was named ctf_file_t, and known as a "CTF file". Nowadays, raw CTF is essentially never written to a file on its own, and the datatype changed name to a "CTF dictionary" years ago. So the term "CTF file" refers to something that is never a file! This is at best confusing. The type has also historically been known as a 'CTF container", which is even more confusing now that we have CTF archives which are *also* a sort of container (they contain CTF dictionaries), but which are never referred to as containers in the source code. So fix this by completing the renaming, renaming ctf_file_t to ctf_dict_t throughout, and renaming those few functions that refer to CTF files by name (keeping compatibility aliases) to refer to dicts instead. Old users who still refer to ctf_file_t will see (harmless) pointer-compatibility warnings at compile time, but the ABI is unchanged (since C doesn't mangle names, and ctf_file_t was always an opaque type) and things will still compile fine as long as -Werror is not specified. All references to CTF containers and CTF files in the source code are fixed to refer to CTF dicts instead. Further (smaller) renamings of annoyingly-named functions to come, as part of the process of souping up queries across whole archives at once (needed for the function info and data object sections). binutils/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t. (dump_ctf_archive_member): Likewise. (dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close. * readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t. (dump_ctf_archive_member): Likewise. (dump_section_as_ctf): Likewise. Use ctf_dict_close, not ctf_file_close. gdb/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctfread.c: Change uses of ctf_file_t to ctf_dict_t. (ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close. include/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (ctf_file_t): Rename to... (ctf_dict_t): ... this. Keep ctf_file_t around for compatibility. (struct ctf_file): Likewise rename to... (struct ctf_dict): ... this. (ctf_file_close): Rename to... (ctf_dict_close): ... this, keeping compatibility function. (ctf_parent_file): Rename to... (ctf_parent_dict): ... this, keeping compatibility function. All callers adjusted. * ctf.h: Rename references to ctf_file_t to ctf_dict_t. (struct ctf_archive) <ctfa_nfiles>: Rename to... <ctfa_ndicts>: ... this. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ldlang.c (ctf_output): This is a ctf_dict_t now. (lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t. (ldlang_open_ctf): Adjust comment. (lang_merge_ctf): Use ctf_dict_close, not ctf_file_close. * ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to ctf_dict_t. Change opaque declaration accordingly. * ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust. * ldemul.h (examine_strtab_for_ctf): Likewise. (ldemul_examine_strtab_for_ctf): Likewise. * ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations adjusted. (ctf_fileops): Rename to... (ctf_dictops): ... this. (ctf_dedup_t) <cd_id_to_file_t>: Rename to... <cd_id_to_dict_t>: ... this. (ctf_file_t): Fix outdated comment. <ctf_fileops>: Rename to... <ctf_dictops>: ... this. (struct ctf_archive_internal) <ctfi_file>: Rename to... <ctfi_dict>: ... this. * ctf-archive.c: Rename ctf_file_t to ctf_dict_t. Rename ctf_archive.ctfa_nfiles to ctfa_ndicts. Rename ctf_file_close to ctf_dict_close. All users adjusted. * ctf-create.c: Likewise. Refer to CTF dicts, not CTF containers. (ctf_bundle_t) <ctb_file>: Rename to... <ctb_dict): ... this. * ctf-decl.c: Rename ctf_file_t to ctf_dict_t. * ctf-dedup.c: Likewise. Rename ctf_file_close to ctf_dict_close. Refer to CTF dicts, not CTF containers. * ctf-dump.c: Likewise. * ctf-error.c: Likewise. * ctf-hash.c: Likewise. * ctf-inlines.h: Likewise. * ctf-labels.c: Likewise. * ctf-link.c: Likewise. * ctf-lookup.c: Likewise. * ctf-open-bfd.c: Likewise. * ctf-string.c: Likewise. * ctf-subr.c: Likewise. * ctf-types.c: Likewise. * ctf-util.c: Likewise. * ctf-open.c: Likewise. (ctf_file_close): Rename to... (ctf_dict_close): ...this. (ctf_file_close): New trivial wrapper around ctf_dict_close, for compatibility. (ctf_parent_file): Rename to... (ctf_parent_dict): ... this. (ctf_parent_file): New trivial wrapper around ctf_parent_dict, for compatibility. * libctf.ver: Add ctf_dict_close and ctf_parent_dict.
Diffstat (limited to 'libctf/ctf-open.c')
-rw-r--r--libctf/ctf-open.c181
1 files changed, 97 insertions, 84 deletions
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 8c30182..456efa6 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -77,7 +77,7 @@ get_vlen_v2 (uint32_t info)
}
static inline ssize_t
-get_ctt_size_common (const ctf_file_t *fp _libctf_unused_,
+get_ctt_size_common (const ctf_dict_t *fp _libctf_unused_,
const ctf_type_t *tp _libctf_unused_,
ssize_t *sizep, ssize_t *incrementp, size_t lsize,
size_t csize, size_t ctf_type_size,
@@ -105,7 +105,7 @@ get_ctt_size_common (const ctf_file_t *fp _libctf_unused_,
}
static ssize_t
-get_ctt_size_v1 (const ctf_file_t *fp, const ctf_type_t *tp,
+get_ctt_size_v1 (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
ctf_type_v1_t *t1p = (ctf_type_v1_t *) tp;
@@ -119,7 +119,7 @@ get_ctt_size_v1 (const ctf_file_t *fp, const ctf_type_t *tp,
/* Return the size that a v1 will be once it is converted to v2. */
static ssize_t
-get_ctt_size_v2_unconverted (const ctf_file_t *fp, const ctf_type_t *tp,
+get_ctt_size_v2_unconverted (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
ctf_type_v1_t *t1p = (ctf_type_v1_t *) tp;
@@ -131,7 +131,7 @@ get_ctt_size_v2_unconverted (const ctf_file_t *fp, const ctf_type_t *tp,
}
static ssize_t
-get_ctt_size_v2 (const ctf_file_t *fp, const ctf_type_t *tp,
+get_ctt_size_v2 (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
return (get_ctt_size_common (fp, tp, sizep, incrementp,
@@ -141,7 +141,7 @@ get_ctt_size_v2 (const ctf_file_t *fp, const ctf_type_t *tp,
}
static ssize_t
-get_vbytes_common (ctf_file_t *fp, unsigned short kind,
+get_vbytes_common (ctf_dict_t *fp, unsigned short kind,
ssize_t size _libctf_unused_, size_t vlen)
{
switch (kind)
@@ -169,7 +169,7 @@ get_vbytes_common (ctf_file_t *fp, unsigned short kind,
}
static ssize_t
-get_vbytes_v1 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
+get_vbytes_v1 (ctf_dict_t *fp, unsigned short kind, ssize_t size, size_t vlen)
{
switch (kind)
{
@@ -189,7 +189,7 @@ get_vbytes_v1 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
}
static ssize_t
-get_vbytes_v2 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
+get_vbytes_v2 (ctf_dict_t *fp, unsigned short kind, ssize_t size, size_t vlen)
{
switch (kind)
{
@@ -208,7 +208,7 @@ get_vbytes_v2 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
return (get_vbytes_common (fp, kind, size, vlen));
}
-static const ctf_fileops_t ctf_fileops[] = {
+static const ctf_dictops_t ctf_dictops[] = {
{NULL, NULL, NULL, NULL, NULL},
/* CTF_VERSION_1 */
{get_kind_v1, get_root_v1, get_vlen_v1, get_ctt_size_v1, get_vbytes_v1},
@@ -225,7 +225,7 @@ static const ctf_fileops_t ctf_fileops[] = {
STT_OBJECT entry in the symbol table. */
static int
-init_symtab (ctf_file_t *fp, const ctf_header_t *hp,
+init_symtab (ctf_dict_t *fp, const ctf_header_t *hp,
const ctf_sect_t *sp, const ctf_sect_t *strp)
{
const unsigned char *symp = sp->cts_data;
@@ -311,14 +311,14 @@ init_symtab (ctf_file_t *fp, const ctf_header_t *hp,
}
/* Reset the CTF base pointer and derive the buf pointer from it, initializing
- everything in the ctf_file that depends on the base or buf pointers.
+ everything in the ctf_dict that depends on the base or buf pointers.
The original gap between the buf and base pointers, if any -- the original,
unconverted CTF header -- is kept, but its contents are not specified and are
never used. */
static void
-ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
+ctf_set_base (ctf_dict_t *fp, const ctf_header_t *hp, unsigned char *base)
{
fp->ctf_buf = base + (fp->ctf_buf - fp->ctf_base);
fp->ctf_base = base;
@@ -330,8 +330,8 @@ ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
+ hp->cth_stroff;
fp->ctf_str[CTF_STRTAB_0].cts_len = hp->cth_strlen;
- /* If we have a parent container name and label, store the relocated
- string pointers in the CTF container for easy access later. */
+ /* If we have a parent dict name and label, store the relocated string
+ pointers in the CTF dict for easy access later. */
/* Note: before conversion, these will be set to values that will be
immediately invalidated by the conversion process, but the conversion
@@ -359,11 +359,11 @@ ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
caller must ensure this has been done in advance. */
static void
-ctf_set_version (ctf_file_t *fp, ctf_header_t *cth, int ctf_version)
+ctf_set_version (ctf_dict_t *fp, ctf_header_t *cth, int ctf_version)
{
fp->ctf_version = ctf_version;
cth->cth_version = ctf_version;
- fp->ctf_fileops = &ctf_fileops[ctf_version];
+ fp->ctf_dictops = &ctf_dictops[ctf_version];
}
@@ -397,7 +397,7 @@ upgrade_header (ctf_header_t *hp)
Type kinds not checked here due to nonexistence in older formats:
CTF_K_SLICE. */
static int
-upgrade_types_v1 (ctf_file_t *fp, ctf_header_t *cth)
+upgrade_types_v1 (ctf_dict_t *fp, ctf_header_t *cth)
{
const ctf_type_v1_t *tbuf;
const ctf_type_v1_t *tend;
@@ -621,7 +621,7 @@ upgrade_types_v1 (ctf_file_t *fp, ctf_header_t *cth)
/* Upgrade from any earlier version. */
static int
-upgrade_types (ctf_file_t *fp, ctf_header_t *cth)
+upgrade_types (ctf_dict_t *fp, ctf_header_t *cth)
{
switch (cth->cth_version)
{
@@ -649,7 +649,7 @@ upgrade_types (ctf_file_t *fp, ctf_header_t *cth)
recension of libctf supports upgrading. */
static int
-init_types (ctf_file_t *fp, ctf_header_t *cth)
+init_types (ctf_dict_t *fp, ctf_header_t *cth)
{
const ctf_type_t *tbuf;
const ctf_type_t *tend;
@@ -659,8 +659,8 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
uint32_t id, dst;
uint32_t *xp;
- /* We determine whether the container is a child or a parent based on
- the value of cth_parname. */
+ /* We determine whether the dict is a child or a parent based on the value of
+ cth_parname. */
int child = cth->cth_parname != 0;
int nlstructs = 0, nlunions = 0;
@@ -704,11 +704,11 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
if (child)
{
- ctf_dprintf ("CTF container %p is a child\n", (void *) fp);
+ ctf_dprintf ("CTF dict %p is a child\n", (void *) fp);
fp->ctf_flags |= LCTF_CHILD;
}
else
- ctf_dprintf ("CTF container %p is a parent\n", (void *) fp);
+ ctf_dprintf ("CTF dict %p is a parent\n", (void *) fp);
/* Now that we've counted up the number of each type, we can allocate
the hash tables, type translation table, and pointer table. */
@@ -885,9 +885,9 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
}
case CTF_K_POINTER:
- /* If the type referenced by the pointer is in this CTF container,
- then store the index of the pointer type in
- fp->ctf_ptrtab[ index of referenced type ]. */
+ /* If the type referenced by the pointer is in this CTF dict, then
+ store the index of the pointer type in fp->ctf_ptrtab[ index of
+ referenced type ]. */
if (LCTF_TYPE_ISCHILD (fp, tp->ctt_type) == child
&& LCTF_TYPE_TO_INDEX (fp, tp->ctt_type) <= fp->ctf_typemax)
@@ -1045,7 +1045,7 @@ flip_vars (void *start, size_t len)
ctf_stype followed by variable data. */
static int
-flip_types (ctf_file_t *fp, void *start, size_t len)
+flip_types (ctf_dict_t *fp, void *start, size_t len)
{
ctf_type_t *t = start;
@@ -1203,7 +1203,7 @@ flip_types (ctf_file_t *fp, void *start, size_t len)
data, this is no real loss. */
static int
-flip_ctf (ctf_file_t *fp, ctf_header_t *cth, unsigned char *buf)
+flip_ctf (ctf_dict_t *fp, ctf_header_t *cth, unsigned char *buf)
{
flip_lbls (buf + cth->cth_lbloff, cth->cth_objtoff - cth->cth_lbloff);
flip_objts (buf + cth->cth_objtoff, cth->cth_funcoff - cth->cth_objtoff);
@@ -1214,9 +1214,9 @@ flip_ctf (ctf_file_t *fp, ctf_header_t *cth, unsigned char *buf)
return flip_types (fp, buf + cth->cth_typeoff, cth->cth_stroff - cth->cth_typeoff);
}
-/* Set up the ctl hashes in a ctf_file_t. Called by both writable and
+/* Set up the ctl hashes in a ctf_dict_t. Called by both writable and
non-writable dictionary initialization. */
-void ctf_set_ctl_hashes (ctf_file_t *fp)
+void ctf_set_ctl_hashes (ctf_dict_t *fp)
{
/* Initialize the ctf_lookup_by_name top-level dictionary. We keep an
array of type name prefixes and the corresponding ctf_hash to use. */
@@ -1239,7 +1239,7 @@ void ctf_set_ctl_hashes (ctf_file_t *fp)
/* Open a CTF file, mocking up a suitable ctf_sect. */
-ctf_file_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
+ctf_dict_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
const char *symsect, size_t symsect_size,
size_t symsect_entsize,
const char *strsect, size_t strsect_size,
@@ -1253,7 +1253,7 @@ ctf_file_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
/* Open a CTF file, mocking up a suitable ctf_sect and overriding the external
strtab with a synthetic one. */
-ctf_file_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
+ctf_dict_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
const char *symsect, size_t symsect_size,
size_t symsect_entsize,
const char *strsect, size_t strsect_size,
@@ -1300,11 +1300,11 @@ ctf_file_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
}
/* Decode the specified CTF buffer and optional symbol table, and create a new
- CTF container representing the symbolic debugging information. This code can
+ CTF dict representing the symbolic debugging information. This code can
be used directly by the debugger, or it can be used as the engine for
ctf_fdopen() or ctf_open(), below. */
-ctf_file_t *
+ctf_dict_t *
ctf_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_sect_t *strsect, int *errp)
{
@@ -1313,7 +1313,7 @@ ctf_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
/* Like ctf_bufopen, but overriding the external strtab with a synthetic one. */
-ctf_file_t *
+ctf_dict_t *
ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_sect_t *strsect, ctf_dynhash_t *syn_strtab,
int writable, int *errp)
@@ -1321,7 +1321,7 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_preamble_t *pp;
size_t hdrsz = sizeof (ctf_header_t);
ctf_header_t *hp;
- ctf_file_t *fp;
+ ctf_dict_t *fp;
int foreign_endian = 0;
int err;
@@ -1393,10 +1393,10 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
if (ctfsect->cts_size < hdrsz)
return (ctf_set_open_errno (errp, ECTF_NOCTFBUF));
- if ((fp = malloc (sizeof (ctf_file_t))) == NULL)
+ if ((fp = malloc (sizeof (ctf_dict_t))) == NULL)
return (ctf_set_open_errno (errp, ENOMEM));
- memset (fp, 0, sizeof (ctf_file_t));
+ memset (fp, 0, sizeof (ctf_dict_t));
if (writable)
fp->ctf_flags |= LCTF_RDWR;
@@ -1511,7 +1511,7 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
}
/* Once we have uncompressed and validated the CTF data buffer, we can
- proceed with initializing the ctf_file_t we allocated above.
+ proceed with initializing the ctf_dict_t we allocated above.
Nothing that depends on buf or base should be set directly in this function
before the init_types() call, because it may be reallocated during
@@ -1575,8 +1575,8 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
ctf_set_base (fp, hp, fp->ctf_base);
- /* No need to do anything else for dynamic containers: they do not support
- symbol lookups, and the type table is maintained in the dthashes. */
+ /* No need to do anything else for dynamic dicts: they do not support symbol
+ lookups, and the type table is maintained in the dthashes. */
if (fp->ctf_flags & LCTF_RDWR)
{
fp->ctf_refcnt = 1;
@@ -1624,37 +1624,37 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
bad:
ctf_set_open_errno (errp, err);
ctf_err_warn_to_open (fp);
- ctf_file_close (fp);
+ ctf_dict_close (fp);
return NULL;
}
-/* Bump the refcount on the specified CTF container, to allow export of
- ctf_file_t's from iterators that open and close the ctf_file_t around the
- loop. (This does not extend their lifetime beyond that of the ctf_archive_t
- in which they are contained.) */
+/* Bump the refcount on the specified CTF dict, to allow export of ctf_dict_t's
+ from iterators that open and close the ctf_dict_t around the loop. (This
+ does not extend their lifetime beyond that of the ctf_archive_t in which they
+ are contained.) */
void
-ctf_ref (ctf_file_t *fp)
+ctf_ref (ctf_dict_t *fp)
{
fp->ctf_refcnt++;
}
-/* Close the specified CTF container and free associated data structures. Note
- that ctf_file_close() is a reference counted operation: if the specified file
- is the parent of other active containers, its reference count will be greater
- than one and it will be freed later when no active children exist. */
+/* Close the specified CTF dict and free associated data structures. Note that
+ ctf_dict_close() is a reference counted operation: if the specified file is
+ the parent of other active dict, its reference count will be greater than one
+ and it will be freed later when no active children exist. */
void
-ctf_file_close (ctf_file_t *fp)
+ctf_dict_close (ctf_dict_t *fp)
{
ctf_dtdef_t *dtd, *ntd;
ctf_dvdef_t *dvd, *nvd;
ctf_err_warning_t *err, *nerr;
if (fp == NULL)
- return; /* Allow ctf_file_close(NULL) to simplify caller code. */
+ return; /* Allow ctf_dict_close(NULL) to simplify caller code. */
- ctf_dprintf ("ctf_file_close(%p) refcnt=%u\n", (void *) fp, fp->ctf_refcnt);
+ ctf_dprintf ("ctf_dict_close(%p) refcnt=%u\n", (void *) fp, fp->ctf_refcnt);
if (fp->ctf_refcnt > 1)
{
@@ -1672,7 +1672,7 @@ ctf_file_close (ctf_file_t *fp)
free (fp->ctf_dyncuname);
free (fp->ctf_dynparname);
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
- ctf_file_close (fp->ctf_parent);
+ ctf_dict_close (fp->ctf_parent);
for (dtd = ctf_list_next (&fp->ctf_dtdefs); dtd != NULL; dtd = ntd)
{
@@ -1743,6 +1743,13 @@ ctf_file_close (ctf_file_t *fp)
free (fp);
}
+/* Backward compatibility. */
+void
+ctf_file_close (ctf_file_t *fp)
+{
+ ctf_dict_close (fp);
+}
+
/* The converse of ctf_open(). ctf_open() disguises whatever it opens as an
archive, so closing one is just like closing an archive. */
void
@@ -1751,36 +1758,42 @@ ctf_close (ctf_archive_t *arc)
ctf_arc_close (arc);
}
-/* Get the CTF archive from which this ctf_file_t is derived. */
+/* Get the CTF archive from which this ctf_dict_t is derived. */
ctf_archive_t *
-ctf_get_arc (const ctf_file_t *fp)
+ctf_get_arc (const ctf_dict_t *fp)
{
return fp->ctf_archive;
}
/* Return the ctfsect out of the core ctf_impl. Useful for freeing the
- ctfsect's data * after ctf_file_close(), which is why we return the actual
+ ctfsect's data * after ctf_dict_close(), which is why we return the actual
structure, not a pointer to it, since that is likely to become a pointer to
freed data before the return value is used under the expected use case of
- ctf_getsect()/ ctf_file_close()/free(). */
+ ctf_getsect()/ ctf_dict_close()/free(). */
ctf_sect_t
-ctf_getdatasect (const ctf_file_t *fp)
+ctf_getdatasect (const ctf_dict_t *fp)
{
return fp->ctf_data;
}
-/* Return the CTF handle for the parent CTF container, if one exists.
- Otherwise return NULL to indicate this container has no imported parent. */
-ctf_file_t *
-ctf_parent_file (ctf_file_t *fp)
+/* Return the CTF handle for the parent CTF dict, if one exists. Otherwise
+ return NULL to indicate this dict has no imported parent. */
+ctf_dict_t *
+ctf_parent_dict (ctf_dict_t *fp)
{
return fp->ctf_parent;
}
-/* Return the name of the parent CTF container, if one exists. Otherwise
- return NULL to indicate this container is a root container. */
+/* Backward compatibility. */
+ctf_dict_t *
+ctf_parent_file (ctf_dict_t *fp)
+{
+ return ctf_parent_dict (fp);
+}
+
+/* Return the name of the parent CTF dict, if one exists, or NULL otherwise. */
const char *
-ctf_parent_name (ctf_file_t *fp)
+ctf_parent_name (ctf_dict_t *fp)
{
return fp->ctf_parname;
}
@@ -1788,7 +1801,7 @@ ctf_parent_name (ctf_file_t *fp)
/* Set the parent name. It is an error to call this routine without calling
ctf_import() at some point. */
int
-ctf_parent_name_set (ctf_file_t *fp, const char *name)
+ctf_parent_name_set (ctf_dict_t *fp, const char *name)
{
if (fp->ctf_dynparname != NULL)
free (fp->ctf_dynparname);
@@ -1800,16 +1813,16 @@ ctf_parent_name_set (ctf_file_t *fp, const char *name)
}
/* Return the name of the compilation unit this CTF file applies to. Usually
- non-NULL only for non-parent containers. */
+ non-NULL only for non-parent dicts. */
const char *
-ctf_cuname (ctf_file_t *fp)
+ctf_cuname (ctf_dict_t *fp)
{
return fp->ctf_cuname;
}
/* Set the compilation unit name. */
int
-ctf_cuname_set (ctf_file_t *fp, const char *name)
+ctf_cuname_set (ctf_dict_t *fp, const char *name)
{
if (fp->ctf_dyncuname != NULL)
free (fp->ctf_dyncuname);
@@ -1820,11 +1833,11 @@ ctf_cuname_set (ctf_file_t *fp, const char *name)
return 0;
}
-/* Import the types from the specified parent container by storing a pointer
- to it in ctf_parent and incrementing its reference count. Only one parent
- is allowed: if a parent already exists, it is replaced by the new parent. */
+/* Import the types from the specified parent dict by storing a pointer to it in
+ ctf_parent and incrementing its reference count. Only one parent is allowed:
+ if a parent already exists, it is replaced by the new parent. */
int
-ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
+ctf_import (ctf_dict_t *fp, ctf_dict_t *pfp)
{
if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
return (ctf_set_errno (fp, EINVAL));
@@ -1833,7 +1846,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
return (ctf_set_errno (fp, ECTF_DMODEL));
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
- ctf_file_close (fp->ctf_parent);
+ ctf_dict_close (fp->ctf_parent);
fp->ctf_parent = NULL;
if (pfp != NULL)
@@ -1858,7 +1871,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
caller must do all freeing itself. Used internally to avoid refcount
loops. */
int
-ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
+ctf_import_unref (ctf_dict_t *fp, ctf_dict_t *pfp)
{
if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
return (ctf_set_errno (fp, EINVAL));
@@ -1867,7 +1880,7 @@ ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
return (ctf_set_errno (fp, ECTF_DMODEL));
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
- ctf_file_close (fp->ctf_parent);
+ ctf_dict_close (fp->ctf_parent);
fp->ctf_parent = NULL;
if (pfp != NULL)
@@ -1886,9 +1899,9 @@ ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
return 0;
}
-/* Set the data model constant for the CTF container. */
+/* Set the data model constant for the CTF dict. */
int
-ctf_setmodel (ctf_file_t *fp, int model)
+ctf_setmodel (ctf_dict_t *fp, int model)
{
const ctf_dmodel_t *dp;
@@ -1904,24 +1917,24 @@ ctf_setmodel (ctf_file_t *fp, int model)
return (ctf_set_errno (fp, EINVAL));
}
-/* Return the data model constant for the CTF container. */
+/* Return the data model constant for the CTF dict. */
int
-ctf_getmodel (ctf_file_t *fp)
+ctf_getmodel (ctf_dict_t *fp)
{
return fp->ctf_dmodel->ctd_code;
}
-/* The caller can hang an arbitrary pointer off each ctf_file_t using this
+/* The caller can hang an arbitrary pointer off each ctf_dict_t using this
function. */
void
-ctf_setspecific (ctf_file_t *fp, void *data)
+ctf_setspecific (ctf_dict_t *fp, void *data)
{
fp->ctf_specific = data;
}
/* Retrieve the arbitrary pointer again. */
void *
-ctf_getspecific (ctf_file_t *fp)
+ctf_getspecific (ctf_dict_t *fp)
{
return fp->ctf_specific;
}