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.
+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.
+
2020-11-20 Nick Clifton <nickc@redhat.com>
PR 22967
/* Dump CTF errors/warnings. */
static void
-dump_ctf_errs (ctf_file_t *fp)
+dump_ctf_errs (ctf_dict_t *fp)
{
ctf_next_t *it = NULL;
char *errtext;
/* Dump one CTF archive member. */
static int
-dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
+dump_ctf_archive_member (ctf_dict_t *ctf, const char *name, void *arg)
{
- ctf_file_t *parent = (ctf_file_t *) arg;
+ ctf_dict_t *parent = (ctf_dict_t *) arg;
const char *things[] = {"Header", "Labels", "Data objects",
"Function objects", "Variables", "Types", "Strings",
""};
bfd_byte *ctfdata, *parentdata = NULL;
bfd_size_type ctfsize, parentsize;
ctf_sect_t ctfsect;
- ctf_file_t *parent = NULL;
+ ctf_dict_t *parent = NULL;
int err;
if ((ctfdata = read_section_stabs (abfd, sect_name, &ctfsize, NULL)) == NULL)
printf (_("Contents of CTF section %s:\n"), sanitize_string (sect_name));
ctf_archive_iter (ctfa, dump_ctf_archive_member, parent);
- ctf_file_close (parent);
+ ctf_dict_close (parent);
ctf_close (ctfa);
ctf_close (parenta);
free (parentdata);
/* Dump CTF errors/warnings. */
static void
-dump_ctf_errs (ctf_file_t *fp)
+dump_ctf_errs (ctf_dict_t *fp)
{
ctf_next_t *it = NULL;
char *errtext;
/* Dump one CTF archive member. */
static int
-dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
+dump_ctf_archive_member (ctf_dict_t *ctf, const char *name, void *arg)
{
- ctf_file_t *parent = (ctf_file_t *) arg;
+ ctf_dict_t *parent = (ctf_dict_t *) arg;
const char *things[] = {"Header", "Labels", "Data objects",
"Function objects", "Variables", "Types", "Strings",
""};
ctf_sect_t * strsectp = NULL;
ctf_archive_t * ctfa = NULL;
ctf_archive_t * parenta = NULL, *lookparent;
- ctf_file_t * parent = NULL;
+ ctf_dict_t * parent = NULL;
int err;
bfd_boolean ret = FALSE;
ret = FALSE;
fail:
- ctf_file_close (parent);
+ ctf_dict_close (parent);
ctf_close (ctfa);
ctf_close (parenta);
free (parentdata);
+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.
+
2020-11-20 Pedro Alves <pedro@palves.net>
* language.c (language_arch_info::lookup_primitive_type): Use
struct ctf_fp_info
{
- explicit ctf_fp_info (ctf_file_t *cfp) : fp (cfp) {}
+ explicit ctf_fp_info (ctf_dict_t *cfp) : fp (cfp) {}
~ctf_fp_info ();
- ctf_file_t *fp;
+ ctf_dict_t *fp;
};
-/* Cleanup function for the ctf_file_key data. */
+/* Cleanup function for the ctf_dict_key data. */
ctf_fp_info::~ctf_fp_info ()
{
if (!fp)
return;
ctf_archive_t *arc = ctf_get_arc (fp);
- ctf_file_close (fp);
+ ctf_dict_close (fp);
ctf_close (arc);
}
-static const objfile_key<ctf_fp_info> ctf_file_key;
+static const objfile_key<ctf_fp_info> ctf_dict_key;
/* A CTF context consists of a file pointer and an objfile pointer. */
struct ctf_context
{
- ctf_file_t *fp;
+ ctf_dict_t *fp;
struct objfile *of;
partial_symtab *pst;
struct buildsym_compunit *builder;
/* Return the size of storage in bits for INTEGER, FLOAT, or ENUM. */
static int
-get_bitsize (ctf_file_t *fp, ctf_id_t tid, uint32_t kind)
+get_bitsize (ctf_dict_t *fp, ctf_id_t tid, uint32_t kind)
{
ctf_encoding_t cet;
new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
{
struct objfile *objfile = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct symbol *sym = NULL;
gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid));
read_base_type (struct ctf_context *ccp, ctf_id_t tid)
{
struct objfile *of = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
ctf_encoding_t cet;
struct type *type = NULL;
char *name;
read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
{
struct objfile *of = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct type *type;
uint32_t kind;
read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
{
struct objfile *of = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct type *type, *rettype;
ctf_funcinfo_t cfi;
read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
{
struct objfile *of = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct type *type, *target_type;
ctf_funcinfo_t fi;
read_array_type (struct ctf_context *ccp, ctf_id_t tid)
{
struct objfile *objfile = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct type *element_type, *range_type, *idx_type;
struct type *type;
ctf_arinfo_t ar;
read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid)
{
struct objfile *objfile = ccp->of;
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
struct type *base_type, *cv_type;
base_type = get_tid_type (objfile, btid);
static struct type *
read_type_record (struct ctf_context *ccp, ctf_id_t tid)
{
- ctf_file_t *fp = ccp->fp;
+ ctf_dict_t *fp = ccp->fp;
uint32_t kind;
struct type *type = NULL;
ctf_id_t btid;
static ctf_psymtab *
create_partial_symtab (const char *name,
- ctf_file_t *cfp,
+ ctf_dict_t *cfp,
struct objfile *objfile)
{
ctf_psymtab *pst;
debugging information is available. */
static void
-scan_partial_symbols (ctf_file_t *cfp, struct objfile *of)
+scan_partial_symbols (ctf_dict_t *cfp, struct objfile *of)
{
bfd *abfd = of->obfd;
const char *name = bfd_get_filename (abfd);
error (_("ctf_bfdopen failed on %s - %s"),
bfd_get_filename (abfd), ctf_errmsg (err));
- ctf_file_t *fp = ctf_arc_open_by_name (arc, NULL, &err);
+ ctf_dict_t *fp = ctf_arc_open_by_name (arc, NULL, &err);
if (fp == NULL)
error (_("ctf_arc_open_by_name failed on %s - %s"),
bfd_get_filename (abfd), ctf_errmsg (err));
- ctf_file_key.emplace (of, fp);
+ ctf_dict_key.emplace (of, fp);
scan_partial_symbols (fp, of);
}
+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.
+
2020-11-18 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* elf/common.h (SHF_GNU_RETAIN): Define.
#endif
/* Clients can open one or more CTF containers and obtain a pointer to an
- opaque ctf_file_t. Types are identified by an opaque ctf_id_t token.
+ opaque ctf_dict_t. Types are identified by an opaque ctf_id_t token.
They can also open or create read-only archives of CTF containers in a
ctf_archive_t.
These opaque definitions allow libctf to evolve without breaking clients. */
-typedef struct ctf_file ctf_file_t;
+typedef struct ctf_dict ctf_dict_t;
typedef struct ctf_archive_internal ctf_archive_t;
typedef unsigned long ctf_id_t;
typedef int ctf_type_all_f (ctf_id_t type, int flag, void *arg);
typedef int ctf_label_f (const char *name, const ctf_lblinfo_t *info,
void *arg);
-typedef int ctf_archive_member_f (ctf_file_t *fp, const char *name, void *arg);
+typedef int ctf_archive_member_f (ctf_dict_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);
typedef char *ctf_dump_decorate_f (ctf_sect_names_t sect,
/* Opening. These mostly return an abstraction over both CTF files and CTF
archives: so they can be used to open both. CTF files will appear to be an
archive with one member named '.ctf'. The low-level functions
- ctf_simple_open() and ctf_bufopen() return ctf_file_t's directly, and cannot
+ ctf_simple_open() and ctf_bufopen() return ctf_dict_t's directly, and cannot
be used on CTF archives. */
extern ctf_archive_t *ctf_bfdopen (struct bfd *, int *);
extern ctf_archive_t *ctf_open (const char *filename,
const char *target, int *errp);
extern void ctf_close (ctf_archive_t *);
-extern ctf_sect_t ctf_getdatasect (const ctf_file_t *);
-extern ctf_archive_t *ctf_get_arc (const ctf_file_t *);
+extern ctf_sect_t ctf_getdatasect (const ctf_dict_t *);
+extern ctf_archive_t *ctf_get_arc (const ctf_dict_t *);
extern ctf_archive_t *ctf_arc_open (const char *, int *);
extern ctf_archive_t *ctf_arc_bufopen (const ctf_sect_t *,
const ctf_sect_t *,
const ctf_sect_t *,
int *);
extern void ctf_arc_close (ctf_archive_t *);
-extern ctf_file_t *ctf_arc_open_by_name (const ctf_archive_t *,
+extern ctf_dict_t *ctf_arc_open_by_name (const ctf_archive_t *,
const char *, int *);
-extern ctf_file_t *ctf_arc_open_by_name_sections (const ctf_archive_t *,
+extern ctf_dict_t *ctf_arc_open_by_name_sections (const ctf_archive_t *,
const ctf_sect_t *,
const ctf_sect_t *,
const char *, int *);
/* The next functions return or close real CTF files, or write out CTF archives,
not opaque containers around either. */
-extern ctf_file_t *ctf_simple_open (const char *, size_t, const char *, size_t,
+extern ctf_dict_t *ctf_simple_open (const char *, size_t, const char *, size_t,
size_t, const char *, size_t, int *);
-extern ctf_file_t *ctf_bufopen (const ctf_sect_t *, const ctf_sect_t *,
+extern ctf_dict_t *ctf_bufopen (const ctf_sect_t *, const ctf_sect_t *,
const ctf_sect_t *, int *);
-extern void ctf_ref (ctf_file_t *);
-extern void ctf_file_close (ctf_file_t *);
+extern void ctf_ref (ctf_dict_t *);
+extern void ctf_dict_close (ctf_dict_t *);
-extern int ctf_arc_write (const char *, ctf_file_t **, size_t,
+extern int ctf_arc_write (const char *, ctf_dict_t **, size_t,
const char **, size_t);
-extern int ctf_arc_write_fd (int, ctf_file_t **, size_t, const char **,
+extern int ctf_arc_write_fd (int, ctf_dict_t **, size_t, const char **,
size_t);
-extern const char *ctf_cuname (ctf_file_t *);
-extern int ctf_cuname_set (ctf_file_t *, const char *);
-extern ctf_file_t *ctf_parent_file (ctf_file_t *);
-extern const char *ctf_parent_name (ctf_file_t *);
-extern int 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 const char *ctf_cuname (ctf_dict_t *);
+extern int ctf_cuname_set (ctf_dict_t *, const char *);
+extern ctf_dict_t *ctf_parent_dict (ctf_dict_t *);
+extern const char *ctf_parent_name (ctf_dict_t *);
+extern int ctf_parent_name_set (ctf_dict_t *, const char *);
+extern int ctf_type_isparent (ctf_dict_t *, ctf_id_t);
+extern int ctf_type_ischild (ctf_dict_t *, ctf_id_t);
-extern int ctf_import (ctf_file_t *, ctf_file_t *);
-extern int ctf_setmodel (ctf_file_t *, int);
-extern int ctf_getmodel (ctf_file_t *);
+extern int ctf_import (ctf_dict_t *, ctf_dict_t *);
+extern int ctf_setmodel (ctf_dict_t *, int);
+extern int ctf_getmodel (ctf_dict_t *);
-extern void ctf_setspecific (ctf_file_t *, void *);
-extern void *ctf_getspecific (ctf_file_t *);
+extern void ctf_setspecific (ctf_dict_t *, void *);
+extern void *ctf_getspecific (ctf_dict_t *);
-extern int ctf_errno (ctf_file_t *);
+extern int ctf_errno (ctf_dict_t *);
extern const char *ctf_errmsg (int);
extern int ctf_version (int);
-extern int ctf_func_info (ctf_file_t *, unsigned long, ctf_funcinfo_t *);
-extern int ctf_func_args (ctf_file_t *, unsigned long, uint32_t, ctf_id_t *);
-extern int ctf_func_type_info (ctf_file_t *, ctf_id_t, ctf_funcinfo_t *);
-extern int ctf_func_type_args (ctf_file_t *, ctf_id_t, uint32_t, ctf_id_t *);
-
-extern ctf_id_t ctf_lookup_by_name (ctf_file_t *, const char *);
-extern ctf_id_t ctf_lookup_by_symbol (ctf_file_t *, unsigned long);
-extern ctf_id_t ctf_lookup_variable (ctf_file_t *, const char *);
-
-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 char *ctf_type_aname_raw (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 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 *);
-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 *,
+extern int ctf_func_info (ctf_dict_t *, unsigned long, ctf_funcinfo_t *);
+extern int ctf_func_args (ctf_dict_t *, unsigned long, uint32_t, ctf_id_t *);
+extern int ctf_func_type_info (ctf_dict_t *, ctf_id_t, ctf_funcinfo_t *);
+extern int ctf_func_type_args (ctf_dict_t *, ctf_id_t, uint32_t, ctf_id_t *);
+
+extern ctf_id_t ctf_lookup_by_name (ctf_dict_t *, const char *);
+extern ctf_id_t ctf_lookup_by_symbol (ctf_dict_t *, unsigned long);
+extern ctf_id_t ctf_lookup_variable (ctf_dict_t *, const char *);
+
+extern ctf_id_t ctf_type_resolve (ctf_dict_t *, ctf_id_t);
+extern char *ctf_type_aname (ctf_dict_t *, ctf_id_t);
+extern char *ctf_type_aname_raw (ctf_dict_t *, ctf_id_t);
+extern ssize_t ctf_type_lname (ctf_dict_t *, ctf_id_t, char *, size_t);
+extern char *ctf_type_name (ctf_dict_t *, ctf_id_t, char *, size_t);
+extern const char *ctf_type_name_raw (ctf_dict_t *, ctf_id_t);
+extern ssize_t ctf_type_size (ctf_dict_t *, ctf_id_t);
+extern ssize_t ctf_type_align (ctf_dict_t *, ctf_id_t);
+extern int ctf_type_kind (ctf_dict_t *, ctf_id_t);
+extern int ctf_type_kind_forwarded (ctf_dict_t *, ctf_id_t);
+extern ctf_id_t ctf_type_reference (ctf_dict_t *, ctf_id_t);
+extern ctf_id_t ctf_type_pointer (ctf_dict_t *, ctf_id_t);
+extern int ctf_type_encoding (ctf_dict_t *, ctf_id_t, ctf_encoding_t *);
+extern int ctf_type_visit (ctf_dict_t *, ctf_id_t, ctf_visit_f *, void *);
+extern int ctf_type_cmp (ctf_dict_t *, ctf_id_t, ctf_dict_t *, ctf_id_t);
+extern int ctf_type_compat (ctf_dict_t *, ctf_id_t, ctf_dict_t *, ctf_id_t);
+
+extern int ctf_member_info (ctf_dict_t *, ctf_id_t, const char *,
ctf_membinfo_t *);
-extern int ctf_array_info (ctf_file_t *, ctf_id_t, ctf_arinfo_t *);
+extern int ctf_array_info (ctf_dict_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 const char *ctf_enum_name (ctf_dict_t *, ctf_id_t, int);
+extern int ctf_enum_value (ctf_dict_t *, ctf_id_t, const char *, int *);
-extern void ctf_label_set (ctf_file_t *, const char *);
-extern const char *ctf_label_get (ctf_file_t *);
+extern void ctf_label_set (ctf_dict_t *, const char *);
+extern const char *ctf_label_get (ctf_dict_t *);
-extern const char *ctf_label_topmost (ctf_file_t *);
-extern int ctf_label_info (ctf_file_t *, const char *, ctf_lblinfo_t *);
+extern const char *ctf_label_topmost (ctf_dict_t *);
+extern int ctf_label_info (ctf_dict_t *, const char *, ctf_lblinfo_t *);
-extern int ctf_member_count (ctf_file_t *, ctf_id_t);
-extern int ctf_member_iter (ctf_file_t *, ctf_id_t, ctf_member_f *, void *);
-extern ssize_t ctf_member_next (ctf_file_t *, ctf_id_t, ctf_next_t **,
+extern int ctf_member_count (ctf_dict_t *, ctf_id_t);
+extern int ctf_member_iter (ctf_dict_t *, ctf_id_t, ctf_member_f *, void *);
+extern ssize_t ctf_member_next (ctf_dict_t *, ctf_id_t, ctf_next_t **,
const char **name, ctf_id_t *membtype);
-extern int ctf_enum_iter (ctf_file_t *, ctf_id_t, ctf_enum_f *, void *);
-extern const char *ctf_enum_next (ctf_file_t *, ctf_id_t, ctf_next_t **,
+extern int ctf_enum_iter (ctf_dict_t *, ctf_id_t, ctf_enum_f *, void *);
+extern const char *ctf_enum_next (ctf_dict_t *, ctf_id_t, ctf_next_t **,
int *);
-extern int ctf_type_iter (ctf_file_t *, ctf_type_f *, void *);
-extern int ctf_type_iter_all (ctf_file_t *, ctf_type_all_f *, void *);
-extern ctf_id_t ctf_type_next (ctf_file_t *, ctf_next_t **,
+extern int ctf_type_iter (ctf_dict_t *, ctf_type_f *, void *);
+extern int ctf_type_iter_all (ctf_dict_t *, ctf_type_all_f *, void *);
+extern ctf_id_t ctf_type_next (ctf_dict_t *, ctf_next_t **,
int *flag, int want_hidden);
-extern int ctf_label_iter (ctf_file_t *, ctf_label_f *, void *);
-extern int ctf_label_next (ctf_file_t *, ctf_next_t **, const char **); /* TBD */
-extern int ctf_variable_iter (ctf_file_t *, ctf_variable_f *, void *);
-extern ctf_id_t ctf_variable_next (ctf_file_t *, ctf_next_t **,
+extern int ctf_label_iter (ctf_dict_t *, ctf_label_f *, void *);
+extern int ctf_label_next (ctf_dict_t *, ctf_next_t **, const char **); /* TBD */
+extern int ctf_variable_iter (ctf_dict_t *, ctf_variable_f *, void *);
+extern ctf_id_t ctf_variable_next (ctf_dict_t *, ctf_next_t **,
const char **);
extern int ctf_archive_iter (const ctf_archive_t *, ctf_archive_member_f *,
void *);
-extern ctf_file_t *ctf_archive_next (const ctf_archive_t *, ctf_next_t **,
+extern ctf_dict_t *ctf_archive_next (const ctf_archive_t *, ctf_next_t **,
const char **, int skip_parent, int *errp);
/* This function alone does not currently operate on CTF files masquerading
to deal with non-archives at all. */
extern int ctf_archive_raw_iter (const ctf_archive_t *,
ctf_archive_raw_member_f *, void *);
-extern char *ctf_dump (ctf_file_t *, ctf_dump_state_t **state,
+extern char *ctf_dump (ctf_dict_t *, ctf_dump_state_t **state,
ctf_sect_names_t sect, ctf_dump_decorate_f *,
void *arg);
/* Error-warning reporting: an 'iterator' that returns errors and warnings from
the error/warning list, in order of emission. Errors and warnings are popped
after return: the caller must free the returned error-text pointer. */
-extern char *ctf_errwarning_next (ctf_file_t *, ctf_next_t **,
+extern char *ctf_errwarning_next (ctf_dict_t *, ctf_next_t **,
int *is_warning, int *errp);
-extern ctf_id_t ctf_add_array (ctf_file_t *, uint32_t,
+extern ctf_id_t ctf_add_array (ctf_dict_t *, uint32_t,
const ctf_arinfo_t *);
-extern ctf_id_t ctf_add_const (ctf_file_t *, uint32_t, ctf_id_t);
-extern ctf_id_t ctf_add_enum_encoded (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_const (ctf_dict_t *, uint32_t, ctf_id_t);
+extern ctf_id_t ctf_add_enum_encoded (ctf_dict_t *, uint32_t, const char *,
const ctf_encoding_t *);
-extern ctf_id_t ctf_add_enum (ctf_file_t *, uint32_t, const char *);
-extern ctf_id_t ctf_add_float (ctf_file_t *, uint32_t,
+extern ctf_id_t ctf_add_enum (ctf_dict_t *, uint32_t, const char *);
+extern ctf_id_t ctf_add_float (ctf_dict_t *, uint32_t,
const char *, const ctf_encoding_t *);
-extern ctf_id_t ctf_add_forward (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_forward (ctf_dict_t *, uint32_t, const char *,
uint32_t);
-extern ctf_id_t ctf_add_function (ctf_file_t *, uint32_t,
+extern ctf_id_t ctf_add_function (ctf_dict_t *, uint32_t,
const ctf_funcinfo_t *, const ctf_id_t *);
-extern ctf_id_t ctf_add_integer (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_integer (ctf_dict_t *, uint32_t, const char *,
const ctf_encoding_t *);
-extern ctf_id_t ctf_add_slice (ctf_file_t *, uint32_t, ctf_id_t, const ctf_encoding_t *);
-extern ctf_id_t ctf_add_pointer (ctf_file_t *, uint32_t, ctf_id_t);
-extern ctf_id_t ctf_add_type (ctf_file_t *, ctf_file_t *, ctf_id_t);
-extern ctf_id_t ctf_add_typedef (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_slice (ctf_dict_t *, uint32_t, ctf_id_t, const ctf_encoding_t *);
+extern ctf_id_t ctf_add_pointer (ctf_dict_t *, uint32_t, ctf_id_t);
+extern ctf_id_t ctf_add_type (ctf_dict_t *, ctf_dict_t *, ctf_id_t);
+extern ctf_id_t ctf_add_typedef (ctf_dict_t *, uint32_t, const char *,
ctf_id_t);
-extern ctf_id_t ctf_add_restrict (ctf_file_t *, uint32_t, ctf_id_t);
-extern ctf_id_t ctf_add_struct (ctf_file_t *, uint32_t, const char *);
-extern ctf_id_t ctf_add_union (ctf_file_t *, uint32_t, const char *);
-extern ctf_id_t ctf_add_struct_sized (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_restrict (ctf_dict_t *, uint32_t, ctf_id_t);
+extern ctf_id_t ctf_add_struct (ctf_dict_t *, uint32_t, const char *);
+extern ctf_id_t ctf_add_union (ctf_dict_t *, uint32_t, const char *);
+extern ctf_id_t ctf_add_struct_sized (ctf_dict_t *, uint32_t, const char *,
size_t);
-extern ctf_id_t ctf_add_union_sized (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_union_sized (ctf_dict_t *, uint32_t, const char *,
size_t);
-extern ctf_id_t ctf_add_volatile (ctf_file_t *, uint32_t, ctf_id_t);
+extern ctf_id_t ctf_add_volatile (ctf_dict_t *, uint32_t, ctf_id_t);
-extern int ctf_add_enumerator (ctf_file_t *, ctf_id_t, const char *, int);
-extern int ctf_add_member (ctf_file_t *, ctf_id_t, const char *, ctf_id_t);
-extern int ctf_add_member_offset (ctf_file_t *, ctf_id_t, const char *,
+extern int ctf_add_enumerator (ctf_dict_t *, ctf_id_t, const char *, int);
+extern int ctf_add_member (ctf_dict_t *, ctf_id_t, const char *, ctf_id_t);
+extern int ctf_add_member_offset (ctf_dict_t *, ctf_id_t, const char *,
ctf_id_t, unsigned long);
-extern int ctf_add_member_encoded (ctf_file_t *, ctf_id_t, const char *,
+extern int ctf_add_member_encoded (ctf_dict_t *, ctf_id_t, const char *,
ctf_id_t, unsigned long,
const ctf_encoding_t);
-extern int ctf_add_variable (ctf_file_t *, const char *, ctf_id_t);
+extern int ctf_add_variable (ctf_dict_t *, const char *, ctf_id_t);
-extern int ctf_set_array (ctf_file_t *, ctf_id_t, const ctf_arinfo_t *);
+extern int ctf_set_array (ctf_dict_t *, ctf_id_t, const ctf_arinfo_t *);
-extern ctf_file_t *ctf_create (int *);
-extern int ctf_update (ctf_file_t *);
-extern ctf_snapshot_id_t ctf_snapshot (ctf_file_t *);
-extern int ctf_rollback (ctf_file_t *, ctf_snapshot_id_t);
-extern int ctf_discard (ctf_file_t *);
-extern int ctf_write (ctf_file_t *, int);
-extern int ctf_gzwrite (ctf_file_t *fp, gzFile fd);
-extern int ctf_compress_write (ctf_file_t * fp, int fd);
-extern unsigned char *ctf_write_mem (ctf_file_t *, size_t *, size_t threshold);
+extern ctf_dict_t *ctf_create (int *);
+extern int ctf_update (ctf_dict_t *);
+extern ctf_snapshot_id_t ctf_snapshot (ctf_dict_t *);
+extern int ctf_rollback (ctf_dict_t *, ctf_snapshot_id_t);
+extern int ctf_discard (ctf_dict_t *);
+extern int ctf_write (ctf_dict_t *, int);
+extern int ctf_gzwrite (ctf_dict_t *fp, gzFile fd);
+extern int ctf_compress_write (ctf_dict_t * fp, int fd);
+extern unsigned char *ctf_write_mem (ctf_dict_t *, size_t *, size_t threshold);
-extern int ctf_link_add_ctf (ctf_file_t *, ctf_archive_t *, const char *);
+extern int ctf_link_add_ctf (ctf_dict_t *, ctf_archive_t *, const char *);
/* The variable filter should return nonzero if a variable should not
appear in the output. */
-typedef int ctf_link_variable_filter_f (ctf_file_t *, const char *, ctf_id_t,
+typedef int ctf_link_variable_filter_f (ctf_dict_t *, const char *, ctf_id_t,
void *);
-extern int ctf_link_set_variable_filter (ctf_file_t *,
+extern int ctf_link_set_variable_filter (ctf_dict_t *,
ctf_link_variable_filter_f *, void *);
-extern int ctf_link (ctf_file_t *, int flags);
+extern int ctf_link (ctf_dict_t *, int flags);
typedef const char *ctf_link_strtab_string_f (uint32_t *offset, void *arg);
-extern int ctf_link_add_strtab (ctf_file_t *, ctf_link_strtab_string_f *,
+extern int ctf_link_add_strtab (ctf_dict_t *, ctf_link_strtab_string_f *,
void *);
typedef ctf_link_sym_t *ctf_link_iter_symbol_f (ctf_link_sym_t *dest,
void *arg);
-extern int ctf_link_shuffle_syms (ctf_file_t *, ctf_link_iter_symbol_f *,
+extern int ctf_link_shuffle_syms (ctf_dict_t *, ctf_link_iter_symbol_f *,
void *);
-extern unsigned char *ctf_link_write (ctf_file_t *, size_t *size,
+extern unsigned char *ctf_link_write (ctf_dict_t *, size_t *size,
size_t threshold);
/* Specialist linker functions. These functions are not used by ld, but can be
used by other programs making use of the linker machinery for other purposes
to customize its output. */
-extern int ctf_link_add_cu_mapping (ctf_file_t *, const char *from,
+extern int ctf_link_add_cu_mapping (ctf_dict_t *, const char *from,
const char *to);
-typedef char *ctf_link_memb_name_changer_f (ctf_file_t *,
+typedef char *ctf_link_memb_name_changer_f (ctf_dict_t *,
const char *, void *);
extern void ctf_link_set_memb_name_changer
- (ctf_file_t *, ctf_link_memb_name_changer_f *, void *);
+ (ctf_dict_t *, ctf_link_memb_name_changer_f *, void *);
extern void ctf_setdebug (int debug);
extern int ctf_getdebug (void);
+/* Deprecated aliases for existing functions and types. */
+
+struct ctf_file;
+typedef struct ctf_dict ctf_file_t;
+extern void ctf_file_close (ctf_file_t *);
+extern ctf_dict_t *ctf_parent_file (ctf_dict_t *);
+
#ifdef __cplusplus
}
#endif
int32_t cte_value; /* Value associated with this name. */
} ctf_enum_t;
-/* The ctf_archive is a collection of ctf_file_t's stored together. The format
+/* The ctf_archive is a collection of ctf_dict_t's stored together. The format
is suitable for mmap()ing: this control structure merely describes the
mmap()ed archive (and overlaps the first few bytes of it), hence the
greater care taken with integral types. All CTF files in an archive
/* CTF data model. */
uint64_t ctfa_model;
- /* Number of CTF files in the archive. */
- uint64_t ctfa_nfiles;
+ /* Number of CTF dicts in the archive. */
+ uint64_t ctfa_ndicts;
/* Offset of the name table. */
uint64_t ctfa_names;
/* Offset of the CTF table. Each element starts with a size (a uint64_t
- in network byte order) then a ctf_file_t of that size. */
+ in network byte order) then a ctf_dict_t of that size. */
uint64_t ctfa_ctfs;
};
/* An array of ctfa_nnamed of this structure lies at
ctf_archive[ctf_archive->ctfa_modents] and gives the ctfa_ctfs or
- ctfa_names-relative offsets of each name or ctf_file_t. */
+ ctfa_names-relative offsets of each name or ctf_dict_t. */
typedef struct ctf_archive_modent
{
+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.
+
2020-11-20 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* testsuite/ld-elf/retain3.s: Move symbolic reference into writeable
void
ldelf_examine_strtab_for_ctf
- (struct ctf_file *ctf_output, struct elf_sym_strtab *syms,
+ (struct ctf_dict *ctf_output, struct elf_sym_strtab *syms,
bfd_size_type symcount, struct elf_strtab_hash *symstrtab)
{
struct ctf_strsym_iter_cb_arg args = { syms, symcount, symstrtab,
}
extern void ldelf_examine_strtab_for_ctf
- (struct ctf_file *ctf_output ATTRIBUTE_UNUSED,
+ (struct ctf_dict *ctf_output ATTRIBUTE_UNUSED,
struct elf_sym_strtab *syms ATTRIBUTE_UNUSED,
bfd_size_type symcount ATTRIBUTE_UNUSED,
struct elf_strtab_hash *symstrtab ATTRIBUTE_UNUSED)
struct elf_sym_strtab;
struct elf_strtab_hash;
-struct ctf_file;
+struct ctf_dict;
extern void ldelf_map_segments (bfd_boolean);
extern int ldelf_emit_ctf_early (void);
extern void ldelf_examine_strtab_for_ctf
- (struct ctf_file *ctf_output, struct elf_sym_strtab *syms,
+ (struct ctf_dict *ctf_output, struct elf_sym_strtab *syms,
bfd_size_type symcount, struct elf_strtab_hash *symstrtab);
}
void
-ldemul_examine_strtab_for_ctf (struct ctf_file *ctf_output,
+ldemul_examine_strtab_for_ctf (struct ctf_dict *ctf_output,
struct elf_sym_strtab *syms,
bfd_size_type symcount,
struct elf_strtab_hash *symstrtab)
(void);
/* Called from per-target code to examine the strtab and symtab. */
extern void ldemul_examine_strtab_for_ctf
- (struct ctf_file *, struct elf_sym_strtab *, bfd_size_type,
+ (struct ctf_dict *, struct elf_sym_strtab *, bfd_size_type,
struct elf_strtab_hash *);
extern bfd_boolean ldemul_print_symbol
(struct bfd_link_hash_entry *hash_entry, void *ptr);
waits until 'late'. (Late mode needs explicit support at per-target link
time to get called at all). If set, called by ld when the examine_strtab
bfd_link_callback is invoked by per-target code. */
- void (*examine_strtab_for_ctf) (struct ctf_file *, struct elf_sym_strtab *,
+ void (*examine_strtab_for_ctf) (struct ctf_dict *, struct elf_sym_strtab *,
bfd_size_type, struct elf_strtab_hash *);
/* Called when printing a symbol to the map file. AIX uses this
struct lang_nocrossrefs *nocrossref_list;
struct asneeded_minfo **asneeded_list_tail;
#ifdef ENABLE_LIBCTF
-static ctf_file_t *ctf_output;
+static ctf_dict_t *ctf_output;
#endif
/* Functions that traverse the linker script and might evaluate
/* Emit CTF errors and warnings. fp can be NULL to report errors/warnings
that happened specifically at CTF open time. */
static void
-lang_ctf_errs_warnings (ctf_file_t *fp)
+lang_ctf_errs_warnings (ctf_dict_t *fp)
{
ctf_next_t *i = NULL;
char *text;
{
asection *sect;
- /* Incoming files from the compiler have a single ctf_file_t in them
+ /* Incoming files from the compiler have a single ctf_dict_t in them
(which is presented to us by the libctf API in a ctf_archive_t
wrapper): files derived from a previous relocatable link have a CTF
archive containing possibly many CTF files. */
/* If the section was discarded, don't waste time merging. */
if (output_sect == NULL)
{
- ctf_file_close (ctf_output);
+ ctf_dict_close (ctf_output);
ctf_output = NULL;
LANG_FOR_EACH_INPUT_STATEMENT (file)
}
/* This also closes every CTF input file used in the link. */
- ctf_file_close (ctf_output);
+ ctf_dict_close (ctf_output);
ctf_output = NULL;
LANG_FOR_EACH_INPUT_STATEMENT (file)
+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.
+
2020-10-21 Tom Tromey <tromey@adacore.com>
* mkerrors.sed: Remove.
#include <sys/mman.h>
#endif
-static off_t arc_write_one_ctf (ctf_file_t * f, int fd, size_t threshold);
-static ctf_file_t *ctf_arc_open_by_offset (const struct ctf_archive *arc,
+static off_t arc_write_one_ctf (ctf_dict_t * f, int fd, size_t threshold);
+static ctf_dict_t *ctf_arc_open_by_offset (const struct ctf_archive *arc,
const ctf_sect_t *symsect,
const ctf_sect_t *strsect,
size_t offset, int *errp);
static int arc_mmap_unmap (void *header, size_t headersz, const char **errmsg);
/* Write out a CTF archive to the start of the file referenced by the passed-in
- fd. The entries in CTF_FILES are referenced by name: the names are passed in
- the names array, which must have CTF_FILES entries.
+ fd. The entries in CTF_DICTS are referenced by name: the names are passed in
+ the names array, which must have CTF_DICTS entries.
Returns 0 on success, or an errno, or an ECTF_* value. */
int
-ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
+ctf_arc_write_fd (int fd, ctf_dict_t **ctf_dicts, size_t ctf_dict_cnt,
const char **names, size_t threshold)
{
const char *errmsg;
struct ctf_archive_modent *modent;
ctf_dprintf ("Writing CTF archive with %lu files\n",
- (unsigned long) ctf_file_cnt);
+ (unsigned long) ctf_dict_cnt);
/* Figure out the size of the mmap()ed header, including the
ctf_archive_modent array. We assume that all of this needs no
padding: a likely assumption, given that it's all made up of
uint64_t's. */
headersz = sizeof (struct ctf_archive)
- + (ctf_file_cnt * sizeof (uint64_t) * 2);
+ + (ctf_dict_cnt * sizeof (uint64_t) * 2);
ctf_dprintf ("headersz is %lu\n", (unsigned long) headersz);
/* From now on we work in two pieces: an mmap()ed region from zero up to the
/* Fill in everything we can, which is everything other than the name
table offset. */
archdr->ctfa_magic = htole64 (CTFA_MAGIC);
- archdr->ctfa_nfiles = htole64 (ctf_file_cnt);
+ archdr->ctfa_ndicts = htole64 (ctf_dict_cnt);
archdr->ctfa_ctfs = htole64 (ctf_startoffs);
/* We could validate that all CTF files have the same data model, but
this case, but we must be sure not to dereference uninitialized
memory.) */
- if (ctf_file_cnt > 0)
- archdr->ctfa_model = htole64 (ctf_getmodel (ctf_files[0]));
+ if (ctf_dict_cnt > 0)
+ archdr->ctfa_model = htole64 (ctf_getmodel (ctf_dicts[0]));
/* Now write out the CTFs: ctf_archive_modent array via the mapping,
ctfs via write(). The names themselves have not been written yet: we
The name table is not sorted. */
- for (i = 0, namesz = 0; i < le64toh (archdr->ctfa_nfiles); i++)
+ for (i = 0, namesz = 0; i < le64toh (archdr->ctfa_ndicts); i++)
namesz += strlen (names[i]) + 1;
nametbl = malloc (namesz);
for (i = 0, namesz = 0,
modent = (ctf_archive_modent_t *) ((char *) archdr
+ sizeof (struct ctf_archive));
- i < le64toh (archdr->ctfa_nfiles); i++)
+ i < le64toh (archdr->ctfa_ndicts); i++)
{
off_t off;
strcpy (&nametbl[namesz], names[i]);
- off = arc_write_one_ctf (ctf_files[i], fd, threshold);
+ off = arc_write_one_ctf (ctf_dicts[i], fd, threshold);
if ((off < 0) && (off > -ECTF_BASE))
{
errmsg = N_("ctf_arc_write(): cannot determine file "
ctf_qsort_r ((ctf_archive_modent_t *) ((char *) archdr
+ sizeof (struct ctf_archive)),
- le64toh (archdr->ctfa_nfiles),
+ le64toh (archdr->ctfa_ndicts),
sizeof (struct ctf_archive_modent), sort_modent_by_name,
nametbl);
/* We report errors into the first file in the archive, if any: if this is a
zero-file archive, put it in the open-errors stream for lack of anywhere
else for it to go. */
- ctf_err_warn (ctf_file_cnt > 0 ? ctf_files[0] : NULL, 0, errno, "%s",
+ ctf_err_warn (ctf_dict_cnt > 0 ? ctf_dicts[0] : NULL, 0, errno, "%s",
gettext (errmsg));
return errno;
}
-/* Write out a CTF archive. The entries in CTF_FILES are referenced by name:
- the names are passed in the names array, which must have CTF_FILES entries.
+/* Write out a CTF archive. The entries in CTF_DICTS are referenced by name:
+ the names are passed in the names array, which must have CTF_DICTS entries.
If the filename is NULL, create a temporary file and return a pointer to it.
Returns 0 on success, or an errno, or an ECTF_* value. */
int
-ctf_arc_write (const char *file, ctf_file_t **ctf_files, size_t ctf_file_cnt,
+ctf_arc_write (const char *file, ctf_dict_t **ctf_dicts, size_t ctf_dict_cnt,
const char **names, size_t threshold)
{
int err;
if ((fd = open (file, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0666)) < 0)
{
- ctf_err_warn (ctf_file_cnt > 0 ? ctf_files[0] : NULL, 0, errno,
+ ctf_err_warn (ctf_dict_cnt > 0 ? ctf_dicts[0] : NULL, 0, errno,
_("ctf_arc_write(): cannot create %s"), file);
return errno;
}
- err = ctf_arc_write_fd (fd, ctf_files, ctf_file_cnt, names, threshold);
+ err = ctf_arc_write_fd (fd, ctf_dicts, ctf_dict_cnt, names, threshold);
if (err)
goto err_close;
if ((err = close (fd)) < 0)
- ctf_err_warn (ctf_file_cnt > 0 ? ctf_files[0] : NULL, 0, errno,
+ ctf_err_warn (ctf_dict_cnt > 0 ? ctf_dicts[0] : NULL, 0, errno,
_("ctf_arc_write(): cannot close after writing to archive"));
goto err;
negative errno or ctf_errno value. On error, the file position may no longer
be at the end of the file. */
static off_t
-arc_write_one_ctf (ctf_file_t * f, int fd, size_t threshold)
+arc_write_one_ctf (ctf_dict_t * f, int fd, size_t threshold)
{
off_t off, end_off;
uint64_t ctfsz = 0;
char *ctfszp;
size_t ctfsz_len;
- int (*writefn) (ctf_file_t * fp, int fd);
+ int (*writefn) (ctf_dict_t * fp, int fd);
if (ctf_serialize (f) < 0)
return f->ctf_errno * -1;
}
/* Make a new struct ctf_archive_internal wrapper for a ctf_archive or a
- ctf_file. Closes ARC and/or FP on error. Arrange to free the SYMSECT or
+ ctf_dict. Closes ARC and/or FP on error. Arrange to free the SYMSECT or
STRSECT, as needed, on close. Possibly do not unmap on close. */
struct ctf_archive_internal *
ctf_new_archive_internal (int is_archive, int unmap_on_close,
struct ctf_archive *arc,
- ctf_file_t *fp, const ctf_sect_t *symsect,
+ ctf_dict_t *fp, const ctf_sect_t *symsect,
const ctf_sect_t *strsect,
int *errp)
{
ctf_arc_close_internal (arc);
}
else
- ctf_file_close (fp);
+ ctf_dict_close (fp);
return (ctf_set_open_errno (errp, errno));
}
arci->ctfi_is_archive = is_archive;
if (is_archive)
arci->ctfi_archive = arc;
else
- arci->ctfi_file = fp;
+ arci->ctfi_dict = fp;
if (symsect)
memcpy (&arci->ctfi_symsect, symsect, sizeof (struct ctf_sect));
if (strsect)
{
struct ctf_archive *arc = NULL;
int is_archive;
- ctf_file_t *fp = NULL;
+ ctf_dict_t *fp = NULL;
if (ctfsect->cts_size > sizeof (uint64_t) &&
(le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
ctf_arc_close_internal (arc->ctfi_archive);
}
else
- ctf_file_close (arc->ctfi_file);
+ ctf_dict_close (arc->ctfi_dict);
if (arc->ctfi_free_symsect)
free ((void *) arc->ctfi_symsect.cts_data);
if (arc->ctfi_free_strsect)
free (arc);
}
-/* Return the ctf_file_t with the given name, or NULL if none, setting 'err' if
+/* Return the ctf_dict_t with the given name, or NULL if none, setting 'err' if
non-NULL. A name of NULL means to open the default file. */
-static ctf_file_t *
+static ctf_dict_t *
ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
const ctf_sect_t *symsect,
const ctf_sect_t *strsect,
+ sizeof (struct ctf_archive));
search_nametbl = (const char *) arc + le64toh (arc->ctfa_names);
- modent = bsearch_r (name, modent, le64toh (arc->ctfa_nfiles),
+ modent = bsearch_r (name, modent, le64toh (arc->ctfa_ndicts),
sizeof (struct ctf_archive_modent),
search_modent_by_name, (void *) search_nametbl);
le64toh (modent->ctf_offset), errp);
}
-/* Return the ctf_file_t with the given name, or NULL if none, setting 'err' if
+/* Return the ctf_dict_t with the given name, or NULL if none, setting 'err' if
non-NULL. A name of NULL means to open the default file.
Use the specified string and symbol table sections.
Public entry point. */
-ctf_file_t *
+ctf_dict_t *
ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
const ctf_sect_t *symsect,
const ctf_sect_t *strsect,
{
if (arc->ctfi_is_archive)
{
- ctf_file_t *ret;
+ ctf_dict_t *ret;
ret = ctf_arc_open_by_name_internal (arc->ctfi_archive, symsect, strsect,
name, errp);
if (ret)
*errp = ECTF_ARNNAME;
return NULL;
}
- arc->ctfi_file->ctf_archive = (ctf_archive_t *) arc;
+ arc->ctfi_dict->ctf_archive = (ctf_archive_t *) arc;
- /* Bump the refcount so that the user can ctf_file_close() it. */
- arc->ctfi_file->ctf_refcnt++;
- return arc->ctfi_file;
+ /* Bump the refcount so that the user can ctf_dict_close() it. */
+ arc->ctfi_dict->ctf_refcnt++;
+ return arc->ctfi_dict;
}
-/* Return the ctf_file_t with the given name, or NULL if none, setting 'err' if
+/* Return the ctf_dict_t with the given name, or NULL if none, setting 'err' if
non-NULL. A name of NULL means to open the default file.
Public entry point. */
-ctf_file_t *
+ctf_dict_t *
ctf_arc_open_by_name (const ctf_archive_t *arc, const char *name, int *errp)
{
const ctf_sect_t *symsect = &arc->ctfi_symsect;
return ctf_arc_open_by_name_sections (arc, symsect, strsect, name, errp);
}
-/* Return the ctf_file_t at the given ctfa_ctfs-relative offset, or NULL if
+/* Return the ctf_dict_t at the given ctfa_ctfs-relative offset, or NULL if
none, setting 'err' if non-NULL. */
-static ctf_file_t *
+static ctf_dict_t *
ctf_arc_open_by_offset (const struct ctf_archive *arc,
const ctf_sect_t *symsect,
const ctf_sect_t *strsect, size_t offset,
int *errp)
{
ctf_sect_t ctfsect;
- ctf_file_t *fp;
+ ctf_dict_t *fp;
ctf_dprintf ("ctf_arc_open_by_offset(%lu): opening\n", (unsigned long) offset);
if (!wrapper->ctfi_is_archive)
return 1;
- return wrapper->ctfi_archive->ctfa_nfiles;
+ return wrapper->ctfi_archive->ctfa_ndicts;
}
/* Raw iteration over all CTF files in an archive. We pass the raw data for all
+ sizeof (struct ctf_archive));
nametbl = (((const char *) arc) + le64toh (arc->ctfa_names));
- for (i = 0; i < le64toh (arc->ctfa_nfiles); i++)
+ for (i = 0; i < le64toh (arc->ctfa_ndicts); i++)
{
const char *name;
char *fp;
{
int rc;
size_t i;
- ctf_file_t *f;
+ ctf_dict_t *f;
struct ctf_archive_modent *modent;
const char *nametbl;
+ sizeof (struct ctf_archive));
nametbl = (((const char *) arc) + le64toh (arc->ctfa_names));
- for (i = 0; i < le64toh (arc->ctfa_nfiles); i++)
+ for (i = 0; i < le64toh (arc->ctfa_ndicts); i++)
{
const char *name;
f->ctf_archive = (ctf_archive_t *) wrapper;
if ((rc = func (f, name, data)) != 0)
{
- ctf_file_close (f);
+ ctf_dict_close (f);
return rc;
}
- ctf_file_close (f);
+ ctf_dict_close (f);
}
return 0;
}
return ctf_archive_iter_internal (arc, arc->ctfi_archive, symsect, strsect,
func, data);
- return func (arc->ctfi_file, _CTF_SECTION, data);
+ return func (arc->ctfi_dict, _CTF_SECTION, data);
}
/* Iterate over all CTF files in an archive, returning each dict in turn as a
- ctf_file_t, and NULL on error or end of iteration. It is the caller's
+ ctf_dict_t, and NULL on error or end of iteration. It is the caller's
responsibility to close it. Parent dicts may be skipped. Regardless of
whether they are skipped or not, the caller must ctf_import the parent if
need be.
We identify parents by name rather than by flag value: for now, with the
linker only emitting parents named _CTF_SECTION, this works well enough. */
-ctf_file_t *
+ctf_dict_t *
ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **name,
int skip_parent, int *errp)
{
- ctf_file_t *f;
+ ctf_dict_t *f;
ctf_next_t *i = *it;
struct ctf_archive *arc;
struct ctf_archive_modent *modent;
return NULL;
}
- /* Iteration is made a bit more complex by the need to handle ctf_file_t's
+ /* Iteration is made a bit more complex by the need to handle ctf_dict_t's
transparently wrapped in a single-member archive. These are parents: if
skip_parent is on, they are skipped and the iterator terminates
immediately. */
i->ctn_n++;
if (!skip_parent)
{
- wrapper->ctfi_file->ctf_refcnt++;
- return wrapper->ctfi_file;
+ wrapper->ctfi_dict->ctf_refcnt++;
+ return wrapper->ctfi_dict;
}
}
do
{
- if ((!wrapper->ctfi_is_archive) || (i->ctn_n >= le64toh (arc->ctfa_nfiles)))
+ if ((!wrapper->ctfi_is_archive) || (i->ctn_n >= le64toh (arc->ctfa_ndicts)))
{
ctf_next_destroy (i);
*it = NULL;
at a time. */
static int
-ctf_grow_ptrtab (ctf_file_t *fp)
+ctf_grow_ptrtab (ctf_dict_t *fp)
{
size_t new_ptrtab_len = fp->ctf_ptrtab_len;
return 0;
}
-/* To create an empty CTF container, we just declare a zeroed header and call
- ctf_bufopen() on it. If ctf_bufopen succeeds, we mark the new container r/w
- and initialize the dynamic members. We start assigning type IDs at 1 because
+/* To create an empty CTF dict, we just declare a zeroed header and call
+ ctf_bufopen() on it. If ctf_bufopen succeeds, we mark the new dict r/w and
+ initialize the dynamic members. We start assigning type IDs at 1 because
type ID 0 is used as a sentinel and a not-found indicator. */
-ctf_file_t *
+ctf_dict_t *
ctf_create (int *errp)
{
static const ctf_header_t hdr = { .cth_preamble = { CTF_MAGIC, CTF_VERSION, 0 } };
ctf_dynhash_t *dvhash;
ctf_dynhash_t *structs = NULL, *unions = NULL, *enums = NULL, *names = NULL;
ctf_sect_t cts;
- ctf_file_t *fp;
+ ctf_dict_t *fp;
libctf_init_debug();
dthash = ctf_dynhash_create (ctf_hash_integer, ctf_hash_eq_integer,
if (ctf_grow_ptrtab (fp) < 0)
{
ctf_set_open_errno (errp, ctf_errno (fp));
- ctf_file_close (fp);
+ ctf_dict_close (fp);
return NULL;
}
}
static unsigned char *
-ctf_copy_smembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
+ctf_copy_smembers (ctf_dict_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
{
ctf_dmdef_t *dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
ctf_member_t ctm;
}
static unsigned char *
-ctf_copy_lmembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
+ctf_copy_lmembers (ctf_dict_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
{
ctf_dmdef_t *dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
ctf_lmember_t ctlm;
}
static unsigned char *
-ctf_copy_emembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
+ctf_copy_emembers (ctf_dict_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
{
ctf_dmdef_t *dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
ctf_enum_t cte;
typedef struct ctf_sort_var_arg_cb
{
- ctf_file_t *fp;
+ ctf_dict_t *fp;
ctf_strs_t *strtab;
} ctf_sort_var_arg_cb_t;
/* Compatibility: just update the threshold for ctf_discard. */
int
-ctf_update (ctf_file_t *fp)
+ctf_update (ctf_dict_t *fp)
{
if (!(fp->ctf_flags & LCTF_RDWR))
return (ctf_set_errno (fp, ECTF_RDONLY));
return 0;
}
-/* If the specified CTF container is writable and has been modified, reload this
- container with the updated type definitions, ready for serialization. In
- order to make this code and the rest of libctf as simple as possible, we
- perform updates by taking the dynamic type definitions and creating an
- in-memory CTF file containing the definitions, and then call
- ctf_simple_open_internal() on it. We perform one extra trick here for the
- benefit of callers and to keep our code simple: ctf_simple_open_internal()
- will return a new ctf_file_t, but we want to keep the fp constant for the
- caller, so after ctf_simple_open_internal() returns, we use memcpy to swap
- the interior of the old and new ctf_file_t's, and then free the old. */
+/* If the specified CTF dict is writable and has been modified, reload this dict
+ with the updated type definitions, ready for serialization. In order to make
+ this code and the rest of libctf as simple as possible, we perform updates by
+ taking the dynamic type definitions and creating an in-memory CTF dict
+ containing the definitions, and then call ctf_simple_open_internal() on it.
+ We perform one extra trick here for the benefit of callers and to keep our
+ code simple: ctf_simple_open_internal() will return a new ctf_dict_t, but we
+ want to keep the fp constant for the caller, so after
+ ctf_simple_open_internal() returns, we use memcpy to swap the interior of the
+ old and new ctf_dict_t's, and then free the old. */
int
-ctf_serialize (ctf_file_t *fp)
+ctf_serialize (ctf_dict_t *fp)
{
- ctf_file_t ofp, *nfp;
+ ctf_dict_t ofp, *nfp;
ctf_header_t hdr, *hdrp;
ctf_dtdef_t *dtd;
ctf_dvdef_t *dvd;
buf_size += hdrp->cth_strlen;
free (strtab.cts_strs);
- /* Finally, we are ready to ctf_simple_open() the new container. If this
- is successful, we then switch nfp and fp and free the old container. */
+ /* Finally, we are ready to ctf_simple_open() the new dict. If this is
+ successful, we then switch nfp and fp and free the old dict. */
if ((nfp = ctf_simple_open_internal ((char *) buf, buf_size, NULL, 0,
0, NULL, 0, fp->ctf_syn_ext_strtab,
fp->ctf_enums.ctn_writable = NULL;
fp->ctf_names.ctn_writable = NULL;
- memcpy (&ofp, fp, sizeof (ctf_file_t));
- memcpy (fp, nfp, sizeof (ctf_file_t));
- memcpy (nfp, &ofp, sizeof (ctf_file_t));
+ memcpy (&ofp, fp, sizeof (ctf_dict_t));
+ memcpy (fp, nfp, sizeof (ctf_dict_t));
+ memcpy (nfp, &ofp, sizeof (ctf_dict_t));
nfp->ctf_refcnt = 1; /* Force nfp to be freed. */
- ctf_file_close (nfp);
+ ctf_dict_close (nfp);
return 0;
}
ctf_names_t *
-ctf_name_table (ctf_file_t *fp, int kind)
+ctf_name_table (ctf_dict_t *fp, int kind)
{
switch (kind)
{
}
int
-ctf_dtd_insert (ctf_file_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
+ctf_dtd_insert (ctf_dict_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
{
const char *name;
if (ctf_dynhash_insert (fp->ctf_dthash, (void *) (uintptr_t) dtd->dtd_type,
}
void
-ctf_dtd_delete (ctf_file_t *fp, ctf_dtdef_t *dtd)
+ctf_dtd_delete (ctf_dict_t *fp, ctf_dtdef_t *dtd)
{
ctf_dmdef_t *dmd, *nmd;
int kind = LCTF_INFO_KIND (fp, dtd->dtd_data.ctt_info);
}
ctf_dtdef_t *
-ctf_dtd_lookup (const ctf_file_t *fp, ctf_id_t type)
+ctf_dtd_lookup (const ctf_dict_t *fp, ctf_id_t type)
{
return (ctf_dtdef_t *)
ctf_dynhash_lookup (fp->ctf_dthash, (void *) (uintptr_t) type);
}
ctf_dtdef_t *
-ctf_dynamic_type (const ctf_file_t *fp, ctf_id_t id)
+ctf_dynamic_type (const ctf_dict_t *fp, ctf_id_t id)
{
ctf_id_t idx;
}
int
-ctf_dvd_insert (ctf_file_t *fp, ctf_dvdef_t *dvd)
+ctf_dvd_insert (ctf_dict_t *fp, ctf_dvdef_t *dvd)
{
if (ctf_dynhash_insert (fp->ctf_dvhash, dvd->dvd_name, dvd) < 0)
return -1;
}
void
-ctf_dvd_delete (ctf_file_t *fp, ctf_dvdef_t *dvd)
+ctf_dvd_delete (ctf_dict_t *fp, ctf_dvdef_t *dvd)
{
ctf_dynhash_remove (fp->ctf_dvhash, dvd->dvd_name);
free (dvd->dvd_name);
}
ctf_dvdef_t *
-ctf_dvd_lookup (const ctf_file_t *fp, const char *name)
+ctf_dvd_lookup (const ctf_dict_t *fp, const char *name)
{
return (ctf_dvdef_t *) ctf_dynhash_lookup (fp->ctf_dvhash, name);
}
/* Discard all of the dynamic type definitions and variable definitions that
- have been added to the container since the last call to ctf_update(). We
- locate such types by scanning the dtd list and deleting elements that have
- type IDs greater than ctf_dtoldid, which is set by ctf_update(), above, and
- by scanning the variable list and deleting elements that have update IDs
- equal to the current value of the last-update snapshot count (indicating that
- they were added after the most recent call to ctf_update()). */
+ have been added to the dict since the last call to ctf_update(). We locate
+ such types by scanning the dtd list and deleting elements that have type IDs
+ greater than ctf_dtoldid, which is set by ctf_update(), above, and by
+ scanning the variable list and deleting elements that have update IDs equal
+ to the current value of the last-update snapshot count (indicating that they
+ were added after the most recent call to ctf_update()). */
int
-ctf_discard (ctf_file_t *fp)
+ctf_discard (ctf_dict_t *fp)
{
ctf_snapshot_id_t last_update =
{ fp->ctf_dtoldid,
}
ctf_snapshot_id_t
-ctf_snapshot (ctf_file_t *fp)
+ctf_snapshot (ctf_dict_t *fp)
{
ctf_snapshot_id_t snapid;
snapid.dtd_id = fp->ctf_typemax;
/* Like ctf_discard(), only discards everything after a particular ID. */
int
-ctf_rollback (ctf_file_t *fp, ctf_snapshot_id_t id)
+ctf_rollback (ctf_dict_t *fp, ctf_snapshot_id_t id)
{
ctf_dtdef_t *dtd, *ntd;
ctf_dvdef_t *dvd, *nvd;
}
static ctf_id_t
-ctf_add_generic (ctf_file_t *fp, uint32_t flag, const char *name, int kind,
+ctf_add_generic (ctf_dict_t *fp, uint32_t flag, const char *name, int kind,
ctf_dtdef_t **rp)
{
ctf_dtdef_t *dtd;
}
ctf_id_t
-ctf_add_encoded (ctf_file_t *fp, uint32_t flag,
+ctf_add_encoded (ctf_dict_t *fp, uint32_t flag,
const char *name, const ctf_encoding_t *ep, uint32_t kind)
{
ctf_dtdef_t *dtd;
}
ctf_id_t
-ctf_add_reftype (ctf_file_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind)
+ctf_add_reftype (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
int child = fp->ctf_flags & LCTF_CHILD;
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
}
ctf_id_t
-ctf_add_slice (ctf_file_t *fp, uint32_t flag, ctf_id_t ref,
+ctf_add_slice (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref,
const ctf_encoding_t *ep)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
int kind;
const ctf_type_t *tp;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
if (ep == NULL)
return (ctf_set_errno (fp, EINVAL));
}
ctf_id_t
-ctf_add_integer (ctf_file_t *fp, uint32_t flag,
+ctf_add_integer (ctf_dict_t *fp, uint32_t flag,
const char *name, const ctf_encoding_t *ep)
{
return (ctf_add_encoded (fp, flag, name, ep, CTF_K_INTEGER));
}
ctf_id_t
-ctf_add_float (ctf_file_t *fp, uint32_t flag,
+ctf_add_float (ctf_dict_t *fp, uint32_t flag,
const char *name, const ctf_encoding_t *ep)
{
return (ctf_add_encoded (fp, flag, name, ep, CTF_K_FLOAT));
}
ctf_id_t
-ctf_add_pointer (ctf_file_t *fp, uint32_t flag, ctf_id_t ref)
+ctf_add_pointer (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref)
{
return (ctf_add_reftype (fp, flag, ref, CTF_K_POINTER));
}
ctf_id_t
-ctf_add_array (ctf_file_t *fp, uint32_t flag, const ctf_arinfo_t *arp)
+ctf_add_array (ctf_dict_t *fp, uint32_t flag, const ctf_arinfo_t *arp)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
if (arp == NULL)
return (ctf_set_errno (fp, EINVAL));
}
int
-ctf_set_array (ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
+ctf_set_array (ctf_dict_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
{
ctf_dtdef_t *dtd = ctf_dtd_lookup (fp, type);
}
ctf_id_t
-ctf_add_function (ctf_file_t *fp, uint32_t flag,
+ctf_add_function (ctf_dict_t *fp, uint32_t flag,
const ctf_funcinfo_t *ctc, const ctf_id_t *argv)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
uint32_t vlen;
uint32_t *vdat = NULL;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
size_t i;
if (ctc == NULL || (ctc->ctc_flags & ~CTF_FUNC_VARARG) != 0
}
ctf_id_t
-ctf_add_struct_sized (ctf_file_t *fp, uint32_t flag, const char *name,
+ctf_add_struct_sized (ctf_dict_t *fp, uint32_t flag, const char *name,
size_t size)
{
ctf_dtdef_t *dtd;
}
ctf_id_t
-ctf_add_struct (ctf_file_t *fp, uint32_t flag, const char *name)
+ctf_add_struct (ctf_dict_t *fp, uint32_t flag, const char *name)
{
return (ctf_add_struct_sized (fp, flag, name, 0));
}
ctf_id_t
-ctf_add_union_sized (ctf_file_t *fp, uint32_t flag, const char *name,
+ctf_add_union_sized (ctf_dict_t *fp, uint32_t flag, const char *name,
size_t size)
{
ctf_dtdef_t *dtd;
}
ctf_id_t
-ctf_add_union (ctf_file_t *fp, uint32_t flag, const char *name)
+ctf_add_union (ctf_dict_t *fp, uint32_t flag, const char *name)
{
return (ctf_add_union_sized (fp, flag, name, 0));
}
ctf_id_t
-ctf_add_enum (ctf_file_t *fp, uint32_t flag, const char *name)
+ctf_add_enum (ctf_dict_t *fp, uint32_t flag, const char *name)
{
ctf_dtdef_t *dtd;
ctf_id_t type = 0;
}
ctf_id_t
-ctf_add_enum_encoded (ctf_file_t *fp, uint32_t flag, const char *name,
+ctf_add_enum_encoded (ctf_dict_t *fp, uint32_t flag, const char *name,
const ctf_encoding_t *ep)
{
ctf_id_t type = 0;
}
ctf_id_t
-ctf_add_forward (ctf_file_t *fp, uint32_t flag, const char *name,
+ctf_add_forward (ctf_dict_t *fp, uint32_t flag, const char *name,
uint32_t kind)
{
ctf_dtdef_t *dtd;
}
ctf_id_t
-ctf_add_typedef (ctf_file_t *fp, uint32_t flag, const char *name,
+ctf_add_typedef (ctf_dict_t *fp, uint32_t flag, const char *name,
ctf_id_t ref)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
return (ctf_set_errno (fp, EINVAL));
}
ctf_id_t
-ctf_add_volatile (ctf_file_t *fp, uint32_t flag, ctf_id_t ref)
+ctf_add_volatile (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref)
{
return (ctf_add_reftype (fp, flag, ref, CTF_K_VOLATILE));
}
ctf_id_t
-ctf_add_const (ctf_file_t *fp, uint32_t flag, ctf_id_t ref)
+ctf_add_const (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref)
{
return (ctf_add_reftype (fp, flag, ref, CTF_K_CONST));
}
ctf_id_t
-ctf_add_restrict (ctf_file_t *fp, uint32_t flag, ctf_id_t ref)
+ctf_add_restrict (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref)
{
return (ctf_add_reftype (fp, flag, ref, CTF_K_RESTRICT));
}
int
-ctf_add_enumerator (ctf_file_t *fp, ctf_id_t enid, const char *name,
+ctf_add_enumerator (ctf_dict_t *fp, ctf_id_t enid, const char *name,
int value)
{
ctf_dtdef_t *dtd = ctf_dtd_lookup (fp, enid);
}
int
-ctf_add_member_offset (ctf_file_t *fp, ctf_id_t souid, const char *name,
+ctf_add_member_offset (ctf_dict_t *fp, ctf_id_t souid, const char *name,
ctf_id_t type, unsigned long bit_offset)
{
ctf_dtdef_t *dtd = ctf_dtd_lookup (fp, souid);
}
int
-ctf_add_member_encoded (ctf_file_t *fp, ctf_id_t souid, const char *name,
+ctf_add_member_encoded (ctf_dict_t *fp, ctf_id_t souid, const char *name,
ctf_id_t type, unsigned long bit_offset,
const ctf_encoding_t encoding)
{
}
int
-ctf_add_member (ctf_file_t *fp, ctf_id_t souid, const char *name,
+ctf_add_member (ctf_dict_t *fp, ctf_id_t souid, const char *name,
ctf_id_t type)
{
return ctf_add_member_offset (fp, souid, name, type, (unsigned long) - 1);
}
int
-ctf_add_variable (ctf_file_t *fp, const char *name, ctf_id_t ref)
+ctf_add_variable (ctf_dict_t *fp, const char *name, ctf_id_t ref)
{
ctf_dvdef_t *dvd;
- ctf_file_t *tmp = fp;
+ ctf_dict_t *tmp = fp;
if (!(fp->ctf_flags & LCTF_RDWR))
return (ctf_set_errno (fp, ECTF_RDONLY));
typedef struct ctf_bundle
{
- ctf_file_t *ctb_file; /* CTF container handle. */
+ ctf_dict_t *ctb_dict; /* CTF dict handle. */
ctf_id_t ctb_type; /* CTF type identifier. */
ctf_dtdef_t *ctb_dtd; /* CTF dynamic type definition (if any). */
} ctf_bundle_t;
ctf_bundle_t *ctb = arg;
int bvalue;
- if (ctf_enum_value (ctb->ctb_file, ctb->ctb_type, name, &bvalue) < 0)
+ if (ctf_enum_value (ctb->ctb_dict, ctb->ctb_type, name, &bvalue) < 0)
{
- ctf_err_warn (ctb->ctb_file, 0, 0,
+ ctf_err_warn (ctb->ctb_dict, 0, 0,
_("conflict due to enum %s iteration error"), name);
return 1;
}
if (value != bvalue)
{
- ctf_err_warn (ctb->ctb_file, 1, ECTF_CONFLICT,
+ ctf_err_warn (ctb->ctb_dict, 1, ECTF_CONFLICT,
_("conflict due to enum value change: %i versus %i"),
value, bvalue);
return 1;
{
ctf_bundle_t *ctb = arg;
- return (ctf_add_enumerator (ctb->ctb_file, ctb->ctb_type,
+ return (ctf_add_enumerator (ctb->ctb_dict, ctb->ctb_type,
name, value) < 0);
}
if (name[0] == 0)
return 0;
- if (ctf_member_info (ctb->ctb_file, ctb->ctb_type, name, &ctm) < 0)
+ if (ctf_member_info (ctb->ctb_dict, ctb->ctb_type, name, &ctm) < 0)
{
- ctf_err_warn (ctb->ctb_file, 0, 0,
+ ctf_err_warn (ctb->ctb_dict, 0, 0,
_("conflict due to struct member %s iteration error"),
name);
return 1;
}
if (ctm.ctm_offset != offset)
{
- ctf_err_warn (ctb->ctb_file, 1, ECTF_CONFLICT,
+ ctf_err_warn (ctb->ctb_dict, 1, ECTF_CONFLICT,
_("conflict due to struct member %s offset change: "
"%lx versus %lx"),
name, ctm.ctm_offset, offset);
char *s = NULL;
if ((dmd = malloc (sizeof (ctf_dmdef_t))) == NULL)
- return (ctf_set_errno (ctb->ctb_file, EAGAIN));
+ return (ctf_set_errno (ctb->ctb_dict, EAGAIN));
if (name != NULL && (s = strdup (name)) == NULL)
{
free (dmd);
- return (ctf_set_errno (ctb->ctb_file, EAGAIN));
+ return (ctf_set_errno (ctb->ctb_dict, EAGAIN));
}
/* For now, dmd_type is copied as the src_fp's type; it is reset to an
ctf_list_append (&ctb->ctb_dtd->dtd_u.dtu_members, dmd);
- ctb->ctb_file->ctf_flags |= LCTF_DIRTY;
+ ctb->ctb_dict->ctf_flags |= LCTF_DIRTY;
return 0;
}
-/* The ctf_add_type routine is used to copy a type from a source CTF container
- to a dynamic destination container. This routine operates recursively by
+/* The ctf_add_type routine is used to copy a type from a source CTF dictionary
+ to a dynamic destination dictionary. This routine operates recursively by
following the source type's links and embedded member types. If the
- destination container already contains a named type which has the same
- attributes, then we succeed and return this type but no changes occur. */
+ destination dict already contains a named type which has the same attributes,
+ then we succeed and return this type but no changes occur. */
static ctf_id_t
-ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type,
- ctf_file_t *proc_tracking_fp)
+ctf_add_type_internal (ctf_dict_t *dst_fp, ctf_dict_t *src_fp, ctf_id_t src_type,
+ ctf_dict_t *proc_tracking_fp)
{
ctf_id_t dst_type = CTF_ERR;
uint32_t dst_kind = CTF_K_UNKNOWN;
- ctf_file_t *tmp_fp = dst_fp;
+ ctf_dict_t *tmp_fp = dst_fp;
ctf_id_t tmp;
const char *name;
(void *) (uintptr_t) src_type))
return tmp;
- /* If this type has already been added from this container, and is the same
- kind and (if a struct or union) has the same number of members, hand it
- straight back. */
+ /* If this type has already been added from this dictionary, and is the
+ same kind and (if a struct or union) has the same number of members,
+ hand it straight back. */
if (ctf_type_kind_unsliced (tmp_fp, tmp) == (int) kind)
{
if (kind == CTF_K_FORWARD)
forward_kind = src_tp->ctt_type;
- /* If the source type has a name and is a root type (visible at the
- top-level scope), lookup the name in the destination container and
- verify that it is of the same kind before we do anything else. */
+ /* If the source type has a name and is a root type (visible at the top-level
+ scope), lookup the name in the destination dictionary and verify that it is
+ of the same kind before we do anything else. */
if ((flag & CTF_ADD_ROOT) && name[0] != '\0'
&& (tmp = ctf_lookup_by_rawname (dst_fp, forward_kind, name)) != 0)
&& kind != CTF_K_UNION))
{
ctf_err_warn (dst_fp, 1, ECTF_CONFLICT,
- _("ctf_add_file(): conflict for type %s: "
+ _("ctf_add_type: conflict for type %s: "
"kinds differ, new: %i; old (ID %lx): %i"),
name, kind, dst_type, dst_kind);
return (ctf_set_errno (dst_fp, ECTF_CONFLICT));
if (dst_type != CTF_ERR)
{
- ctf_file_t *fp = dst_fp;
+ ctf_dict_t *fp = dst_fp;
if ((dst_tp = ctf_lookup_by_id (&fp, dst_type)) == NULL)
return CTF_ERR;
}
}
- src.ctb_file = src_fp;
+ src.ctb_dict = src_fp;
src.ctb_type = src_type;
src.ctb_dtd = NULL;
- dst.ctb_file = dst_fp;
+ dst.ctb_dict = dst_fp;
dst.ctb_type = dst_type;
dst.ctb_dtd = NULL;
for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
dmd != NULL; dmd = ctf_list_next (dmd))
{
- ctf_file_t *dst = dst_fp;
+ ctf_dict_t *dst = dst_fp;
ctf_id_t memb_type;
memb_type = ctf_type_mapping (src_fp, dmd->dmd_type, &dst);
}
ctf_id_t
-ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
+ctf_add_type (ctf_dict_t *dst_fp, ctf_dict_t *src_fp, ctf_id_t src_type)
{
ctf_id_t id;
/* Write the compressed CTF data stream to the specified gzFile descriptor. */
int
-ctf_gzwrite (ctf_file_t *fp, gzFile fd)
+ctf_gzwrite (ctf_dict_t *fp, gzFile fd)
{
const unsigned char *buf;
ssize_t resid;
/* Compress the specified CTF data stream and write it to the specified file
descriptor. */
int
-ctf_compress_write (ctf_file_t *fp, int fd)
+ctf_compress_write (ctf_dict_t *fp, int fd)
{
unsigned char *buf;
unsigned char *bp;
/* Optionally compress the specified CTF data stream and return it as a new
dynamically-allocated string. */
unsigned char *
-ctf_write_mem (ctf_file_t *fp, size_t *size, size_t threshold)
+ctf_write_mem (ctf_dict_t *fp, size_t *size, size_t threshold)
{
unsigned char *buf;
unsigned char *bp;
/* Write the uncompressed CTF data stream to the specified file descriptor. */
int
-ctf_write (ctf_file_t *fp, int fd)
+ctf_write (ctf_dict_t *fp, int fd)
{
const unsigned char *buf;
ssize_t resid;
}
void
-ctf_decl_push (ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type)
+ctf_decl_push (ctf_decl_t *cd, ctf_dict_t *fp, ctf_id_t type)
{
ctf_decl_node_t *cdp;
ctf_decl_prec_t prec;
*global type ID* or 'GID', a pair of an array offset and a ctf_id_t. Since
both are already 32 bits or less or can easily be constrained to that range,
we can pack them both into a single 64-bit hash word for easy lookups, which
- would be much more annoying to do with a ctf_file_t * and a ctf_id_t. (On
+ would be much more annoying to do with a ctf_dict_t * and a ctf_id_t. (On
32-bit platforms, we must do that anyway, since pointers, and thus hash keys
and values, are only 32 bits wide). We track which inputs are parents of
which other inputs so that we can correctly recognize that types we have
approach, but with a smaller key, this is all we can do. */
static void *
-id_to_packed_id (ctf_file_t *fp, int input_num, ctf_id_t type)
+id_to_packed_id (ctf_dict_t *fp, int input_num, ctf_id_t type)
{
const void *lookup;
ctf_type_id_key_t *dynkey = NULL;
ctf_type_id_key_t key = { input_num, type };
- if (!ctf_dynhash_lookup_kv (fp->ctf_dedup.cd_id_to_file_t,
+ if (!ctf_dynhash_lookup_kv (fp->ctf_dedup.cd_id_to_dict_t,
&key, &lookup, NULL))
{
if ((dynkey = malloc (sizeof (ctf_type_id_key_t))) == NULL)
goto oom;
memcpy (dynkey, &key, sizeof (ctf_type_id_key_t));
- if (ctf_dynhash_insert (fp->ctf_dedup.cd_id_to_file_t, dynkey, NULL) < 0)
+ if (ctf_dynhash_insert (fp->ctf_dedup.cd_id_to_dict_t, dynkey, NULL) < 0)
goto oom;
- ctf_dynhash_lookup_kv (fp->ctf_dedup.cd_id_to_file_t,
+ ctf_dynhash_lookup_kv (fp->ctf_dedup.cd_id_to_dict_t,
dynkey, &lookup, NULL);
}
/* We use a raw assert() here because there isn't really a way to get any sort
/* Initialize the dedup atoms table. */
int
-ctf_dedup_atoms_init (ctf_file_t *fp)
+ctf_dedup_atoms_init (ctf_dict_t *fp)
{
if (fp->ctf_dedup_atoms)
return 0;
/* Intern things in the dedup atoms table. */
static const char *
-intern (ctf_file_t *fp, char *atom)
+intern (ctf_dict_t *fp, char *atom)
{
const void *foo;
while allowing for the four C namespaces (normal, struct, union, enum).
Return a new dynamically-allocated string. */
static const char *
-ctf_decorate_type_name (ctf_file_t *fp, const char *name, int kind)
+ctf_decorate_type_name (ctf_dict_t *fp, const char *name, int kind)
{
ctf_dedup_t *d = &fp->ctf_dedup;
const char *ret;
}
static const char *
-ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
- ctf_file_t **inputs, uint32_t *parents,
+ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input,
+ ctf_dict_t **inputs, uint32_t *parents,
int input_num, ctf_id_t type, int flags,
unsigned long depth,
- int (*populate_fun) (ctf_file_t *fp,
- ctf_file_t *input,
- ctf_file_t **inputs,
+ int (*populate_fun) (ctf_dict_t *fp,
+ ctf_dict_t *input,
+ ctf_dict_t **inputs,
int input_num,
ctf_id_t type,
void *id,
Only called for forwards or forwardable types with names, when the link mode
is CTF_LINK_SHARE_DUPLICATED. */
static int
-ctf_dedup_record_origin (ctf_file_t *fp, int input_num, const char *decorated,
+ctf_dedup_record_origin (ctf_dict_t *fp, int input_num, const char *decorated,
void *id)
{
ctf_dedup_t *d = &fp->ctf_dedup;
calls, recursively). */
static const char *
-ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
+ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs,
uint32_t *parents, int input_num, ctf_id_t type,
void *type_id, const ctf_type_t *tp, const char *name,
const char *decorated, int kind, int flags,
unsigned long depth,
- int (*populate_fun) (ctf_file_t *fp,
- ctf_file_t *input,
- ctf_file_t **inputs,
+ int (*populate_fun) (ctf_dict_t *fp,
+ ctf_dict_t *input,
+ ctf_dict_t **inputs,
int input_num,
ctf_id_t type,
void *id,
Returns a hash value (an atom), or NULL on error. */
static const char *
-ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
- ctf_file_t **inputs, uint32_t *parents,
+ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input,
+ ctf_dict_t **inputs, uint32_t *parents,
int input_num, ctf_id_t type, int flags,
unsigned long depth,
- int (*populate_fun) (ctf_file_t *fp,
- ctf_file_t *input,
- ctf_file_t **inputs,
+ int (*populate_fun) (ctf_dict_t *fp,
+ ctf_dict_t *input,
+ ctf_dict_t **inputs,
int input_num,
ctf_id_t type,
void *id,
cd_output_first_tu mapping. */
static int
-ctf_dedup_populate_mappings (ctf_file_t *fp, ctf_file_t *input _libctf_unused_,
- ctf_file_t **inputs _libctf_unused_,
+ctf_dedup_populate_mappings (ctf_dict_t *fp, ctf_dict_t *input _libctf_unused_,
+ ctf_dict_t **inputs _libctf_unused_,
int input_num _libctf_unused_,
ctf_id_t type _libctf_unused_, void *id,
const char *decorated_name,
while ((err = ctf_dynset_cnext (type_ids, &i, &one_id)) == 0)
{
- ctf_file_t *foo = inputs[CTF_DEDUP_GID_TO_INPUT (one_id)];
+ ctf_dict_t *foo = inputs[CTF_DEDUP_GID_TO_INPUT (one_id)];
ctf_id_t bar = CTF_DEDUP_GID_TO_TYPE (one_id);
if (ctf_type_kind_unsliced (foo, bar) != orig_kind)
{
ctf_dedup_maybe_synthesize_forward.) */
static int
-ctf_dedup_mark_conflicting_hash (ctf_file_t *fp, const char *hval)
+ctf_dedup_mark_conflicting_hash (ctf_dict_t *fp, const char *hval)
{
ctf_dedup_t *d = &fp->ctf_dedup;
ctf_next_t *i = NULL;
/* Look up a type kind from the output mapping, given a type hash value. */
static int
-ctf_dedup_hash_kind (ctf_file_t *fp, ctf_file_t **inputs, const char *hash)
+ctf_dedup_hash_kind (ctf_dict_t *fp, ctf_dict_t **inputs, const char *hash)
{
ctf_dedup_t *d = &fp->ctf_dedup;
void *id;
/* Used to keep a count of types: i.e. distinct type hash values. */
typedef struct ctf_dedup_type_counter
{
- ctf_file_t *fp;
- ctf_file_t **inputs;
+ ctf_dict_t *fp;
+ ctf_dict_t **inputs;
int num_non_forwards;
} ctf_dedup_type_counter_t;
/* Detect name ambiguity and mark ambiguous names as conflicting, other than the
most common. */
static int
-ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
+ctf_dedup_detect_name_ambiguity (ctf_dict_t *fp, ctf_dict_t **inputs)
{
ctf_dedup_t *d = &fp->ctf_dedup;
ctf_next_t *i = NULL;
/* Initialize the deduplication machinery. */
static int
-ctf_dedup_init (ctf_file_t *fp)
+ctf_dedup_init (ctf_dict_t *fp)
{
ctf_dedup_t *d = &fp->ctf_dedup;
size_t i;
goto oom;
#if IDS_NEED_ALLOCATION
- if ((d->cd_id_to_file_t = ctf_dynhash_create (ctf_hash_type_id_key,
+ if ((d->cd_id_to_dict_t = ctf_dynhash_create (ctf_hash_type_id_key,
ctf_hash_eq_type_id_key,
free, NULL)) == NULL)
goto oom;
}
void
-ctf_dedup_fini (ctf_file_t *fp, ctf_file_t **outputs, uint32_t noutputs)
+ctf_dedup_fini (ctf_dict_t *fp, ctf_dict_t **outputs, uint32_t noutputs)
{
ctf_dedup_t *d = &fp->ctf_dedup;
size_t i;
/* ctf_dedup_atoms is kept across links. */
#if IDS_NEED_ALLOCATION
- ctf_dynhash_destroy (d->cd_id_to_file_t);
+ ctf_dynhash_destroy (d->cd_id_to_dict_t);
#endif
for (i = 0; i < 4; i++)
ctf_dynhash_destroy (d->cd_decorated_names[i]);
ctf_dedup_t *od = &outputs[i]->ctf_dedup;
ctf_dynhash_destroy (od->cd_output_emission_hashes);
ctf_dynhash_destroy (od->cd_output_emission_conflicted_forwards);
- ctf_file_close (od->cd_output);
+ ctf_dict_close (od->cd_output);
}
}
memset (d, 0, sizeof (ctf_dedup_t));
/* Return 1 if this type is cited by multiple input dictionaries. */
static int
-ctf_dedup_multiple_input_dicts (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_multiple_input_dicts (ctf_dict_t *output, ctf_dict_t **inputs,
const char *hval)
{
ctf_dedup_t *d = &output->ctf_dedup;
ctf_dynset_t *type_ids;
ctf_next_t *i = NULL;
void *id;
- ctf_file_t *found = NULL, *relative_found = NULL;
+ ctf_dict_t *found = NULL, *relative_found = NULL;
const char *type_id;
- ctf_file_t *input_fp;
+ ctf_dict_t *input_fp;
ctf_id_t input_id;
const char *name;
const char *decorated;
while ((err = ctf_dynset_next (type_ids, &i, &id)) == 0)
{
- ctf_file_t *fp = inputs[CTF_DEDUP_GID_TO_INPUT (id)];
+ ctf_dict_t *fp = inputs[CTF_DEDUP_GID_TO_INPUT (id)];
if (fp == found || fp == relative_found)
continue;
types. Only used if the link mode is CTF_LINK_SHARE_DUPLICATED. */
static int
-ctf_dedup_conflictify_unshared (ctf_file_t *output, ctf_file_t **inputs)
+ctf_dedup_conflictify_unshared (ctf_dict_t *output, ctf_dict_t **inputs)
{
ctf_dedup_t *d = &output->ctf_dedup;
ctf_next_t *i = NULL;
ctf_dedup_emit afterwards to do that. */
int
-ctf_dedup (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
+ctf_dedup (ctf_dict_t *output, ctf_dict_t **inputs, uint32_t ninputs,
uint32_t *parents, int cu_mapped)
{
ctf_dedup_t *d = &output->ctf_dedup;
}
static int
-ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_rwalk_output_mapping (ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs, uint32_t *parents,
ctf_dynset_t *already_visited,
const char *hval,
int (*visit_fun) (const char *hval,
- ctf_file_t *output,
- ctf_file_t **inputs,
+ ctf_dict_t *output,
+ ctf_dict_t **inputs,
uint32_t ninputs,
uint32_t *parents,
int already_visited,
- ctf_file_t *input,
+ ctf_dict_t *input,
ctf_id_t type,
void *id,
int depth,
/* Like ctf_dedup_rwalk_output_mapping (which see), only takes a single target
type and visits it. */
static int
-ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
- ctf_file_t **inputs, uint32_t ninputs,
+ctf_dedup_rwalk_one_output_mapping (ctf_dict_t *output,
+ ctf_dict_t **inputs, uint32_t ninputs,
uint32_t *parents,
ctf_dynset_t *already_visited,
int visited, void *type_id,
const char *hval,
int (*visit_fun) (const char *hval,
- ctf_file_t *output,
- ctf_file_t **inputs,
+ ctf_dict_t *output,
+ ctf_dict_t **inputs,
uint32_t ninputs,
uint32_t *parents,
int already_visited,
- ctf_file_t *input,
+ ctf_dict_t *input,
ctf_id_t type,
void *id,
int depth,
void *arg, unsigned long depth)
{
ctf_dedup_t *d = &output->ctf_dedup;
- ctf_file_t *fp;
+ ctf_dict_t *fp;
int input_num;
ctf_id_t type;
int ret;
once, but are not recursed through repeatedly: ALREADY_VISITED tracks whether
types have already been visited. */
static int
-ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_rwalk_output_mapping (ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs, uint32_t *parents,
ctf_dynset_t *already_visited,
const char *hval,
int (*visit_fun) (const char *hval,
- ctf_file_t *output,
- ctf_file_t **inputs,
+ ctf_dict_t *output,
+ ctf_dict_t **inputs,
uint32_t ninputs,
uint32_t *parents,
int already_visited,
- ctf_file_t *input,
+ ctf_dict_t *input,
ctf_id_t type,
void *id,
int depth,
typedef struct ctf_sort_om_cb_arg
{
- ctf_file_t **inputs;
+ ctf_dict_t **inputs;
uint32_t ninputs;
ctf_dedup_t *d;
} ctf_sort_om_cb_arg_t;
void *one_gid, *two_gid;
uint32_t one_ninput;
uint32_t two_ninput;
- ctf_file_t *one_fp;
- ctf_file_t *two_fp;
+ ctf_dict_t *one_fp;
+ ctf_dict_t *two_fp;
ctf_id_t one_type;
ctf_id_t two_type;
/* The public entry point to ctf_dedup_rwalk_output_mapping, above. */
static int
-ctf_dedup_walk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_walk_output_mapping (ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs, uint32_t *parents,
int (*visit_fun) (const char *hval,
- ctf_file_t *output,
- ctf_file_t **inputs,
+ ctf_dict_t *output,
+ ctf_dict_t **inputs,
uint32_t ninputs,
uint32_t *parents,
int already_visited,
- ctf_file_t *input,
+ ctf_dict_t *input,
ctf_id_t type,
void *id,
int depth,
conflicted per-TU type ID in INPUT with hash HVAL. Return its CTF ID, or 0
if none was needed. */
static ctf_id_t
-ctf_dedup_maybe_synthesize_forward (ctf_file_t *output, ctf_file_t *target,
- ctf_file_t *input, ctf_id_t id,
+ctf_dedup_maybe_synthesize_forward (ctf_dict_t *output, ctf_dict_t *target,
+ ctf_dict_t *input, ctf_id_t id,
const char *hval)
{
ctf_dedup_t *od = &output->ctf_dedup;
make usability a bit better. */
static ctf_id_t
-ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
- ctf_file_t **inputs, uint32_t ninputs,
- uint32_t *parents, ctf_file_t *input, int input_num,
+ctf_dedup_id_to_target (ctf_dict_t *output, ctf_dict_t *target,
+ ctf_dict_t **inputs, uint32_t ninputs,
+ uint32_t *parents, ctf_dict_t *input, int input_num,
ctf_id_t id)
{
ctf_dedup_t *od = &output->ctf_dedup;
ctf_dedup_t *td = &target->ctf_dedup;
- ctf_file_t *err_fp = input;
+ ctf_dict_t *err_fp = input;
const char *hval;
void *target_id;
ctf_id_t emitted_forward;
have already been emitted. (This type itself may also have been emitted.)
If the ARG is 1, this is a CU-mapped deduplication round mapping many
- ctf_file_t's into precisely one: conflicting types should be marked
+ ctf_dict_t's into precisely one: conflicting types should be marked
non-root-visible. If the ARG is 0, conflicting types go into per-CU
dictionaries stored in the input's ctf_dedup.cd_output: otherwise, everything
is emitted directly into the output. No struct/union members are emitted.
data object section, backtrace section etc). */
static int
-ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_emit_type (const char *hval, ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs, uint32_t *parents, int already_visited,
- ctf_file_t *input, ctf_id_t type, void *id, int depth,
+ ctf_dict_t *input, ctf_id_t type, void *id, int depth,
void *arg)
{
ctf_dedup_t *d = &output->ctf_dedup;
int kind = ctf_type_kind_unsliced (input, type);
const char *name;
- ctf_file_t *target = output;
- ctf_file_t *real_input;
+ ctf_dict_t *target = output;
+ ctf_dict_t *real_input;
const ctf_type_t *tp;
int input_num = CTF_DEDUP_GID_TO_INPUT (id);
int output_num = (uint32_t) -1; /* 'shared' */
point. */
static int
-ctf_dedup_emit_struct_members (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_emit_struct_members (ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs, uint32_t *parents)
{
ctf_dedup_t *d = &output->ctf_dedup;
ctf_next_t *i = NULL;
void *input_id, *target_id;
int err;
- ctf_file_t *err_fp, *input_fp;
+ ctf_dict_t *err_fp, *input_fp;
int input_num;
ctf_id_t err_type;
&input_id, &target_id)) == 0)
{
ctf_next_t *j = NULL;
- ctf_file_t *target;
+ ctf_dict_t *target;
uint32_t target_num;
ctf_id_t input_type, target_type;
ssize_t offset;
dict containing a non-null cd_output resulting from a ctf_dedup_emit_type
walk). */
static int
-ctf_dedup_populate_type_mapping (ctf_file_t *shared, ctf_file_t *fp,
- ctf_file_t **inputs)
+ctf_dedup_populate_type_mapping (ctf_dict_t *shared, ctf_dict_t *fp,
+ ctf_dict_t **inputs)
{
ctf_dedup_t *d = &shared->ctf_dedup;
- ctf_file_t *output = fp->ctf_dedup.cd_output;
+ ctf_dict_t *output = fp->ctf_dedup.cd_output;
const void *k, *v;
ctf_next_t *i = NULL;
int err;
while ((err = ctf_dynset_cnext (type_ids, &j, &id)) == 0)
{
- ctf_file_t *input = inputs[CTF_DEDUP_GID_TO_INPUT (id)];
+ ctf_dict_t *input = inputs[CTF_DEDUP_GID_TO_INPUT (id)];
ctf_id_t id_in = CTF_DEDUP_GID_TO_TYPE (id);
#ifdef ENABLE_LIBCTF_HASH_DEBUGGING
/* Populate the type mapping machinery used by the rest of the linker,
by ctf_add_type, etc. */
static int
-ctf_dedup_populate_type_mappings (ctf_file_t *output, ctf_file_t **inputs,
+ctf_dedup_populate_type_mappings (ctf_dict_t *output, ctf_dict_t **inputs,
uint32_t ninputs)
{
size_t i;
If CU_MAPPED is set, this is a first pass for a link with a non-empty CU
mapping: only one output will result. */
-ctf_file_t **
-ctf_dedup_emit (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
+ctf_dict_t **
+ctf_dedup_emit (ctf_dict_t *output, ctf_dict_t **inputs, uint32_t ninputs,
uint32_t *parents, uint32_t *noutputs, int cu_mapped)
{
size_t num_outputs = 1; /* Always at least one output: us. */
- ctf_file_t **outputs;
- ctf_file_t **walk;
+ ctf_dict_t **outputs;
+ ctf_dict_t **walk;
size_t i;
ctf_dprintf ("Triggering emission.\n");
if (!ctf_assert (output, !cu_mapped || (cu_mapped && num_outputs == 1)))
return NULL;
- if ((outputs = calloc (num_outputs, sizeof (ctf_file_t *))) == NULL)
+ if ((outputs = calloc (num_outputs, sizeof (ctf_dict_t *))) == NULL)
{
ctf_err_warn (output, 0, ENOMEM,
_("out of memory allocating link outputs array"));
struct ctf_dump_state
{
ctf_sect_names_t cds_sect;
- ctf_file_t *cds_fp;
+ ctf_dict_t *cds_fp;
ctf_dump_item_t *cds_current;
ctf_list_t cds_items;
};
typedef struct ctf_dump_membstate
{
char **cdm_str;
- ctf_file_t *cdm_fp;
+ ctf_dict_t *cdm_fp;
} ctf_dump_membstate_t;
static int
type's references. */
static char *
-ctf_dump_format_type (ctf_file_t *fp, ctf_id_t id, int flag)
+ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
{
ctf_id_t new_id;
char *str = NULL, *bit = NULL, *buf = NULL;
/* Dump one string field from the file header into the cds_items. */
static int
-ctf_dump_header_strfield (ctf_file_t *fp, ctf_dump_state_t *state,
+ctf_dump_header_strfield (ctf_dict_t *fp, ctf_dump_state_t *state,
const char *name, uint32_t value)
{
char *str;
/* Dump one section-offset field from the file header into the cds_items. */
static int
-ctf_dump_header_sectfield (ctf_file_t *fp, ctf_dump_state_t *state,
+ctf_dump_header_sectfield (ctf_dict_t *fp, ctf_dump_state_t *state,
const char *sect, uint32_t off, uint32_t nextoff)
{
char *str;
/* Dump the file header into the cds_items. */
static int
-ctf_dump_header (ctf_file_t *fp, ctf_dump_state_t *state)
+ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state)
{
char *str;
const ctf_header_t *hp = fp->ctf_header;
/* Everything else is only printed if present. */
- /* The flags are unusual in that they represent the ctf_file_t *in memory*:
+ /* The flags are unusual in that they represent the ctf_dict_t *in memory*:
flags representing compression, etc, are turned off as the file is
decompressed. So we store a copy of the flags before they are changed, for
the dumper. */
them, rather than only one. */
static int
-ctf_dump_objts (ctf_file_t *fp, ctf_dump_state_t *state)
+ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state)
{
size_t i;
iterator for this section.) */
static int
-ctf_dump_funcs (ctf_file_t *fp, ctf_dump_state_t *state)
+ctf_dump_funcs (ctf_dict_t *fp, ctf_dump_state_t *state)
{
size_t i;
/* Dump the string table into the cds_items. */
static int
-ctf_dump_str (ctf_file_t *fp, ctf_dump_state_t *state)
+ctf_dump_str (ctf_dict_t *fp, ctf_dump_state_t *state)
{
const char *s = fp->ctf_str[CTF_STRTAB_0].cts_strs;
allocate a new one and return it if it likes). */
char *
-ctf_dump (ctf_file_t *fp, ctf_dump_state_t **statep, ctf_sect_names_t sect,
+ctf_dump (ctf_dict_t *fp, ctf_dump_state_t **statep, ctf_sect_names_t sect,
ctf_dump_decorate_f *func, void *arg)
{
char *str;
}
int
-ctf_errno (ctf_file_t * fp)
+ctf_errno (ctf_dict_t * fp)
{
return fp->ctf_errno;
}
}
int
-ctf_hash_insert_type (ctf_hash_t *hp, ctf_file_t *fp, uint32_t type,
+ctf_hash_insert_type (ctf_hash_t *hp, ctf_dict_t *fp, uint32_t type,
uint32_t name)
{
const char *str = ctf_strraw (fp, name);
this new official definition. If the key is not present, then call
ctf_hash_insert_type and hash it in. */
int
-ctf_hash_define_type (ctf_hash_t *hp, ctf_file_t *fp, uint32_t type,
+ctf_hash_define_type (ctf_hash_t *hp, ctf_dict_t *fp, uint32_t type,
uint32_t name)
{
/* This matches the semantics of ctf_hash_insert_type in this
}
ctf_id_t
-ctf_hash_lookup_type (ctf_hash_t *hp, ctf_file_t *fp __attribute__ ((__unused__)),
+ctf_hash_lookup_type (ctf_hash_t *hp, ctf_dict_t *fp __attribute__ ((__unused__)),
const char *key)
{
ctf_helem_t **slot;
ctf_names_t *ctl_hash; /* Pointer to hash table for lookup. */
} ctf_lookup_t;
-typedef struct ctf_fileops
+typedef struct ctf_dictops
{
uint32_t (*ctfo_get_kind) (uint32_t);
uint32_t (*ctfo_get_root) (uint32_t);
uint32_t (*ctfo_get_vlen) (uint32_t);
- ssize_t (*ctfo_get_ctt_size) (const ctf_file_t *, const ctf_type_t *,
+ ssize_t (*ctfo_get_ctt_size) (const ctf_dict_t *, const ctf_type_t *,
ssize_t *, ssize_t *);
- ssize_t (*ctfo_get_vbytes) (ctf_file_t *, unsigned short, ssize_t, size_t);
-} ctf_fileops_t;
+ ssize_t (*ctfo_get_vbytes) (ctf_dict_t *, unsigned short, ssize_t, size_t);
+} ctf_dictops_t;
typedef struct ctf_list
{
typedef struct ctf_link_type_key
{
- ctf_file_t *cltk_fp;
+ ctf_dict_t *cltk_fp;
ctf_id_t cltk_idx;
} ctf_link_type_key_t;
-/* The structure used as the key in a cd_id_to_file_t on 32-bit platforms. */
+/* The structure used as the key in a cd_id_to_dict_t on 32-bit platforms. */
typedef struct ctf_type_id_key
{
int ctii_input_num;
The dedup state below uses three terms consistently. A "hash" is a
ctf_dynhash_t; a "hash value" is the hash value of a type as returned by
ctf_dedup_hash_type; a "global type ID" or "global ID" is a packed-together
- reference to a single ctf_file_t (by array index in an array of inputs) and
+ reference to a single ctf_dict_t (by array index in an array of inputs) and
ctf_id_t, i.e. a single instance of some hash value in some input.
The deduplication algorithm takes a bunch of inputs and yields a single
/* On 32-bit platforms only, a hash of global type IDs, in the form of
a ctf_link_type_id_key_t. */
- ctf_dynhash_t *cd_id_to_file_t;
+ ctf_dynhash_t *cd_id_to_dict_t;
/* Atoms tables of decorated names: maps undecorated name to decorated name.
- (The actual allocations are in the CTF file for the former and the real
+ (The actual allocations are in the CTF dict for the former and the real
atoms table for the latter). Uses the same namespaces as ctf_lookups,
below, but has no need for null-termination. */
ctf_dynhash_t *cd_decorated_names[4];
/* Points to the output counterpart of this input dictionary, at emission
time. */
- ctf_file_t *cd_output;
+ ctf_dict_t *cd_output;
} ctf_dedup_t;
-/* The ctf_file is the structure used to represent a CTF container to library
+/* The ctf_dict is the structure used to represent a CTF dictionary to library
clients, who see it only as an opaque pointer. Modifications can therefore
be made freely to this structure without regard to client versioning. The
- ctf_file_t typedef appears in <ctf-api.h> and declares a forward tag.
+ ctf_dict_t typedef appears in <ctf-api.h> and declares a forward tag.
+ (A ctf_file_t typedef also appears there, for historical reasons.)
- NOTE: ctf_update() requires that everything inside of ctf_file either be an
- immediate value, a pointer to dynamically allocated data *outside* of the
- ctf_file itself, or a pointer to statically allocated data. If you add a
- pointer to ctf_file that points to something within the ctf_file itself,
- you must make corresponding changes to ctf_update(). */
+ NOTE: ctf_serialize() requires that everything inside of ctf_dict either be
+ an immediate value, a pointer to dynamically allocated data *outside* of the
+ ctf_dict itself, or a pointer to statically allocated data. If you add a
+ pointer to ctf_dict that points to something within the ctf_dict itself, you
+ must make corresponding changes to ctf_serialize(). */
-struct ctf_file
+struct ctf_dict
{
- const ctf_fileops_t *ctf_fileops; /* Version-specific file operations. */
- struct ctf_header *ctf_header; /* The header from this CTF file. */
- unsigned char ctf_openflags; /* Flags the file had when opened. */
+ const ctf_dictops_t *ctf_dictops; /* Version-specific dict operations. */
+ struct ctf_header *ctf_header; /* The header from this CTF dict. */
+ unsigned char ctf_openflags; /* Flags the dict had when opened. */
ctf_sect_t ctf_data; /* CTF data from object file. */
ctf_sect_t ctf_symtab; /* Symbol table from object file. */
ctf_sect_t ctf_strtab; /* String table from object file. */
const ctf_dmodel_t *ctf_dmodel; /* Data model pointer (see above). */
const char *ctf_cuname; /* Compilation unit name (if any). */
char *ctf_dyncuname; /* Dynamically allocated name of CU. */
- struct ctf_file *ctf_parent; /* Parent CTF container (if any). */
+ struct ctf_dict *ctf_parent; /* Parent CTF dict (if any). */
int ctf_parent_unreffed; /* Parent set by ctf_import_unref? */
- const char *ctf_parlabel; /* Label in parent container (if any). */
+ const char *ctf_parlabel; /* Label in parent dict (if any). */
const char *ctf_parname; /* Basename of parent (if any). */
char *ctf_dynparname; /* Dynamically allocated name of parent. */
uint32_t ctf_parmax; /* Highest type ID of a parent type. */
unsigned long ctf_dtoldid; /* Oldest id that has been committed. */
unsigned long ctf_snapshots; /* ctf_snapshot() plus ctf_update() count. */
unsigned long ctf_snapshot_lu; /* ctf_snapshot() call count at last update. */
- ctf_archive_t *ctf_archive; /* Archive this ctf_file_t came from. */
+ ctf_archive_t *ctf_archive; /* Archive this ctf_dict_t came from. */
ctf_list_t ctf_errs_warnings; /* CTF errors and warnings. */
ctf_dynhash_t *ctf_link_inputs; /* Inputs to this link. */
ctf_dynhash_t *ctf_link_outputs; /* Additional outputs from this link. */
void *ctf_specific; /* Data for ctf_get/setspecific(). */
};
-/* An abstraction over both a ctf_file_t and a ctf_archive_t. */
+/* An abstraction over both a ctf_dict_t and a ctf_archive_t. */
struct ctf_archive_internal
{
int ctfi_is_archive;
int ctfi_unmap_on_close;
- ctf_file_t *ctfi_file;
+ ctf_dict_t *ctfi_dict;
struct ctf_archive *ctfi_archive;
ctf_sect_t ctfi_symsect;
ctf_sect_t ctfi_strsect;
ssize_t ctn_size;
ssize_t ctn_increment;
uint32_t ctn_n;
- /* We can save space on this side of things by noting that a container is
+ /* We can save space on this side of things by noting that a dictionary is
either dynamic or not, as a whole, and a given iterator can only iterate
over one kind of thing at once: so we can overlap the DTD and non-DTD
members, and the structure, variable and enum members, etc. */
ctf_next_hkv_t *ctn_sorted_hkv;
void **ctn_hash_slot;
} u;
- /* This union is of various sorts of container we can iterate over:
+ /* This union is of various sorts of dict we can iterate over:
currently dictionaries and archives, dynhashes, and dynsets. */
union
{
- const ctf_file_t *ctn_fp;
+ const ctf_dict_t *ctn_fp;
const ctf_archive_t *ctn_arc;
const ctf_dynhash_t *ctn_h;
const ctf_dynset_t *ctn_s;
(fp, i, fp->ctf_flags & LCTF_CHILD))->dtd_data) : \
(ctf_type_t *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)]))
-#define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info))
-#define LCTF_INFO_ISROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info))
-#define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info))
+#define LCTF_INFO_KIND(fp, info) ((fp)->ctf_dictops->ctfo_get_kind(info))
+#define LCTF_INFO_ISROOT(fp, info) ((fp)->ctf_dictops->ctfo_get_root(info))
+#define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_dictops->ctfo_get_vlen(info))
#define LCTF_VBYTES(fp, kind, size, vlen) \
- ((fp)->ctf_fileops->ctfo_get_vbytes(fp, kind, size, vlen))
+ ((fp)->ctf_dictops->ctfo_get_vbytes(fp, kind, size, vlen))
-#define LCTF_CHILD 0x0001 /* CTF container is a child */
-#define LCTF_RDWR 0x0002 /* CTF container is writable */
-#define LCTF_DIRTY 0x0004 /* CTF container has been modified */
+#define LCTF_CHILD 0x0001 /* CTF dict is a child */
+#define LCTF_RDWR 0x0002 /* CTF dict is writable */
+#define LCTF_DIRTY 0x0004 /* CTF dict has been modified */
-extern ctf_names_t *ctf_name_table (ctf_file_t *, int);
-extern const ctf_type_t *ctf_lookup_by_id (ctf_file_t **, ctf_id_t);
-extern ctf_id_t ctf_lookup_by_rawname (ctf_file_t *, int, const char *);
-extern ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *, ctf_names_t *, const char *);
-extern void ctf_set_ctl_hashes (ctf_file_t *);
+extern ctf_names_t *ctf_name_table (ctf_dict_t *, int);
+extern const ctf_type_t *ctf_lookup_by_id (ctf_dict_t **, ctf_id_t);
+extern ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *, int, const char *);
+extern ctf_id_t ctf_lookup_by_rawhash (ctf_dict_t *, ctf_names_t *, const char *);
+extern void ctf_set_ctl_hashes (ctf_dict_t *);
-extern ctf_file_t *ctf_get_dict (ctf_file_t *fp, ctf_id_t type);
+extern ctf_dict_t *ctf_get_dict (ctf_dict_t *fp, ctf_id_t type);
typedef unsigned int (*ctf_hash_fun) (const void *ptr);
extern unsigned int ctf_hash_integer (const void *ptr);
void *arg);
extern ctf_hash_t *ctf_hash_create (unsigned long, ctf_hash_fun, ctf_hash_eq_fun);
-extern int ctf_hash_insert_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t);
-extern int ctf_hash_define_type (ctf_hash_t *, ctf_file_t *, uint32_t, uint32_t);
-extern ctf_id_t ctf_hash_lookup_type (ctf_hash_t *, ctf_file_t *, const char *);
+extern int ctf_hash_insert_type (ctf_hash_t *, ctf_dict_t *, uint32_t, uint32_t);
+extern int ctf_hash_define_type (ctf_hash_t *, ctf_dict_t *, uint32_t, uint32_t);
+extern ctf_id_t ctf_hash_lookup_type (ctf_hash_t *, ctf_dict_t *, const char *);
extern uint32_t ctf_hash_size (const ctf_hash_t *);
extern void ctf_hash_destroy (ctf_hash_t *);
extern void ctf_list_splice (ctf_list_t *, ctf_list_t *);
extern int ctf_list_empty_p (ctf_list_t *lp);
-extern int ctf_dtd_insert (ctf_file_t *, ctf_dtdef_t *, int flag, int kind);
-extern void ctf_dtd_delete (ctf_file_t *, ctf_dtdef_t *);
-extern ctf_dtdef_t *ctf_dtd_lookup (const ctf_file_t *, ctf_id_t);
-extern ctf_dtdef_t *ctf_dynamic_type (const ctf_file_t *, ctf_id_t);
+extern int ctf_dtd_insert (ctf_dict_t *, ctf_dtdef_t *, int flag, int kind);
+extern void ctf_dtd_delete (ctf_dict_t *, ctf_dtdef_t *);
+extern ctf_dtdef_t *ctf_dtd_lookup (const ctf_dict_t *, ctf_id_t);
+extern ctf_dtdef_t *ctf_dynamic_type (const ctf_dict_t *, ctf_id_t);
-extern int ctf_dvd_insert (ctf_file_t *, ctf_dvdef_t *);
-extern void ctf_dvd_delete (ctf_file_t *, ctf_dvdef_t *);
-extern ctf_dvdef_t *ctf_dvd_lookup (const ctf_file_t *, const char *);
+extern int ctf_dvd_insert (ctf_dict_t *, ctf_dvdef_t *);
+extern void ctf_dvd_delete (ctf_dict_t *, ctf_dvdef_t *);
+extern ctf_dvdef_t *ctf_dvd_lookup (const ctf_dict_t *, const char *);
-extern ctf_id_t ctf_add_encoded (ctf_file_t *, uint32_t, const char *,
+extern ctf_id_t ctf_add_encoded (ctf_dict_t *, uint32_t, const char *,
const ctf_encoding_t *, uint32_t kind);
-extern ctf_id_t ctf_add_reftype (ctf_file_t *, uint32_t, ctf_id_t,
+extern ctf_id_t ctf_add_reftype (ctf_dict_t *, uint32_t, ctf_id_t,
uint32_t kind);
-extern void ctf_add_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
- ctf_file_t *dst_fp, ctf_id_t dst_type);
-extern ctf_id_t ctf_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
- ctf_file_t **dst_fp);
+extern void ctf_add_type_mapping (ctf_dict_t *src_fp, ctf_id_t src_type,
+ ctf_dict_t *dst_fp, ctf_id_t dst_type);
+extern ctf_id_t ctf_type_mapping (ctf_dict_t *src_fp, ctf_id_t src_type,
+ ctf_dict_t **dst_fp);
-extern int ctf_dedup_atoms_init (ctf_file_t *);
-extern int ctf_dedup (ctf_file_t *, ctf_file_t **, uint32_t ninputs,
+extern int ctf_dedup_atoms_init (ctf_dict_t *);
+extern int ctf_dedup (ctf_dict_t *, ctf_dict_t **, uint32_t ninputs,
uint32_t *parents, int cu_mapped);
-extern void ctf_dedup_fini (ctf_file_t *, ctf_file_t **, uint32_t);
-extern ctf_file_t **ctf_dedup_emit (ctf_file_t *, ctf_file_t **,
+extern void ctf_dedup_fini (ctf_dict_t *, ctf_dict_t **, uint32_t);
+extern ctf_dict_t **ctf_dedup_emit (ctf_dict_t *, ctf_dict_t **,
uint32_t ninputs, uint32_t *parents,
uint32_t *noutputs, int cu_mapped);
extern void ctf_decl_init (ctf_decl_t *);
extern void ctf_decl_fini (ctf_decl_t *);
-extern void ctf_decl_push (ctf_decl_t *, ctf_file_t *, ctf_id_t);
+extern void ctf_decl_push (ctf_decl_t *, ctf_dict_t *, ctf_id_t);
_libctf_printflike_ (2, 3)
extern void ctf_decl_sprintf (ctf_decl_t *, const char *, ...);
extern char *ctf_decl_buf (ctf_decl_t *cd);
-extern const char *ctf_strptr (ctf_file_t *, uint32_t);
-extern const char *ctf_strraw (ctf_file_t *, uint32_t);
-extern const char *ctf_strraw_explicit (ctf_file_t *, uint32_t,
+extern const char *ctf_strptr (ctf_dict_t *, uint32_t);
+extern const char *ctf_strraw (ctf_dict_t *, uint32_t);
+extern const char *ctf_strraw_explicit (ctf_dict_t *, uint32_t,
ctf_strs_t *);
-extern int ctf_str_create_atoms (ctf_file_t *);
-extern void ctf_str_free_atoms (ctf_file_t *);
-extern uint32_t ctf_str_add (ctf_file_t *, const char *);
-extern uint32_t ctf_str_add_ref (ctf_file_t *, const char *, uint32_t *ref);
-extern int ctf_str_add_external (ctf_file_t *, const char *, uint32_t offset);
-extern void ctf_str_remove_ref (ctf_file_t *, const char *, uint32_t *ref);
-extern void ctf_str_rollback (ctf_file_t *, ctf_snapshot_id_t);
-extern void ctf_str_purge_refs (ctf_file_t *);
-extern ctf_strs_writable_t ctf_str_write_strtab (ctf_file_t *);
+extern int ctf_str_create_atoms (ctf_dict_t *);
+extern void ctf_str_free_atoms (ctf_dict_t *);
+extern uint32_t ctf_str_add (ctf_dict_t *, const char *);
+extern uint32_t ctf_str_add_ref (ctf_dict_t *, const char *, uint32_t *ref);
+extern int ctf_str_add_external (ctf_dict_t *, const char *, uint32_t offset);
+extern void ctf_str_remove_ref (ctf_dict_t *, const char *, uint32_t *ref);
+extern void ctf_str_rollback (ctf_dict_t *, ctf_snapshot_id_t);
+extern void ctf_str_purge_refs (ctf_dict_t *);
+extern ctf_strs_writable_t ctf_str_write_strtab (ctf_dict_t *);
extern struct ctf_archive_internal *
ctf_new_archive_internal (int is_archive, int unmap_on_close,
- struct ctf_archive *, ctf_file_t *,
+ struct ctf_archive *, ctf_dict_t *,
const ctf_sect_t *symsect,
const ctf_sect_t *strsect, int *errp);
extern struct ctf_archive *ctf_arc_open_internal (const char *, int *);
extern void ctf_arc_close_internal (struct ctf_archive *);
extern void *ctf_set_open_errno (int *, int);
-extern unsigned long ctf_set_errno (ctf_file_t *, int);
+extern unsigned long ctf_set_errno (ctf_dict_t *, int);
-extern ctf_file_t *ctf_simple_open_internal (const char *, size_t, const char *,
+extern ctf_dict_t *ctf_simple_open_internal (const char *, size_t, const char *,
size_t, size_t,
const char *, size_t,
ctf_dynhash_t *, int, int *);
-extern ctf_file_t *ctf_bufopen_internal (const ctf_sect_t *, const ctf_sect_t *,
+extern ctf_dict_t *ctf_bufopen_internal (const ctf_sect_t *, const ctf_sect_t *,
const ctf_sect_t *, ctf_dynhash_t *,
int, int *);
-extern int ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp);
-extern int ctf_serialize (ctf_file_t *);
+extern int ctf_import_unref (ctf_dict_t *fp, ctf_dict_t *pfp);
+extern int ctf_serialize (ctf_dict_t *);
_libctf_malloc_
extern void *ctf_mmap (size_t length, size_t offset, int fd);
extern void ctf_munmap (void *, size_t);
extern ssize_t ctf_pread (int fd, void *buf, ssize_t count, off_t offset);
-extern void *ctf_realloc (ctf_file_t *, void *, size_t);
+extern void *ctf_realloc (ctf_dict_t *, void *, size_t);
extern char *ctf_str_append (char *, const char *);
extern char *ctf_str_append_noerr (char *, const char *);
-extern ctf_id_t ctf_type_resolve_unsliced (ctf_file_t *, ctf_id_t);
-extern int ctf_type_kind_unsliced (ctf_file_t *, ctf_id_t);
+extern ctf_id_t ctf_type_resolve_unsliced (ctf_dict_t *, ctf_id_t);
+extern int ctf_type_kind_unsliced (ctf_dict_t *, ctf_id_t);
_libctf_printflike_ (1, 2)
extern void ctf_dprintf (const char *, ...);
extern void libctf_init_debug (void);
_libctf_printflike_ (4, 5)
-extern void ctf_err_warn (ctf_file_t *, int is_warning, int err,
+extern void ctf_err_warn (ctf_dict_t *, int is_warning, int err,
const char *, ...);
-extern void ctf_err_warn_to_open (ctf_file_t *);
-extern void ctf_assert_fail_internal (ctf_file_t *, const char *,
+extern void ctf_err_warn_to_open (ctf_dict_t *);
+extern void ctf_assert_fail_internal (ctf_dict_t *, const char *,
size_t, const char *);
-extern const char *ctf_link_input_name (ctf_file_t *);
+extern const char *ctf_link_input_name (ctf_dict_t *);
extern Elf64_Sym *ctf_sym_to_elf64 (const Elf32_Sym *src, Elf64_Sym *dst);
-extern const char *ctf_lookup_symbol_name (ctf_file_t *fp, unsigned long symidx);
+extern const char *ctf_lookup_symbol_name (ctf_dict_t *fp, unsigned long symidx);
/* Variables, all underscore-prepended. */
#endif
static inline ssize_t
-ctf_get_ctt_size (const ctf_file_t *fp,
+ctf_get_ctt_size (const ctf_dict_t *fp,
const ctf_type_t *tp,
ssize_t *sizep,
ssize_t *incrementp)
{
- return (fp->ctf_fileops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
+ return (fp->ctf_dictops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
}
static inline int
}
static inline int
-ctf_assert_internal (ctf_file_t *fp, const char *file, size_t line,
+ctf_assert_internal (ctf_dict_t *fp, const char *file, size_t line,
const char *exprstr, int expr)
{
if (_libctf_unlikely_ (!expr))
#include <string.h>
static int
-extract_label_info (ctf_file_t *fp, const ctf_lblent_t **ctl,
+extract_label_info (ctf_dict_t *fp, const ctf_lblent_t **ctl,
uint32_t *num_labels)
{
const ctf_header_t *h;
/* Returns the topmost label, or NULL if any errors are encountered. */
const char *
-ctf_label_topmost (ctf_file_t *fp)
+ctf_label_topmost (ctf_dict_t *fp)
{
const ctf_lblent_t *ctlp = NULL;
const char *s;
/* Iterate over all labels. We pass the label string and the lblinfo_t struct
to the specified callback function. */
int
-ctf_label_iter (ctf_file_t *fp, ctf_label_f *func, void *arg)
+ctf_label_iter (ctf_dict_t *fp, ctf_label_f *func, void *arg)
{
const ctf_lblent_t *ctlp = NULL;
uint32_t i;
/* Retrieve information about the label with name "lname". */
int
-ctf_label_info (ctf_file_t *fp, const char *lname, ctf_lblinfo_t *linfo)
+ctf_label_info (ctf_dict_t *fp, const char *lname, ctf_lblinfo_t *linfo)
{
linfo_cb_arg_t cb_arg;
int rc;
/* Record the correspondence between a source and ctf_add_type()-added
destination type: both types are translated into parent type IDs if need be,
- so they relate to the actual container they are in. Outside controlled
+ so they relate to the actual dictionary they are in. Outside controlled
circumstances (like linking) it is probably not useful to do more than
compare these pointers, since there is nothing stopping the user closing the
- source container whenever they want to.
+ source dict whenever they want to.
Our OOM handling here is just to not do anything, because this is called deep
enough in the call stack that doing anything useful is painfully difficult:
the worst consequence if we do OOM is a bit of type duplication anyway. */
void
-ctf_add_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
- ctf_file_t *dst_fp, ctf_id_t dst_type)
+ctf_add_type_mapping (ctf_dict_t *src_fp, ctf_id_t src_type,
+ ctf_dict_t *dst_fp, ctf_id_t dst_type)
{
if (LCTF_TYPE_ISPARENT (src_fp, src_type) && src_fp->ctf_parent)
src_fp = src_fp->ctf_parent;
/* Look up a type mapping: return 0 if none. The DST_FP is modified to point to
the parent if need be. The ID returned is from the dst_fp's perspective. */
ctf_id_t
-ctf_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t **dst_fp)
+ctf_type_mapping (ctf_dict_t *src_fp, ctf_id_t src_type, ctf_dict_t **dst_fp)
{
ctf_link_type_key_t key;
- ctf_file_t *target_fp = *dst_fp;
+ ctf_dict_t *target_fp = *dst_fp;
ctf_id_t dst_type = 0;
if (LCTF_TYPE_ISPARENT (src_fp, src_type) && src_fp->ctf_parent)
to, or a non-null string otherwise: prefer the parent. Used in debugging
output. Sometimes used for outputs too. */
const char *
-ctf_link_input_name (ctf_file_t *fp)
+ctf_link_input_name (ctf_dict_t *fp)
{
if (fp->ctf_parent && fp->ctf_parent->ctf_cuname)
return fp->ctf_parent->ctf_cuname;
/* The linker inputs look like this. clin_fp is used for short-circuited
CU-mapped links that can entirely avoid the first link phase in some
- situations in favour of just passing on the contained ctf_file_t: it is
- always the sole ctf_file_t inside the corresponding clin_arc. If set, it
+ situations in favour of just passing on the contained ctf_dict_t: it is
+ always the sole ctf_dict_t inside the corresponding clin_arc. If set, it
gets assigned directly to the final link inputs and freed from there, so it
never gets explicitly freed in the ctf_link_input. */
typedef struct ctf_link_input
{
const char *clin_filename;
ctf_archive_t *clin_arc;
- ctf_file_t *clin_fp;
+ ctf_dict_t *clin_fp;
int n;
} ctf_link_input_t;
/* Like ctf_link_add_ctf, below, but with no error-checking, so it can be called
in the middle of an ongoing link. */
static int
-ctf_link_add_ctf_internal (ctf_file_t *fp, ctf_archive_t *ctf,
- ctf_file_t *fp_input, const char *name)
+ctf_link_add_ctf_internal (ctf_dict_t *fp, ctf_archive_t *ctf,
+ ctf_dict_t *fp_input, const char *name)
{
ctf_link_input_t *input = NULL;
char *dupname = NULL;
implemented. */
static int
-ctf_link_add (ctf_file_t *fp, ctf_archive_t *ctf, const char *name,
+ctf_link_add (ctf_dict_t *fp, ctf_archive_t *ctf, const char *name,
void *buf _libctf_unused_, size_t n _libctf_unused_)
{
if (buf)
final link output, but otherwise is not important. */
int
-ctf_link_add_ctf (ctf_file_t *fp, ctf_archive_t *ctf, const char *name)
+ctf_link_add_ctf (ctf_dict_t *fp, ctf_archive_t *ctf, const char *name)
{
return ctf_link_add (fp, ctf, name, NULL, 0);
}
/* Return a per-CU output CTF dictionary suitable for the given CU, creating and
interning it if need be. */
-static ctf_file_t *
-ctf_create_per_cu (ctf_file_t *fp, const char *filename, const char *cuname)
+static ctf_dict_t *
+ctf_create_per_cu (ctf_dict_t *fp, const char *filename, const char *cuname)
{
- ctf_file_t *cu_fp;
+ ctf_dict_t *cu_fp;
const char *ctf_name = NULL;
char *dynname = NULL;
oom:
free (dynname);
- ctf_file_close (cu_fp);
+ ctf_dict_close (cu_fp);
ctf_set_errno (fp, ENOMEM);
return NULL;
}
/* Add a mapping directing that the CU named FROM should have its
- conflicting/non-duplicate types (depending on link mode) go into a container
+ conflicting/non-duplicate types (depending on link mode) go into a dict
named TO. Many FROMs can share a TO.
- We forcibly add a container named TO in every case, even though it may well
+ We forcibly add a dict named TO in every case, even though it may well
wind up empty, because clients that use this facility usually expect to find
- every TO container present, even if empty, and malfunction otherwise. */
+ every TO dict present, even if empty, and malfunction otherwise. */
int
-ctf_link_add_cu_mapping (ctf_file_t *fp, const char *from, const char *to)
+ctf_link_add_cu_mapping (ctf_dict_t *fp, const char *from, const char *to)
{
int err;
char *f = NULL, *t = NULL;
The changer function accepts a name and should return a new
dynamically-allocated name, or NULL if the name should be left unchanged. */
void
-ctf_link_set_memb_name_changer (ctf_file_t *fp,
+ctf_link_set_memb_name_changer (ctf_dict_t *fp,
ctf_link_memb_name_changer_f *changer,
void *arg)
{
typedef struct ctf_link_in_member_cb_arg
{
/* The shared output dictionary. */
- ctf_file_t *out_fp;
+ ctf_dict_t *out_fp;
/* The filename of the input file, and an fp to each dictionary in that file
in turn. */
const char *in_file_name;
- ctf_file_t *in_fp;
+ ctf_dict_t *in_fp;
/* The CU name of the dict being processed. */
const char *cu_name;
/* The parent dictionary in the input, and whether it's been processed yet.
Not needed by ctf_link_one_type / ctf_link_one_variable, only by higher
layers. */
- ctf_file_t *in_fp_parent;
+ ctf_dict_t *in_fp_parent;
int done_parent;
/* If true, this is the CU-mapped portion of a deduplicating link: no child
ctf_link_one_type (ctf_id_t type, int isroot _libctf_unused_, void *arg_)
{
ctf_link_in_member_cb_arg_t *arg = (ctf_link_in_member_cb_arg_t *) arg_;
- ctf_file_t *per_cu_out_fp;
+ ctf_dict_t *per_cu_out_fp;
int err;
if (arg->in_fp->ctf_link_flags != CTF_LINK_SHARE_UNCONFLICTED)
/* Set a function which is used to filter out unwanted variables from the link. */
int
-ctf_link_set_variable_filter (ctf_file_t *fp, ctf_link_variable_filter_f *filter,
+ctf_link_set_variable_filter (ctf_dict_t *fp, ctf_link_variable_filter_f *filter,
void *arg)
{
fp->ctf_link_variable_filter = filter;
return 0;
}
-/* Check if we can safely add a variable with the given type to this container. */
+/* Check if we can safely add a variable with the given type to this dict. */
static int
-check_variable (const char *name, ctf_file_t *fp, ctf_id_t type,
+check_variable (const char *name, ctf_dict_t *fp, ctf_id_t type,
ctf_dvdef_t **out_dvd)
{
ctf_dvdef_t *dvd;
ctf_link_one_variable (const char *name, ctf_id_t type, void *arg_)
{
ctf_link_in_member_cb_arg_t *arg = (ctf_link_in_member_cb_arg_t *) arg_;
- ctf_file_t *per_cu_out_fp;
+ ctf_dict_t *per_cu_out_fp;
ctf_id_t dst_type = 0;
- ctf_file_t *check_fp;
+ ctf_dict_t *check_fp;
ctf_dvdef_t *dvd;
/* See if this variable is filtered out. */
}
/* In unconflicted link mode, if this type is mapped to a type in the parent
- container, we want to try to add to that first: if it reports a duplicate,
+ dict, we want to try to add to that first: if it reports a duplicate,
or if the type is in a child already, add straight to the child. */
check_fp = arg->out_fp;
ambiguous types if there is one and it's not the default: otherwise, we use
the name of the input file. */
static int
-ctf_link_one_input_archive_member (ctf_file_t *in_fp, const char *name, void *arg_)
+ctf_link_one_input_archive_member (ctf_dict_t *in_fp, const char *name, void *arg_)
{
ctf_link_in_member_cb_arg_t *arg = (ctf_link_in_member_cb_arg_t *) arg_;
int err = 0;
empty_link_type_mapping (void *key _libctf_unused_, void *value,
void *arg _libctf_unused_)
{
- ctf_file_t *fp = (ctf_file_t *) value;
+ ctf_dict_t *fp = (ctf_dict_t *) value;
if (fp->ctf_link_type_mapping)
ctf_dynhash_empty (fp->ctf_link_type_mapping);
Returns the number of files contained within the opened archive (0 for none),
or -1 on error, as usual. */
static ssize_t
-ctf_link_lazy_open (ctf_file_t *fp, ctf_link_input_t *input)
+ctf_link_lazy_open (ctf_dict_t *fp, ctf_link_input_t *input)
{
size_t count;
int err;
if (ctf_link_one_input_archive_member (arg->in_fp_parent,
_CTF_SECTION, arg) < 0)
{
- ctf_file_close (arg->in_fp_parent);
+ ctf_dict_close (arg->in_fp_parent);
goto out;
}
arg->done_parent = 1;
is zero if there was no actual error from the caller. */
ctf_set_errno (arg->out_fp, 0);
}
- ctf_file_close (arg->in_fp_parent);
+ ctf_dict_close (arg->in_fp_parent);
out:
ctf_link_close_one_input_archive (key, value, NULL);
typedef struct link_sort_inputs_cb_arg
{
int is_cu_mapped;
- ctf_file_t *fp;
+ ctf_dict_t *fp;
} link_sort_inputs_cb_arg_t;
/* Sort the inputs by N (the link order). For CU-mapped links, this is a
and optionally the name and ctf_link_input_t of the single input archive if
only one exists (no matter how many dicts it contains). */
static ssize_t
-ctf_link_deduplicating_count_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
+ctf_link_deduplicating_count_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names,
ctf_link_input_t **only_one_input)
{
ctf_dynhash_t *inputs = fp->ctf_link_inputs;
If no inputs exist that correspond to these CUs, return NULL with the errno
set to ECTF_NOCTFDATA. */
-static ctf_file_t **
-ctf_link_deduplicating_open_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
+static ctf_dict_t **
+ctf_link_deduplicating_open_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names,
ssize_t ninputs, uint32_t **parents)
{
ctf_dynhash_t *inputs = fp->ctf_link_inputs;
ctf_next_t *i = NULL;
void *name, *input;
link_sort_inputs_cb_arg_t sort_arg;
- ctf_file_t **dedup_inputs = NULL;
- ctf_file_t **walk;
+ ctf_dict_t **dedup_inputs = NULL;
+ ctf_dict_t **walk;
uint32_t *parents_ = NULL;
int err;
if (cu_names)
inputs = cu_names;
- if ((dedup_inputs = calloc (ninputs, sizeof (ctf_file_t *))) == NULL)
+ if ((dedup_inputs = calloc (ninputs, sizeof (ctf_dict_t *))) == NULL)
goto oom;
if ((parents_ = calloc (ninputs, sizeof (uint32_t))) == NULL)
{
const char *one_name = (const char *) name;
ctf_link_input_t *one_input;
- ctf_file_t *one_fp;
- ctf_file_t *parent_fp = NULL;
+ ctf_dict_t *one_fp;
+ ctf_dict_t *parent_fp = NULL;
uint32_t parent_i;
ctf_next_t *j = NULL;
CU_NAMES. If CU_NAMES is not specified, close all the ctf_link_inputs in one
go, leaving it empty. */
static int
-ctf_link_deduplicating_close_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
- ctf_file_t **inputs, ssize_t ninputs)
+ctf_link_deduplicating_close_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names,
+ ctf_dict_t **inputs, ssize_t ninputs)
{
ctf_next_t *it = NULL;
void *name;
/* This is the inverse of ctf_link_deduplicating_open_inputs: so first, close
all the individual input dicts, opened by the archive iterator. */
for (i = 0; i < ninputs; i++)
- ctf_file_close (inputs[i]);
+ ctf_dict_close (inputs[i]);
/* Now close the archives they are part of. */
if (cu_names)
/* Do a deduplicating link of all variables in the inputs. */
static int
-ctf_link_deduplicating_variables (ctf_file_t *fp, ctf_file_t **inputs,
+ctf_link_deduplicating_variables (ctf_dict_t *fp, ctf_dict_t **inputs,
size_t ninputs, int cu_mapped)
{
ctf_link_in_member_cb_arg_t arg;
/* Do the per-CU part of a deduplicating link. */
static int
-ctf_link_deduplicating_per_cu (ctf_file_t *fp)
+ctf_link_deduplicating_per_cu (ctf_dict_t *fp)
{
ctf_next_t *i = NULL;
int err;
{
const char *out_name = (const char *) out_cu;
ctf_dynhash_t *in = (ctf_dynhash_t *) in_cus;
- ctf_file_t *out = NULL;
- ctf_file_t **inputs;
- ctf_file_t **outputs;
+ ctf_dict_t *out = NULL;
+ ctf_dict_t **inputs;
+ ctf_dict_t **outputs;
ctf_archive_t *in_arc;
ssize_t ninputs;
ctf_link_input_t *only_input;
goto err_outputs;
}
- ctf_file_close (out);
+ ctf_dict_close (out);
free (outputs);
continue;
err_inputs_outputs:
ctf_list_splice (&fp->ctf_errs_warnings, &outputs[0]->ctf_errs_warnings);
- ctf_file_close (outputs[0]);
+ ctf_dict_close (outputs[0]);
free (outputs);
err_inputs:
ctf_link_deduplicating_close_inputs (fp, in, inputs, ninputs);
- ctf_file_close (out);
+ ctf_dict_close (out);
free (inputs);
free (parents);
err_open_inputs:
err_outputs:
ctf_list_splice (&fp->ctf_errs_warnings, &outputs[0]->ctf_errs_warnings);
- ctf_file_close (outputs[0]);
+ ctf_dict_close (outputs[0]);
free (outputs);
ctf_next_destroy (i);
return -1; /* Errno is set for us. */
/* Do a deduplicating link using the ctf-dedup machinery. */
static void
-ctf_link_deduplicating (ctf_file_t *fp)
+ctf_link_deduplicating (ctf_dict_t *fp)
{
size_t i;
- ctf_file_t **inputs, **outputs = NULL;
+ ctf_dict_t **inputs, **outputs = NULL;
ssize_t ninputs;
uint32_t noutputs;
uint32_t *parents;
/* We already have access to this one. Close the duplicate. */
if (i == 0)
{
- ctf_file_close (outputs[0]);
+ ctf_dict_close (outputs[0]);
continue;
}
free (dynname);
for (; i < noutputs; i++)
- ctf_file_close (outputs[i]);
+ ctf_dict_close (outputs[i]);
goto err;
}
ctf_err_warn (fp, 0, 0, _("deduplicating link variable emission failed for "
"%s"), ctf_link_input_name (fp));
for (i = 1; i < noutputs; i++)
- ctf_file_close (outputs[i]);
+ ctf_dict_close (outputs[i]);
goto err;
}
err:
for (i = 0; i < (size_t) ninputs; i++)
- ctf_file_close (inputs[i]);
+ ctf_dict_close (inputs[i]);
free (inputs);
free (parents);
free (outputs);
/* Merge types and variable sections in all files added to the link
together. All the added files are closed. */
int
-ctf_link (ctf_file_t *fp, int flags)
+ctf_link (ctf_dict_t *fp, int flags)
{
ctf_link_in_member_cb_arg_t arg;
ctf_next_t *i = NULL;
fp->ctf_link_outputs = ctf_dynhash_create (ctf_hash_string,
ctf_hash_eq_string, free,
(ctf_hash_free_fun)
- ctf_file_close);
+ ctf_dict_close);
if (fp->ctf_link_outputs == NULL)
return ctf_set_errno (fp, ENOMEM);
ctf_link_intern_extern_string (void *key _libctf_unused_, void *value,
void *arg_)
{
- ctf_file_t *fp = (ctf_file_t *) value;
+ ctf_dict_t *fp = (ctf_dict_t *) value;
ctf_link_out_string_cb_arg_t *arg = (ctf_link_out_string_cb_arg_t *) arg_;
fp->ctf_flags |= LCTF_DIRTY;
files ctf_link() can create to get their strings dedupped against the ELF
strtab properly. */
int
-ctf_link_add_strtab (ctf_file_t *fp, ctf_link_strtab_string_f *add_string,
+ctf_link_add_strtab (ctf_dict_t *fp, ctf_link_strtab_string_f *add_string,
void *arg)
{
const char *str;
/* Not yet implemented. */
int
-ctf_link_shuffle_syms (ctf_file_t *fp _libctf_unused_,
+ctf_link_shuffle_syms (ctf_dict_t *fp _libctf_unused_,
ctf_link_iter_symbol_f *add_sym _libctf_unused_,
void *arg _libctf_unused_)
{
typedef struct ctf_name_list_accum_cb_arg
{
char **names;
- ctf_file_t *fp;
- ctf_file_t **files;
+ ctf_dict_t *fp;
+ ctf_dict_t **files;
size_t i;
char **dynames;
size_t ndynames;
ctf_accumulate_archive_names (void *key, void *value, void *arg_)
{
const char *name = (const char *) key;
- ctf_file_t *fp = (ctf_file_t *) value;
+ ctf_dict_t *fp = (ctf_dict_t *) value;
char **names;
- ctf_file_t **files;
+ ctf_dict_t **files;
ctf_name_list_accum_cb_arg_t *arg = (ctf_name_list_accum_cb_arg_t *) arg_;
if ((names = realloc (arg->names, sizeof (char *) * ++(arg->i))) == NULL)
return;
}
- if ((files = realloc (arg->files, sizeof (ctf_file_t *) * arg->i)) == NULL)
+ if ((files = realloc (arg->files, sizeof (ctf_dict_t *) * arg->i)) == NULL)
{
(arg->i)--;
ctf_set_errno (arg->fp, ENOMEM);
static void
ctf_change_parent_name (void *key _libctf_unused_, void *value, void *arg)
{
- ctf_file_t *fp = (ctf_file_t *) value;
+ ctf_dict_t *fp = (ctf_dict_t *) value;
const char *name = (const char *) arg;
ctf_parent_name_set (fp, name);
(otherwise) into a new dynamically-allocated string, and return it.
Members with sizes above THRESHOLD are compressed. */
unsigned char *
-ctf_link_write (ctf_file_t *fp, size_t *size, size_t threshold)
+ctf_link_write (ctf_dict_t *fp, size_t *size, size_t threshold)
{
ctf_name_list_accum_cb_arg_t arg;
char **names;
char *transformed_name = NULL;
- ctf_file_t **files;
+ ctf_dict_t **files;
FILE *f = NULL;
int err;
long fsize;
}
}
- /* No extra outputs? Just write a simple ctf_file_t. */
+ /* No extra outputs? Just write a simple ctf_dict_t. */
if (arg.i == 0)
return ctf_write_mem (fp, size, threshold);
}
if ((files = realloc (arg.files,
- sizeof (struct ctf_file *) * (arg.i + 1))) == NULL)
+ sizeof (struct ctf_dict *) * (arg.i + 1))) == NULL)
{
- errloc = "ctf_file reallocation";
+ errloc = "ctf_dict reallocation";
goto err_no;
}
arg.files = files;
- memmove (&(arg.files[1]), arg.files, sizeof (ctf_file_t *) * (arg.i));
+ memmove (&(arg.files[1]), arg.files, sizeof (ctf_dict_t *) * (arg.i));
arg.files[0] = fp;
if ((f = tmpfile ()) == NULL)
integers, floats, typedefs, and pointers to any of these named types. */
ctf_id_t
-ctf_lookup_by_name (ctf_file_t *fp, const char *name)
+ctf_lookup_by_name (ctf_dict_t *fp, const char *name)
{
static const char delimiters[] = " \t\n\r\v\f*";
data includes "struct foo *" but not "foo_t *" and
the user tries to access "foo_t *" in the debugger.
- TODO need to handle parent containers too. */
+ TODO need to handle parent dicts too. */
ntype = fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX (fp, type)];
if (ntype == 0)
typedef struct ctf_lookup_var_key
{
- ctf_file_t *clvk_fp;
+ ctf_dict_t *clvk_fp;
const char *clvk_name;
} ctf_lookup_var_key_t;
/* Given a variable name, return the type of the variable with that name. */
ctf_id_t
-ctf_lookup_variable (ctf_file_t *fp, const char *name)
+ctf_lookup_variable (ctf_dict_t *fp, const char *name)
{
ctf_varent_t *ent;
ctf_lookup_var_key_t key = { fp, name };
/* Given a symbol table index, return the name of that symbol from the secondary
string table, or the null string (never NULL). */
const char *
-ctf_lookup_symbol_name (ctf_file_t *fp, unsigned long symidx)
+ctf_lookup_symbol_name (ctf_dict_t *fp, unsigned long symidx)
{
const ctf_sect_t *sp = &fp->ctf_symtab;
Elf64_Sym sym, *gsp;
by the corresponding entry in the symbol table. */
ctf_id_t
-ctf_lookup_by_symbol (ctf_file_t *fp, unsigned long symidx)
+ctf_lookup_by_symbol (ctf_dict_t *fp, unsigned long symidx)
{
const ctf_sect_t *sp = &fp->ctf_symtab;
ctf_id_t type;
/* Return the native dict of a given type: if called on a child and the
type is in the parent, return the parent. Needed if you plan to access
the type directly, without using the API. */
-ctf_file_t *
-ctf_get_dict (ctf_file_t *fp, ctf_id_t type)
+ctf_dict_t *
+ctf_get_dict (ctf_dict_t *fp, ctf_id_t type)
{
if ((fp->ctf_flags & LCTF_CHILD) && LCTF_TYPE_ISPARENT (fp, type))
return fp->ctf_parent;
This function is not exported outside of the library. */
const ctf_type_t *
-ctf_lookup_by_id (ctf_file_t **fpp, ctf_id_t type)
+ctf_lookup_by_id (ctf_dict_t **fpp, ctf_id_t type)
{
- ctf_file_t *fp = *fpp; /* Caller passes in starting CTF dict. */
+ ctf_dict_t *fp = *fpp; /* Caller passes in starting CTF dict. */
ctf_id_t idx;
if ((fp = ctf_get_dict (fp, type)) == NULL)
idx = LCTF_TYPE_TO_INDEX (fp, type);
if (idx > 0 && (unsigned long) idx <= fp->ctf_typemax)
{
- *fpp = fp; /* Function returns ending CTF container. */
+ *fpp = fp; /* Function returns ending CTF dict. */
return (LCTF_INDEX_TO_TYPEPTR (fp, idx));
}
by the corresponding entry in the symbol table. */
int
-ctf_func_info (ctf_file_t *fp, unsigned long symidx, ctf_funcinfo_t *fip)
+ctf_func_info (ctf_dict_t *fp, unsigned long symidx, ctf_funcinfo_t *fip)
{
const ctf_sect_t *sp = &fp->ctf_symtab;
const uint32_t *dp;
by the corresponding entry in the symbol table. */
int
-ctf_func_args (ctf_file_t * fp, unsigned long symidx, uint32_t argc,
+ctf_func_args (ctf_dict_t *fp, unsigned long symidx, uint32_t argc,
ctf_id_t * argv)
{
const uint32_t *dp;
}
/* Open the specified file descriptor and return a pointer to a CTF archive that
- contains one or more CTF containers. The file can be an ELF file, a raw CTF
- file, or a CTF archive. The caller is responsible for closing the file
- descriptor when it is no longer needed. If this is an ELF file, TARGET, if
- non-NULL, should be the name of a suitable BFD target. */
+ contains one or more CTF dicts. The file can be an ELF file, a file
+ containing raw CTF, or a CTF archive. The caller is responsible for closing
+ the file descriptor when it is no longer needed. If this is an ELF file,
+ TARGET, if non-NULL, should be the name of a suitable BFD target. */
ctf_archive_t *
ctf_fdopen (int fd, const char *filename, const char *target, int *errp)
&& (ctfhdr.ctp_magic == CTF_MAGIC
|| ctfhdr.ctp_magic == bswap_16 (CTF_MAGIC)))
{
- ctf_file_t *fp = NULL;
+ ctf_dict_t *fp = NULL;
void *data;
if ((data = ctf_mmap (st.st_size, 0, fd)) == NULL)
return arci;
}
-/* Open the specified file and return a pointer to a CTF container. The file
+/* Open the specified file and return a pointer to a CTF dict. The file
can be either an ELF file or raw CTF file. This is just a convenient
wrapper around ctf_fdopen() for callers. */
}
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,
}
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;
/* 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;
}
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,
}
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)
}
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)
{
}
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)
{
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},
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;
}
/* 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;
+ 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
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];
}
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;
/* 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)
{
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;
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;
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. */
}
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)
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;
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);
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. */
/* 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,
/* 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,
}
/* 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)
{
/* 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)
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;
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;
}
/* 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
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;
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)
{
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)
{
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
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;
}
/* 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);
}
/* 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);
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));
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)
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));
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)
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;
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;
}
/* Convert an encoded CTF string name into a pointer to a C string, using an
explicit internal strtab rather than the fp-based one. */
const char *
-ctf_strraw_explicit (ctf_file_t *fp, uint32_t name, ctf_strs_t *strtab)
+ctf_strraw_explicit (ctf_dict_t *fp, uint32_t name, ctf_strs_t *strtab)
{
ctf_strs_t *ctsp = &fp->ctf_str[CTF_NAME_STID (name)];
/* Convert an encoded CTF string name into a pointer to a C string by looking
up the appropriate string table buffer and then adding the offset. */
const char *
-ctf_strraw (ctf_file_t *fp, uint32_t name)
+ctf_strraw (ctf_dict_t *fp, uint32_t name)
{
return ctf_strraw_explicit (fp, name, NULL);
}
/* Return a guaranteed-non-NULL pointer to the string with the given CTF
name. */
const char *
-ctf_strptr (ctf_file_t *fp, uint32_t name)
+ctf_strptr (ctf_dict_t *fp, uint32_t name)
{
const char *s = ctf_strraw (fp, name);
return (s != NULL ? s : "(?)");
/* Create the atoms table. There is always at least one atom in it, the null
string. */
int
-ctf_str_create_atoms (ctf_file_t *fp)
+ctf_str_create_atoms (ctf_dict_t *fp)
{
fp->ctf_str_atoms = ctf_dynhash_create (ctf_hash_string, ctf_hash_eq_string,
free, ctf_str_free_atom);
/* Destroy the atoms table. */
void
-ctf_str_free_atoms (ctf_file_t *fp)
+ctf_str_free_atoms (ctf_dict_t *fp)
{
ctf_dynhash_destroy (fp->ctf_prov_strtab);
ctf_dynhash_destroy (fp->ctf_str_atoms);
passed-in ref. Possibly add a provisional entry for this string to the
provisional strtab. */
static ctf_str_atom_t *
-ctf_str_add_ref_internal (ctf_file_t *fp, const char *str,
+ctf_str_add_ref_internal (ctf_dict_t *fp, const char *str,
int add_ref, int make_provisional, uint32_t *ref)
{
char *newstr = NULL;
provisional offset is assigned to should be added as a ref using
ctf_str_add_ref() as well.) */
uint32_t
-ctf_str_add (ctf_file_t *fp, const char *str)
+ctf_str_add (ctf_dict_t *fp, const char *str)
{
ctf_str_atom_t *atom;
if (!str)
passed-in ref, whether or not the string is already present. There is no
attempt to deduplicate the refs list (but duplicates are harmless). */
uint32_t
-ctf_str_add_ref (ctf_file_t *fp, const char *str, uint32_t *ref)
+ctf_str_add_ref (ctf_dict_t *fp, const char *str, uint32_t *ref)
{
ctf_str_atom_t *atom;
if (!str)
/* Add an external strtab reference at OFFSET. Returns zero if the addition
failed, nonzero otherwise. */
int
-ctf_str_add_external (ctf_file_t *fp, const char *str, uint32_t offset)
+ctf_str_add_external (ctf_dict_t *fp, const char *str, uint32_t offset)
{
ctf_str_atom_t *atom;
if (!str)
/* Remove a single ref. */
void
-ctf_str_remove_ref (ctf_file_t *fp, const char *str, uint32_t *ref)
+ctf_str_remove_ref (ctf_dict_t *fp, const char *str, uint32_t *ref)
{
ctf_str_atom_ref_t *aref, *anext;
ctf_str_atom_t *atom = NULL;
/* Roll back, deleting all atoms created after a particular ID. */
void
-ctf_str_rollback (ctf_file_t *fp, ctf_snapshot_id_t id)
+ctf_str_rollback (ctf_dict_t *fp, ctf_snapshot_id_t id)
{
ctf_dynhash_iter_remove (fp->ctf_str_atoms, ctf_str_rollback_atom, &id);
}
/* Remove all the recorded refs from the atoms table. */
void
-ctf_str_purge_refs (ctf_file_t *fp)
+ctf_str_purge_refs (ctf_dict_t *fp)
{
if (fp->ctf_str_num_refs > 0)
ctf_dynhash_iter (fp->ctf_str_atoms, ctf_str_purge_one_atom_refs, NULL);
external strtab offsets to names, so we can look them up with ctf_strptr().
Only external strtab offsets with references are added. */
ctf_strs_writable_t
-ctf_str_write_strtab (ctf_file_t *fp)
+ctf_str_write_strtab (ctf_dict_t *fp)
{
ctf_strs_writable_t strtab;
ctf_str_atom_t *nullstr;
This is safe because you cannot ctf_rollback to before the point
when a ctf_update is done, and the strtab is written at ctf_update
time. So any atoms we reference here are sure to stick around
- until ctf_file_close. */
+ until ctf_dict_close. */
any_external = 1;
ctf_str_update_refs (sorttab[i], sorttab[i]->csa_external_offset);
debug stream instead of that recorded on fp. */
_libctf_printflike_ (4, 5)
extern void
-ctf_err_warn (ctf_file_t *fp, int is_warning, int err,
+ctf_err_warn (ctf_dict_t *fp, int is_warning, int err,
const char *format, ...)
{
va_list alist;
/* Move all the errors/warnings from an fp into the open_errors. */
void
-ctf_err_warn_to_open (ctf_file_t *fp)
+ctf_err_warn_to_open (ctf_dict_t *fp)
{
ctf_list_splice (&open_errors, &fp->ctf_errs_warnings);
}
means the end, and not an iterator error. */
char *
-ctf_errwarning_next (ctf_file_t *fp, ctf_next_t **it, int *is_warning,
+ctf_errwarning_next (ctf_dict_t *fp, ctf_next_t **it, int *is_warning,
int *errp)
{
ctf_next_t *i = *it;
}
void
-ctf_assert_fail_internal (ctf_file_t *fp, const char *file, size_t line,
+ctf_assert_fail_internal (ctf_dict_t *fp, const char *file, size_t line,
const char *exprstr)
{
ctf_err_warn (fp, 0, ECTF_INTERNAL, _("%s: %lu: libctf assertion failed: %s"),
/* Determine whether a type is a parent or a child. */
int
-ctf_type_isparent (ctf_file_t *fp, ctf_id_t id)
+ctf_type_isparent (ctf_dict_t *fp, ctf_id_t id)
{
return (LCTF_TYPE_ISPARENT (fp, id));
}
int
-ctf_type_ischild (ctf_file_t * fp, ctf_id_t id)
+ctf_type_ischild (ctf_dict_t * fp, ctf_id_t id)
{
return (LCTF_TYPE_ISCHILD (fp, id));
}
type, and offset of each member to the specified callback function. */
int
-ctf_member_iter (ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
+ctf_member_iter (ctf_dict_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
ctf_dtdef_t *dtd;
ssize_t size, increment;
returns -1. */
ssize_t
-ctf_member_next (ctf_file_t *fp, ctf_id_t type, ctf_next_t **it,
+ctf_member_next (ctf_dict_t *fp, ctf_id_t type, ctf_next_t **it,
const char **name, ctf_id_t *membtype)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
uint32_t kind;
ssize_t offset;
ctf_next_t *i = *it;
integer value of each enum element to the specified callback function. */
int
-ctf_enum_iter (ctf_file_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
+ctf_enum_iter (ctf_dict_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
ctf_dtdef_t *dtd;
enumerand's integer VALue. */
const char *
-ctf_enum_next (ctf_file_t *fp, ctf_id_t type, ctf_next_t **it,
+ctf_enum_next (ctf_dict_t *fp, ctf_id_t type, ctf_next_t **it,
int *val)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
uint32_t kind;
const char *name;
ctf_next_t *i = *it;
return NULL;
}
-/* Iterate over every root (user-visible) type in the given CTF container.
+/* Iterate over every root (user-visible) type in the given CTF dict.
We pass the type ID of each type to the specified callback function.
Does not traverse parent types: you have to do that explicitly. This is by
of a single parent. */
int
-ctf_type_iter (ctf_file_t *fp, ctf_type_f *func, void *arg)
+ctf_type_iter (ctf_dict_t *fp, ctf_type_f *func, void *arg)
{
ctf_id_t id, max = fp->ctf_typemax;
int rc, child = (fp->ctf_flags & LCTF_CHILD);
return 0;
}
-/* Iterate over every type in the given CTF container, user-visible or not.
+/* Iterate over every type in the given CTF dict, user-visible or not.
We pass the type ID of each type to the specified callback function.
Does not traverse parent types: you have to do that explicitly. This is by
of a single parent. */
int
-ctf_type_iter_all (ctf_file_t *fp, ctf_type_all_f *func, void *arg)
+ctf_type_iter_all (ctf_dict_t *fp, ctf_type_all_f *func, void *arg)
{
ctf_id_t id, max = fp->ctf_typemax;
int rc, child = (fp->ctf_flags & LCTF_CHILD);
return 0;
}
-/* Iterate over every type in the given CTF container, optionally including
+/* Iterate over every type in the given CTF dict, optionally including
non-user-visible types, returning each type ID and hidden flag in turn.
Returns CTF_ERR on end of iteration or error.
of a single parent. */
ctf_id_t
-ctf_type_next (ctf_file_t *fp, ctf_next_t **it, int *flag, int want_hidden)
+ctf_type_next (ctf_dict_t *fp, ctf_next_t **it, int *flag, int want_hidden)
{
ctf_next_t *i = *it;
return ctf_set_errno (fp, ECTF_NEXT_END);
}
-/* Iterate over every variable in the given CTF container, in arbitrary order.
+/* Iterate over every variable in the given CTF dict, in arbitrary order.
We pass the name of each variable to the specified callback function. */
int
-ctf_variable_iter (ctf_file_t *fp, ctf_variable_f *func, void *arg)
+ctf_variable_iter (ctf_dict_t *fp, ctf_variable_f *func, void *arg)
{
int rc;
return 0;
}
-/* Iterate over every variable in the given CTF container, in arbitrary order,
+/* Iterate over every variable in the given CTF dict, in arbitrary order,
returning the name and type of each variable in turn. The name argument is
not optional. Returns CTF_ERR on end of iteration or error. */
ctf_id_t
-ctf_variable_next (ctf_file_t *fp, ctf_next_t **it, const char **name)
+ctf_variable_next (ctf_dict_t *fp, ctf_next_t **it, const char **name)
{
ctf_next_t *i = *it;
Does not drill down through slices to their contained type. */
ctf_id_t
-ctf_type_resolve (ctf_file_t *fp, ctf_id_t type)
+ctf_type_resolve (ctf_dict_t *fp, ctf_id_t type)
{
ctf_id_t prev = type, otype = type;
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
if (type == 0)
type. */
ctf_id_t
-ctf_type_resolve_unsliced (ctf_file_t *fp, ctf_id_t type)
+ctf_type_resolve_unsliced (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
/* Look up a name in the given name table, in the appropriate hash given the
kind of the identifier. The name is a raw, undecorated identifier. */
-ctf_id_t ctf_lookup_by_rawname (ctf_file_t *fp, int kind, const char *name)
+ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *fp, int kind, const char *name)
{
return ctf_lookup_by_rawhash (fp, ctf_name_table (fp, kind), name);
}
readability state of the dictionary. The name is a raw, undecorated
identifier. */
-ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *fp, ctf_names_t *np, const char *name)
+ctf_id_t ctf_lookup_by_rawhash (ctf_dict_t *fp, ctf_names_t *np, const char *name)
{
ctf_id_t id;
string. */
char *
-ctf_type_aname (ctf_file_t *fp, ctf_id_t type)
+ctf_type_aname (ctf_dict_t *fp, ctf_id_t type)
{
ctf_decl_t cd;
ctf_decl_node_t *cdp;
for (cdp = ctf_list_next (&cd.cd_nodes[prec]);
cdp != NULL; cdp = ctf_list_next (cdp))
{
- ctf_file_t *rfp = fp;
+ ctf_dict_t *rfp = fp;
const ctf_type_t *tp = ctf_lookup_by_id (&rfp, cdp->cd_type);
const char *name = ctf_strptr (rfp, tp->ctt_name);
the actual number of bytes (not including \0) needed to format the name. */
ssize_t
-ctf_type_lname (ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+ctf_type_lname (ctf_dict_t *fp, ctf_id_t type, char *buf, size_t len)
{
char *str = ctf_type_aname (fp, type);
size_t slen;
is too small, return NULL: the ECTF_NAMELEN error is set on 'fp' for us. */
char *
-ctf_type_name (ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+ctf_type_name (ctf_dict_t *fp, ctf_id_t type, char *buf, size_t len)
{
ssize_t rv = ctf_type_lname (fp, type, buf, len);
return (rv >= 0 && (size_t) rv < len ? buf : NULL);
}
/* Lookup the given type ID and return its raw, unadorned, undecorated name.
- The name will live as long as its ctf_file_t does. */
+ The name will live as long as its ctf_dict_t does. */
const char *
-ctf_type_name_raw (ctf_file_t *fp, ctf_id_t type)
+ctf_type_name_raw (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
new dynamically-allocated string. */
char *
-ctf_type_aname_raw (ctf_file_t *fp, ctf_id_t type)
+ctf_type_aname_raw (ctf_dict_t *fp, ctf_id_t type)
{
const char *name = ctf_type_name_raw (fp, type);
of the type storage in bytes. */
ssize_t
-ctf_type_size (ctf_file_t *fp, ctf_id_t type)
+ctf_type_size (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
ssize_t size;
XXX may need arch-dependent attention. */
ssize_t
-ctf_type_align (ctf_file_t *fp, ctf_id_t type)
+ctf_type_align (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
int kind;
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
/* Return the kind (CTF_K_* constant) for the specified type ID. */
int
-ctf_type_kind_unsliced (ctf_file_t *fp, ctf_id_t type)
+ctf_type_kind_unsliced (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
Slices are considered to be of the same kind as the type sliced. */
int
-ctf_type_kind (ctf_file_t *fp, ctf_id_t type)
+ctf_type_kind (ctf_dict_t *fp, ctf_id_t type)
{
int 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)
+ctf_type_kind_forwarded (ctf_dict_t *fp, ctf_id_t type)
{
int kind;
const ctf_type_t *tp;
then return the ID of the type to which it refers. */
ctf_id_t
-ctf_type_reference (ctf_file_t *fp, ctf_id_t type)
+ctf_type_reference (ctf_dict_t *fp, ctf_id_t type)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
if ((tp = ctf_lookup_by_id (&fp, type)) == NULL)
instead. This helps with cases where the CTF data includes "struct foo *"
but not "foo_t *" and the user accesses "foo_t *" in the debugger.
- XXX what about parent containers? */
+ XXX what about parent dicts? */
ctf_id_t
-ctf_type_pointer (ctf_file_t *fp, ctf_id_t type)
+ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
ctf_id_t ntype;
if (ctf_lookup_by_id (&fp, type) == NULL)
/* Return the encoding for the specified INTEGER or FLOAT. */
int
-ctf_type_encoding (ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep)
+ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
ctf_dtdef_t *dtd;
const ctf_type_t *tp;
ssize_t increment;
}
int
-ctf_type_cmp (ctf_file_t *lfp, ctf_id_t ltype, ctf_file_t *rfp,
+ctf_type_cmp (ctf_dict_t *lfp, ctf_id_t ltype, ctf_dict_t *rfp,
ctf_id_t rtype)
{
int rval;
unions) member count. */
int
-ctf_type_compat (ctf_file_t *lfp, ctf_id_t ltype,
- ctf_file_t *rfp, ctf_id_t rtype)
+ctf_type_compat (ctf_dict_t *lfp, ctf_id_t ltype,
+ ctf_dict_t *rfp, ctf_id_t rtype)
{
const ctf_type_t *ltp, *rtp;
ctf_encoding_t le, re;
enumerators in an ENUM. */
int
-ctf_member_count (ctf_file_t *fp, ctf_id_t type)
+ctf_member_count (ctf_dict_t *fp, ctf_id_t type)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
uint32_t kind;
/* Return the type and offset for a given member of a STRUCT or UNION. */
int
-ctf_member_info (ctf_file_t *fp, ctf_id_t type, const char *name,
+ctf_member_info (ctf_dict_t *fp, ctf_id_t type, const char *name,
ctf_membinfo_t *mip)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
ctf_dtdef_t *dtd;
ssize_t size, increment;
/* Return the array type, index, and size information for the specified ARRAY. */
int
-ctf_array_info (ctf_file_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
+ctf_array_info (ctf_dict_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
const ctf_array_t *ap;
const ctf_dtdef_t *dtd;
matching name can be found. Otherwise NULL is returned. */
const char *
-ctf_enum_name (ctf_file_t *fp, ctf_id_t type, int value)
+ctf_enum_name (ctf_dict_t *fp, ctf_id_t type, int value)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
const ctf_dtdef_t *dtd;
matching name can be found. Otherwise CTF_ERR is returned. */
int
-ctf_enum_value (ctf_file_t * fp, ctf_id_t type, const char *name, int *valp)
+ctf_enum_value (ctf_dict_t * fp, ctf_id_t type, const char *name, int *valp)
{
- ctf_file_t *ofp = fp;
+ ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
const ctf_dtdef_t *dtd;
arg counts for that function. */
int
-ctf_func_type_info (ctf_file_t *fp, ctf_id_t type, ctf_funcinfo_t *fip)
+ctf_func_type_info (ctf_dict_t *fp, ctf_id_t type, ctf_funcinfo_t *fip)
{
const ctf_type_t *tp;
uint32_t kind;
function. */
int
-ctf_func_type_args (ctf_file_t *fp, ctf_id_t type, uint32_t argc, ctf_id_t *argv)
+ctf_func_type_args (ctf_dict_t *fp, ctf_id_t type, uint32_t argc, ctf_id_t *argv)
{
const ctf_type_t *tp;
const uint32_t *args;
returns non-zero, we abort and percolate the error code back up to the top. */
static int
-ctf_type_rvisit (ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func,
+ctf_type_rvisit (ctf_dict_t *fp, ctf_id_t type, ctf_visit_f *func,
void *arg, const char *name, unsigned long offset, int depth)
{
ctf_id_t otype = type;
/* Recursively visit the members of any type. We pass the name, member
type, and offset of each member to the specified callback function. */
int
-ctf_type_visit (ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg)
+ctf_type_visit (ctf_dict_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg)
{
return (ctf_type_rvisit (fp, type, func, arg, "", 0, 0));
}
/* A realloc() that fails noisily if called with any ctf_str_num_users. */
void *
-ctf_realloc (ctf_file_t *fp, void *ptr, size_t size)
+ctf_realloc (ctf_dict_t *fp, void *ptr, size_t size)
{
if (fp->ctf_str_num_refs > 0)
{
return NULL;
}
-/* Store the specified error code into the CTF container, and then return
- CTF_ERR / -1 for the benefit of the caller. */
+/* Store the specified error code into the CTF dict, and then return CTF_ERR /
+ -1 for the benefit of the caller. */
unsigned long
-ctf_set_errno (ctf_file_t * fp, int err)
+ctf_set_errno (ctf_dict_t *fp, int err)
{
fp->ctf_errno = err;
return CTF_ERR;
local:
*;
};
+
+LIBCTF_1.1 {
+ global:
+ ctf_dict_close;
+ ctf_parent_dict;
+} LIBCTF_1.0;