libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_t

The naming of the ctf_file_t type in libctf is a historical curiosity.
Back in the Solaris days, CTF dictionaries were originally generated as
a separate file and then (sometimes) merged into objects: hence the
datatype was named ctf_file_t, and known as a "CTF file".  Nowadays, raw
CTF is essentially never written to a file on its own, and the datatype
changed name to a "CTF dictionary" years ago.  So the term "CTF file"
refers to something that is never a file!  This is at best confusing.

The type has also historically been known as a 'CTF container", which is
even more confusing now that we have CTF archives which are *also* a
sort of container (they contain CTF dictionaries), but which are never
referred to as containers in the source code.

So fix this by completing the renaming, renaming ctf_file_t to
ctf_dict_t throughout, and renaming those few functions that refer to
CTF files by name (keeping compatibility aliases) to refer to dicts
instead.  Old users who still refer to ctf_file_t will see (harmless)
pointer-compatibility warnings at compile time, but the ABI is unchanged
(since C doesn't mangle names, and ctf_file_t was always an opaque type)
and things will still compile fine as long as -Werror is not specified.
All references to CTF containers and CTF files in the source code are
fixed to refer to CTF dicts instead.

Further (smaller) renamings of annoyingly-named functions to come, as
part of the process of souping up queries across whole archives at once
(needed for the function info and data object sections).

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close.
	* readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_section_as_ctf): Likewise.  Use ctf_dict_close, not
	ctf_file_close.

gdb/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctfread.c: Change uses of ctf_file_t to ctf_dict_t.
	(ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_file_t): Rename to...
	(ctf_dict_t): ... this.  Keep ctf_file_t around for compatibility.
	(struct ctf_file): Likewise rename to...
	(struct ctf_dict): ... this.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ... this, keeping compatibility function.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this, keeping compatibility function.
	All callers adjusted.
	* ctf.h: Rename references to ctf_file_t to ctf_dict_t.
	(struct ctf_archive) <ctfa_nfiles>: Rename to...
	<ctfa_ndicts>: ... this.

ld/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ldlang.c (ctf_output): This is a ctf_dict_t now.
	(lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t.
	(ldlang_open_ctf): Adjust comment.
	(lang_merge_ctf): Use ctf_dict_close, not ctf_file_close.
	* ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to
	ctf_dict_t.  Change opaque declaration accordingly.
	* ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust.
	* ldemul.h (examine_strtab_for_ctf): Likewise.
	(ldemul_examine_strtab_for_ctf): Likewise.
	* ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations
	adjusted.
	(ctf_fileops): Rename to...
	(ctf_dictops): ... this.
	(ctf_dedup_t) <cd_id_to_file_t>: Rename to...
	<cd_id_to_dict_t>: ... this.
	(ctf_file_t): Fix outdated comment.
	<ctf_fileops>: Rename to...
	<ctf_dictops>: ... this.
	(struct ctf_archive_internal) <ctfi_file>: Rename to...
	<ctfi_dict>: ... this.
	* ctf-archive.c: Rename ctf_file_t to ctf_dict_t.
	Rename ctf_archive.ctfa_nfiles to ctfa_ndicts.
	Rename ctf_file_close to ctf_dict_close.  All users adjusted.
	* ctf-create.c: Likewise.  Refer to CTF dicts, not CTF containers.
	(ctf_bundle_t) <ctb_file>: Rename to...
	<ctb_dict): ... this.
	* ctf-decl.c: Rename ctf_file_t to ctf_dict_t.
	* ctf-dedup.c: Likewise.  Rename ctf_file_close to
	ctf_dict_close. Refer to CTF dicts, not CTF containers.
	* ctf-dump.c: Likewise.
	* ctf-error.c: Likewise.
	* ctf-hash.c: Likewise.
	* ctf-inlines.h: Likewise.
	* ctf-labels.c: Likewise.
	* ctf-link.c: Likewise.
	* ctf-lookup.c: Likewise.
	* ctf-open-bfd.c: Likewise.
	* ctf-string.c: Likewise.
	* ctf-subr.c: Likewise.
	* ctf-types.c: Likewise.
	* ctf-util.c: Likewise.
	* ctf-open.c: Likewise.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ...this.
	(ctf_file_close): New trivial wrapper around ctf_dict_close, for
	compatibility.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this.
	(ctf_parent_file): New trivial wrapper around ctf_parent_dict, for
	compatibility.
	* libctf.ver: Add ctf_dict_close and ctf_parent_dict.
This commit is contained in:
Nick Alcock 2020-11-20 13:34:04 +00:00
parent cbbcd7a716
commit 139633c307
34 changed files with 916 additions and 801 deletions

View File

@ -1,3 +1,13 @@
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

View File

@ -4073,7 +4073,7 @@ make_ctfsect (const char *name, bfd_byte *data,
/* 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;
@ -4097,9 +4097,9 @@ dump_ctf_errs (ctf_file_t *fp)
/* 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",
""};
@ -4155,7 +4155,7 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
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)
@ -4204,7 +4204,7 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
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);

View File

@ -14598,7 +14598,7 @@ dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
/* 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;
@ -14619,9 +14619,9 @@ dump_ctf_errs (ctf_file_t *fp)
/* 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",
""};
@ -14685,7 +14685,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
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;
@ -14791,7 +14791,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
ret = FALSE;
fail:
ctf_file_close (parent);
ctf_dict_close (parent);
ctf_close (ctfa);
ctf_close (parenta);
free (parentdata);

View File

@ -1,3 +1,8 @@
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

View File

@ -91,29 +91,29 @@ static const struct objfile_key<htab, htab_deleter> ctf_tid_key;
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;
@ -272,7 +272,7 @@ get_tid_type (struct objfile *of, ctf_id_t tid)
/* 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;
@ -434,7 +434,7 @@ static struct symbol *
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));
@ -497,7 +497,7 @@ static struct type *
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;
@ -592,7 +592,7 @@ static struct type *
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;
@ -650,7 +650,7 @@ static struct type *
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;
@ -676,7 +676,7 @@ static struct type *
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;
@ -751,7 +751,7 @@ static struct type *
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;
@ -816,7 +816,7 @@ static struct type *
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);
@ -913,7 +913,7 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t 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;
@ -1310,7 +1310,7 @@ ctf_psymtab::read_symtab (struct objfile *objfile)
static ctf_psymtab *
create_partial_symtab (const char *name,
ctf_file_t *cfp,
ctf_dict_t *cfp,
struct objfile *objfile)
{
ctf_psymtab *pst;
@ -1406,7 +1406,7 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg)
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);
@ -1482,11 +1482,11 @@ elfctf_build_psymtabs (struct objfile *of)
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);
}

View File

@ -1,3 +1,18 @@
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.

View File

@ -34,13 +34,13 @@ extern "C"
#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;
@ -267,7 +267,7 @@ typedef int ctf_type_f (ctf_id_t type, void *arg);
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,
@ -287,7 +287,7 @@ extern ctf_next_t *ctf_next_copy (ctf_next_t *);
/* 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 *);
@ -298,17 +298,17 @@ extern ctf_archive_t *ctf_fdopen (int fd, const char *filename,
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 *);
@ -317,95 +317,95 @@ extern size_t ctf_archive_count (const ctf_archive_t *);
/* 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 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_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_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_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 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_file_t *, ctf_id_t, const char *,
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
@ -414,97 +414,104 @@ extern ctf_file_t *ctf_archive_next (const ctf_archive_t *, ctf_next_t **,
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

View File

@ -552,7 +552,7 @@ typedef struct ctf_enum
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
@ -578,20 +578,20 @@ struct ctf_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
{

View File

@ -1,3 +1,16 @@
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

View File

@ -175,7 +175,7 @@ ldelf_ctf_symbols_iter_cb (struct ctf_link_sym *dest,
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,
@ -205,7 +205,7 @@ extern int ldelf_emit_ctf_early (void)
}
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)

View File

@ -20,10 +20,10 @@
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);

View File

@ -418,7 +418,7 @@ ldemul_emit_ctf_early (void)
}
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)

View File

@ -110,7 +110,7 @@ extern int ldemul_emit_ctf_early
(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);
@ -236,7 +236,7 @@ typedef struct ld_emulation_xfer_struct {
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

View File

@ -131,7 +131,7 @@ struct lang_phdr *lang_phdr_list;
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
@ -3674,7 +3674,7 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
/* 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;
@ -3713,7 +3713,7 @@ ldlang_open_ctf (void)
{
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. */
@ -3776,7 +3776,7 @@ lang_merge_ctf (void)
/* 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)
@ -3882,7 +3882,7 @@ lang_write_ctf (int late)
}
/* 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)

View File

@ -1,3 +1,48 @@
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.

View File

@ -32,8 +32,8 @@
#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);
@ -45,12 +45,12 @@ static int arc_mmap_writeout (int fd, void *header, size_t headersz,
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;
@ -66,14 +66,14 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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
@ -101,7 +101,7 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
/* 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
@ -112,8 +112,8 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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
@ -122,7 +122,7 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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);
@ -135,13 +135,13 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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 "
@ -163,7 +163,7 @@ ctf_arc_write_fd (int fd, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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);
@ -204,19 +204,19 @@ err:
/* 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;
@ -224,17 +224,17 @@ ctf_arc_write (const char *file, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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;
@ -252,13 +252,13 @@ ctf_arc_write (const char *file, ctf_file_t **ctf_files, size_t ctf_file_cnt,
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;
@ -338,13 +338,13 @@ search_modent_by_name (const void *key, const void *ent, void *arg)
}
/* 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)
{
@ -358,14 +358,14 @@ ctf_new_archive_internal (int is_archive, int unmap_on_close,
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)
@ -386,7 +386,7 @@ ctf_arc_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
{
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))
@ -492,7 +492,7 @@ ctf_arc_close (ctf_archive_t *arc)
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)
@ -503,9 +503,9 @@ ctf_arc_close (ctf_archive_t *arc)
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,
@ -523,7 +523,7 @@ ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
+ 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);
@ -540,13 +540,13 @@ ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
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,
@ -555,7 +555,7 @@ ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
{
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)
@ -569,18 +569,18 @@ ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
*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;
@ -594,16 +594,16 @@ ctf_arc_open_by_name (const ctf_archive_t *arc, const char *name, int *errp)
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);
@ -628,7 +628,7 @@ ctf_archive_count (const ctf_archive_t *wrapper)
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
@ -646,7 +646,7 @@ ctf_archive_raw_iter_internal (const struct ctf_archive *arc,
+ 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;
@ -686,7 +686,7 @@ ctf_archive_iter_internal (const ctf_archive_t *wrapper,
{
int rc;
size_t i;
ctf_file_t *f;
ctf_dict_t *f;
struct ctf_archive_modent *modent;
const char *nametbl;
@ -694,7 +694,7 @@ ctf_archive_iter_internal (const ctf_archive_t *wrapper,
+ 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;
@ -706,11 +706,11 @@ ctf_archive_iter_internal (const ctf_archive_t *wrapper,
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;
}
@ -733,11 +733,11 @@ ctf_archive_iter (const ctf_archive_t *arc, ctf_archive_member_f *func,
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.
@ -745,11 +745,11 @@ ctf_archive_iter (const ctf_archive_t *arc, ctf_archive_member_f *func,
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;
@ -783,7 +783,7 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
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. */
@ -793,8 +793,8 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
i->ctn_n++;
if (!skip_parent)
{
wrapper->ctfi_file->ctf_refcnt++;
return wrapper->ctfi_file;
wrapper->ctfi_dict->ctf_refcnt++;
return wrapper->ctfi_dict;
}
}
@ -809,7 +809,7 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
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;

View File

@ -38,7 +38,7 @@
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;
@ -66,12 +66,12 @@ ctf_grow_ptrtab (ctf_file_t *fp)
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 } };
@ -80,7 +80,7 @@ ctf_create (int *errp)
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,
@ -137,7 +137,7 @@ ctf_create (int *errp)
if (ctf_grow_ptrtab (fp) < 0)
{
ctf_set_open_errno (errp, ctf_errno (fp));
ctf_file_close (fp);
ctf_dict_close (fp);
return NULL;
}
@ -156,7 +156,7 @@ ctf_create (int *errp)
}
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;
@ -181,7 +181,7 @@ ctf_copy_smembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
}
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;
@ -207,7 +207,7 @@ ctf_copy_lmembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
}
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;
@ -230,7 +230,7 @@ ctf_copy_emembers (ctf_file_t *fp, ctf_dtdef_t *dtd, unsigned char *t)
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;
@ -247,7 +247,7 @@ ctf_sort_var (const void *one_, const void *two_, void *arg_)
/* 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));
@ -256,20 +256,20 @@ ctf_update (ctf_file_t *fp)
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;
@ -508,8 +508,8 @@ ctf_serialize (ctf_file_t *fp)
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,
@ -591,18 +591,18 @@ ctf_serialize (ctf_file_t *fp)
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)
{
@ -618,7 +618,7 @@ ctf_name_table (ctf_file_t *fp, int 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,
@ -642,7 +642,7 @@ ctf_dtd_insert (ctf_file_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
}
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);
@ -687,14 +687,14 @@ ctf_dtd_delete (ctf_file_t *fp, ctf_dtdef_t *dtd)
}
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;
@ -712,7 +712,7 @@ ctf_dynamic_type (const ctf_file_t *fp, ctf_id_t id)
}
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;
@ -721,7 +721,7 @@ ctf_dvd_insert (ctf_file_t *fp, ctf_dvdef_t *dvd)
}
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);
@ -731,20 +731,20 @@ ctf_dvd_delete (ctf_file_t *fp, ctf_dvdef_t *dvd)
}
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,
@ -758,7 +758,7 @@ ctf_discard (ctf_file_t *fp)
}
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;
@ -768,7 +768,7 @@ ctf_snapshot (ctf_file_t *fp)
/* 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;
@ -826,7 +826,7 @@ ctf_rollback (ctf_file_t *fp, ctf_snapshot_id_t id)
}
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;
@ -893,7 +893,7 @@ clp2 (size_t x)
}
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;
@ -914,11 +914,11 @@ ctf_add_encoded (ctf_file_t *fp, uint32_t flag,
}
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)
@ -963,7 +963,7 @@ ctf_add_reftype (ctf_file_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind)
}
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;
@ -971,7 +971,7 @@ ctf_add_slice (ctf_file_t *fp, uint32_t flag, ctf_id_t ref,
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));
@ -1011,31 +1011,31 @@ ctf_add_slice (ctf_file_t *fp, uint32_t flag, ctf_id_t ref,
}
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));
@ -1059,7 +1059,7 @@ ctf_add_array (ctf_file_t *fp, uint32_t flag, const ctf_arinfo_t *arp)
}
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);
@ -1077,14 +1077,14 @@ ctf_set_array (ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
}
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
@ -1134,7 +1134,7 @@ ctf_add_function (ctf_file_t *fp, uint32_t flag,
}
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;
@ -1165,13 +1165,13 @@ ctf_add_struct_sized (ctf_file_t *fp, uint32_t flag, const char *name,
}
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;
@ -1202,13 +1202,13 @@ ctf_add_union_sized (ctf_file_t *fp, uint32_t flag, const char *name,
}
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;
@ -1230,7 +1230,7 @@ ctf_add_enum (ctf_file_t *fp, uint32_t flag, const char *name)
}
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;
@ -1258,7 +1258,7 @@ ctf_add_enum_encoded (ctf_file_t *fp, uint32_t flag, const char *name,
}
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;
@ -1286,12 +1286,12 @@ ctf_add_forward (ctf_file_t *fp, uint32_t flag, const char *name,
}
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));
@ -1310,25 +1310,25 @@ ctf_add_typedef (ctf_file_t *fp, uint32_t flag, const char *name,
}
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);
@ -1386,7 +1386,7 @@ ctf_add_enumerator (ctf_file_t *fp, ctf_id_t enid, const char *name,
}
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);
@ -1530,7 +1530,7 @@ ctf_add_member_offset (ctf_file_t *fp, ctf_id_t souid, const char *name,
}
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)
{
@ -1548,17 +1548,17 @@ ctf_add_member_encoded (ctf_file_t *fp, ctf_id_t souid, const char *name,
}
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));
@ -1598,7 +1598,7 @@ ctf_add_variable (ctf_file_t *fp, const char *name, ctf_id_t ref)
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;
@ -1609,15 +1609,15 @@ enumcmp (const char *name, int value, void *arg)
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;
@ -1630,7 +1630,7 @@ enumadd (const char *name, int value, void *arg)
{
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);
}
@ -1646,16 +1646,16 @@ membcmp (const char *name, ctf_id_t type _libctf_unused_, unsigned long offset,
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);
@ -1672,12 +1672,12 @@ membadd (const char *name, ctf_id_t type, unsigned long offset, void *arg)
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
@ -1689,22 +1689,22 @@ membadd (const char *name, ctf_id_t type, unsigned long offset, void *arg)
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;
@ -1747,9 +1747,9 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
(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)
{
@ -1769,9 +1769,9 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
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)
@ -1803,7 +1803,7 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
&& 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));
@ -1821,7 +1821,7 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
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;
@ -1867,11 +1867,11 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
}
}
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;
@ -2061,7 +2061,7 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
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);
@ -2142,7 +2142,7 @@ ctf_add_type_internal (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type
}
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;
@ -2164,7 +2164,7 @@ ctf_add_type (ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
/* 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;
@ -2196,7 +2196,7 @@ ctf_gzwrite (ctf_file_t *fp, gzFile fd)
/* 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;
@ -2263,7 +2263,7 @@ ret:
/* 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;
@ -2316,7 +2316,7 @@ ctf_write_mem (ctf_file_t *fp, size_t *size, size_t threshold)
/* 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;

View File

@ -72,7 +72,7 @@ ctf_decl_fini (ctf_decl_t *cd)
}
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;

View File

@ -55,7 +55,7 @@
*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
@ -294,23 +294,23 @@
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
@ -368,7 +368,7 @@ make_set_element (ctf_dynhash_t *set, const void *key)
/* 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;
@ -387,7 +387,7 @@ ctf_dedup_atoms_init (ctf_file_t *fp)
/* 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;
@ -414,7 +414,7 @@ intern (ctf_file_t *fp, char *atom)
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;
@ -484,13 +484,13 @@ ctf_dedup_sha1_add (ctf_sha1_t *sha1, const void *buf, size_t len,
}
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,
@ -519,7 +519,7 @@ ctf_dedup_is_stub (const char *name, int kind, int fwdkind, int flags)
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;
@ -551,14 +551,14 @@ ctf_dedup_record_origin (ctf_file_t *fp, int input_num, const char *decorated,
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,
@ -990,13 +990,13 @@ ctf_dedup_rhash_type (ctf_file_t *fp, ctf_file_t *input, ctf_file_t **inputs,
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,
@ -1139,8 +1139,8 @@ ctf_dedup_hash_type (ctf_file_t *fp, ctf_file_t *input,
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,
@ -1212,7 +1212,7 @@ ctf_dedup_populate_mappings (ctf_file_t *fp, ctf_file_t *input _libctf_unused_,
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)
{
@ -1285,7 +1285,7 @@ ctf_dedup_populate_mappings (ctf_file_t *fp, ctf_file_t *input _libctf_unused_,
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;
@ -1331,7 +1331,7 @@ ctf_dedup_mark_conflicting_hash (ctf_file_t *fp, const char *hval)
/* 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;
@ -1363,8 +1363,8 @@ ctf_dedup_hash_kind (ctf_file_t *fp, ctf_file_t **inputs, const char *hash)
/* 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;
@ -1401,7 +1401,7 @@ ctf_dedup_count_types (void *key_, void *value _libctf_unused_, void *arg_)
/* 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;
@ -1560,7 +1560,7 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
/* 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;
@ -1569,7 +1569,7 @@ ctf_dedup_init (ctf_file_t *fp)
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;
@ -1646,14 +1646,14 @@ ctf_dedup_init (ctf_file_t *fp)
}
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]);
@ -1677,7 +1677,7 @@ ctf_dedup_fini (ctf_file_t *fp, ctf_file_t **outputs, uint32_t noutputs)
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));
@ -1686,16 +1686,16 @@ ctf_dedup_fini (ctf_file_t *fp, ctf_file_t **outputs, uint32_t noutputs)
/* 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;
@ -1714,7 +1714,7 @@ ctf_dedup_multiple_input_dicts (ctf_file_t *output, ctf_file_t **inputs,
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;
@ -1781,7 +1781,7 @@ ctf_dedup_multiple_input_dicts (ctf_file_t *output, ctf_file_t **inputs,
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;
@ -1853,7 +1853,7 @@ ctf_dedup_conflictify_unshared (ctf_file_t *output, ctf_file_t **inputs)
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;
@ -1924,17 +1924,17 @@ ctf_dedup (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
}
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,
@ -1944,19 +1944,19 @@ ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
/* 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,
@ -1964,7 +1964,7 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
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;
@ -2128,17 +2128,17 @@ ctf_dedup_rwalk_one_output_mapping (ctf_file_t *output,
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,
@ -2222,7 +2222,7 @@ ctf_dedup_rwalk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
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;
@ -2241,8 +2241,8 @@ sort_output_mapping (const ctf_next_hkv_t *one, const ctf_next_hkv_t *two,
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;
@ -2288,15 +2288,15 @@ sort_output_mapping (const ctf_next_hkv_t *one, const ctf_next_hkv_t *two,
/* 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,
@ -2351,8 +2351,8 @@ ctf_dedup_walk_output_mapping (ctf_file_t *output, ctf_file_t **inputs,
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;
@ -2430,14 +2430,14 @@ ctf_dedup_maybe_synthesize_forward (ctf_file_t *output, ctf_file_t *target,
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;
@ -2535,7 +2535,7 @@ ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
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.
@ -2546,16 +2546,16 @@ ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
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' */
@ -2896,14 +2896,14 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
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;
@ -2911,7 +2911,7 @@ ctf_dedup_emit_struct_members (ctf_file_t *output, ctf_file_t **inputs,
&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;
@ -2992,11 +2992,11 @@ ctf_dedup_emit_struct_members (ctf_file_t *output, ctf_file_t **inputs,
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;
@ -3029,7 +3029,7 @@ ctf_dedup_populate_type_mapping (ctf_file_t *shared, ctf_file_t *fp,
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
@ -3057,7 +3057,7 @@ ctf_dedup_populate_type_mapping (ctf_file_t *shared, ctf_file_t *fp,
/* 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;
@ -3094,13 +3094,13 @@ ctf_dedup_populate_type_mappings (ctf_file_t *output, ctf_file_t **inputs,
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");
@ -3124,7 +3124,7 @@ ctf_dedup_emit (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
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"));

View File

@ -36,7 +36,7 @@ typedef struct ctf_dump_item
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;
};
@ -46,7 +46,7 @@ struct ctf_dump_state
typedef struct ctf_dump_membstate
{
char **cdm_str;
ctf_file_t *cdm_fp;
ctf_dict_t *cdm_fp;
} ctf_dump_membstate_t;
static int
@ -83,7 +83,7 @@ ctf_dump_free (ctf_dump_state_t *state)
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;
@ -183,7 +183,7 @@ ctf_dump_format_type (ctf_file_t *fp, ctf_id_t id, int flag)
/* 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;
@ -201,7 +201,7 @@ ctf_dump_header_strfield (ctf_file_t *fp, ctf_dump_state_t *state,
/* 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;
@ -221,7 +221,7 @@ ctf_dump_header_sectfield (ctf_file_t *fp, ctf_dump_state_t *state,
/* 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;
@ -252,7 +252,7 @@ ctf_dump_header (ctf_file_t *fp, ctf_dump_state_t *state)
/* 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. */
@ -339,7 +339,7 @@ ctf_dump_label (const char *name, const ctf_lblinfo_t *info,
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;
@ -396,7 +396,7 @@ ctf_dump_objts (ctf_file_t *fp, ctf_dump_state_t *state)
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;
@ -627,7 +627,7 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg)
/* 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;
@ -657,7 +657,7 @@ ctf_dump_str (ctf_file_t *fp, ctf_dump_state_t *state)
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;

View File

@ -77,7 +77,7 @@ ctf_errmsg (int error)
}
int
ctf_errno (ctf_file_t * fp)
ctf_errno (ctf_dict_t * fp)
{
return fp->ctf_errno;
}

View File

@ -781,7 +781,7 @@ ctf_hash_size (const ctf_hash_t *hp)
}
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);
@ -811,7 +811,7 @@ ctf_hash_insert_type (ctf_hash_t *hp, ctf_file_t *fp, uint32_t type,
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
@ -821,7 +821,7 @@ ctf_hash_define_type (ctf_hash_t *hp, ctf_file_t *fp, uint32_t type,
}
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;

View File

@ -123,15 +123,15 @@ typedef struct ctf_lookup
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
{
@ -237,11 +237,11 @@ typedef struct ctf_str_atom_ref
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;
@ -253,7 +253,7 @@ typedef struct ctf_type_id_key
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
@ -272,10 +272,10 @@ typedef struct ctf_dedup
/* 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];
@ -339,25 +339,26 @@ typedef struct ctf_dedup
/* 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. */
@ -390,9 +391,9 @@ struct ctf_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. */
@ -407,7 +408,7 @@ struct ctf_file
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. */
@ -457,13 +458,13 @@ struct ctf_file
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;
@ -490,7 +491,7 @@ struct ctf_next
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. */
@ -504,11 +505,11 @@ struct ctf_next
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;
@ -535,23 +536,23 @@ struct ctf_next
(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);
@ -576,9 +577,9 @@ typedef int (*ctf_hash_sort_f) (const ctf_next_hkv_t *, const ctf_next_hkv_t *,
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 *);
@ -626,101 +627,101 @@ extern void ctf_list_delete (ctf_list_t *, void *);
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. */

View File

@ -32,12 +32,12 @@ extern "C"
#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
@ -81,7 +81,7 @@ ctf_dynset_cinsert (ctf_dynset_t *h, const void *k)
}
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))

View File

@ -21,7 +21,7 @@
#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;
@ -37,7 +37,7 @@ extract_label_info (ctf_file_t *fp, const ctf_lblent_t **ctl,
/* 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;
@ -61,7 +61,7 @@ ctf_label_topmost (ctf_file_t *fp)
/* 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;
@ -122,7 +122,7 @@ label_info_cb (const char *lname, const ctf_lblinfo_t *linfo, void *arg)
/* 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;

View File

@ -28,18 +28,18 @@
/* 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;
@ -83,10 +83,10 @@ ctf_add_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
/* 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)
@ -145,7 +145,7 @@ ctf_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t **dst_fp)
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;
@ -157,15 +157,15 @@ ctf_link_input_name (ctf_file_t *fp)
/* 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;
@ -181,8 +181,8 @@ ctf_link_input_close (void *input)
/* 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;
@ -228,7 +228,7 @@ ctf_link_add_ctf_internal (ctf_file_t *fp, ctf_archive_t *ctf,
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)
@ -275,7 +275,7 @@ ctf_link_add (ctf_file_t *fp, ctf_archive_t *ctf, const char *name,
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);
}
@ -283,10 +283,10 @@ ctf_link_add_ctf (ctf_file_t *fp, ctf_archive_t *ctf, const char *name)
/* 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;
@ -334,21 +334,21 @@ ctf_create_per_cu (ctf_file_t *fp, const char *filename, const char *cuname)
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;
@ -431,7 +431,7 @@ ctf_link_add_cu_mapping (ctf_file_t *fp, const char *from, const char *to)
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)
{
@ -442,12 +442,12 @@ ctf_link_set_memb_name_changer (ctf_file_t *fp,
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;
@ -456,7 +456,7 @@ typedef struct ctf_link_in_member_cb_arg
/* 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
@ -472,7 +472,7 @@ static int
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)
@ -533,7 +533,7 @@ ctf_link_one_type (ctf_id_t type, int isroot _libctf_unused_, void *arg_)
/* 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;
@ -541,10 +541,10 @@ ctf_link_set_variable_filter (ctf_file_t *fp, ctf_link_variable_filter_f *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;
@ -572,9 +572,9 @@ static int
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. */
@ -587,7 +587,7 @@ ctf_link_one_variable (const char *name, ctf_id_t type, void *arg_)
}
/* 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;
@ -657,7 +657,7 @@ ctf_link_one_variable (const char *name, ctf_id_t type, void *arg_)
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;
@ -705,7 +705,7 @@ static void
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);
@ -716,7 +716,7 @@ empty_link_type_mapping (void *key _libctf_unused_, void *value,
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;
@ -803,7 +803,7 @@ ctf_link_one_input_archive (void *key, void *value, void *arg_)
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;
@ -818,7 +818,7 @@ ctf_link_one_input_archive (void *key, void *value, void *arg_)
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);
@ -827,7 +827,7 @@ ctf_link_one_input_archive (void *key, void *value, void *arg_)
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
@ -875,7 +875,7 @@ ctf_link_sort_inputs (const ctf_next_hkv_t *one, const ctf_next_hkv_t *two,
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;
@ -952,23 +952,23 @@ ctf_link_deduplicating_count_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
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)
@ -987,8 +987,8 @@ ctf_link_deduplicating_open_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
{
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;
@ -1088,8 +1088,8 @@ ctf_link_deduplicating_open_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
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;
@ -1099,7 +1099,7 @@ ctf_link_deduplicating_close_inputs (ctf_file_t *fp, ctf_dynhash_t *cu_names,
/* 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)
@ -1126,7 +1126,7 @@ ctf_link_deduplicating_close_inputs (ctf_file_t *fp, ctf_dynhash_t *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;
@ -1155,7 +1155,7 @@ ctf_link_deduplicating_variables (ctf_file_t *fp, ctf_file_t **inputs,
/* 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;
@ -1172,9 +1172,9 @@ ctf_link_deduplicating_per_cu (ctf_file_t *fp)
{
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;
@ -1336,17 +1336,17 @@ ctf_link_deduplicating_per_cu (ctf_file_t *fp)
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:
@ -1355,7 +1355,7 @@ ctf_link_deduplicating_per_cu (ctf_file_t *fp)
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. */
@ -1372,10 +1372,10 @@ ctf_link_deduplicating_per_cu (ctf_file_t *fp)
/* 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;
@ -1425,7 +1425,7 @@ ctf_link_deduplicating (ctf_file_t *fp)
/* We already have access to this one. Close the duplicate. */
if (i == 0)
{
ctf_file_close (outputs[0]);
ctf_dict_close (outputs[0]);
continue;
}
@ -1443,7 +1443,7 @@ ctf_link_deduplicating (ctf_file_t *fp)
free (dynname);
for (; i < noutputs; i++)
ctf_file_close (outputs[i]);
ctf_dict_close (outputs[i]);
goto err;
}
@ -1453,7 +1453,7 @@ ctf_link_deduplicating (ctf_file_t *fp)
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;
}
@ -1469,7 +1469,7 @@ ctf_link_deduplicating (ctf_file_t *fp)
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);
@ -1479,7 +1479,7 @@ ctf_link_deduplicating (ctf_file_t *fp)
/* 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;
@ -1496,7 +1496,7 @@ ctf_link (ctf_file_t *fp, int flags)
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);
@ -1555,7 +1555,7 @@ static void
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;
@ -1570,7 +1570,7 @@ ctf_link_intern_extern_string (void *key _libctf_unused_, void *value,
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;
@ -1596,7 +1596,7 @@ ctf_link_add_strtab (ctf_file_t *fp, ctf_link_strtab_string_f *add_string,
/* 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_)
{
@ -1606,8 +1606,8 @@ ctf_link_shuffle_syms (ctf_file_t *fp _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;
@ -1618,9 +1618,9 @@ static void
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)
@ -1630,7 +1630,7 @@ ctf_accumulate_archive_names (void *key, void *value, void *arg_)
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);
@ -1675,7 +1675,7 @@ ctf_accumulate_archive_names (void *key, void *value, void *arg_)
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);
@ -1685,12 +1685,12 @@ ctf_change_parent_name (void *key _libctf_unused_, void *value, void *arg)
(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;
@ -1710,7 +1710,7 @@ ctf_link_write (ctf_file_t *fp, size_t *size, size_t threshold)
}
}
/* 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);
@ -1741,13 +1741,13 @@ ctf_link_write (ctf_file_t *fp, size_t *size, size_t 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)

View File

@ -69,7 +69,7 @@ isqualifier (const char *s, size_t len)
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*";
@ -102,7 +102,7 @@ ctf_lookup_by_name (ctf_file_t *fp, const char *name)
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)
@ -194,7 +194,7 @@ err:
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;
@ -212,7 +212,7 @@ ctf_lookup_var (const void *key_, const void *memb_)
/* 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 };
@ -236,7 +236,7 @@ ctf_lookup_variable (ctf_file_t *fp, const char *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;
@ -271,7 +271,7 @@ ctf_lookup_symbol_name (ctf_file_t *fp, unsigned long symidx)
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;
@ -308,8 +308,8 @@ ctf_lookup_by_symbol (ctf_file_t *fp, unsigned long symidx)
/* 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;
@ -322,9 +322,9 @@ ctf_get_dict (ctf_file_t *fp, ctf_id_t type)
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)
@ -353,7 +353,7 @@ ctf_lookup_by_id (ctf_file_t **fpp, ctf_id_t type)
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));
}
@ -365,7 +365,7 @@ ctf_lookup_by_id (ctf_file_t **fpp, ctf_id_t type)
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;
@ -422,7 +422,7 @@ ctf_func_info (ctf_file_t *fp, unsigned long symidx, ctf_funcinfo_t *fip)
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;

View File

@ -209,10 +209,10 @@ err: _libctf_unused_;
}
/* 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)
@ -245,7 +245,7 @@ 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)
@ -316,7 +316,7 @@ ctf_fdopen (int fd, const char *filename, const char *target, int *errp)
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. */

View File

@ -77,7 +77,7 @@ get_vlen_v2 (uint32_t info)
}
static inline ssize_t
get_ctt_size_common (const ctf_file_t *fp _libctf_unused_,
get_ctt_size_common (const ctf_dict_t *fp _libctf_unused_,
const ctf_type_t *tp _libctf_unused_,
ssize_t *sizep, ssize_t *incrementp, size_t lsize,
size_t csize, size_t ctf_type_size,
@ -105,7 +105,7 @@ get_ctt_size_common (const ctf_file_t *fp _libctf_unused_,
}
static ssize_t
get_ctt_size_v1 (const ctf_file_t *fp, const ctf_type_t *tp,
get_ctt_size_v1 (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
ctf_type_v1_t *t1p = (ctf_type_v1_t *) tp;
@ -119,7 +119,7 @@ get_ctt_size_v1 (const ctf_file_t *fp, const ctf_type_t *tp,
/* Return the size that a v1 will be once it is converted to v2. */
static ssize_t
get_ctt_size_v2_unconverted (const ctf_file_t *fp, const ctf_type_t *tp,
get_ctt_size_v2_unconverted (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
ctf_type_v1_t *t1p = (ctf_type_v1_t *) tp;
@ -131,7 +131,7 @@ get_ctt_size_v2_unconverted (const ctf_file_t *fp, const ctf_type_t *tp,
}
static ssize_t
get_ctt_size_v2 (const ctf_file_t *fp, const ctf_type_t *tp,
get_ctt_size_v2 (const ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t *sizep, ssize_t *incrementp)
{
return (get_ctt_size_common (fp, tp, sizep, incrementp,
@ -141,7 +141,7 @@ get_ctt_size_v2 (const ctf_file_t *fp, const ctf_type_t *tp,
}
static ssize_t
get_vbytes_common (ctf_file_t *fp, unsigned short kind,
get_vbytes_common (ctf_dict_t *fp, unsigned short kind,
ssize_t size _libctf_unused_, size_t vlen)
{
switch (kind)
@ -169,7 +169,7 @@ get_vbytes_common (ctf_file_t *fp, unsigned short kind,
}
static ssize_t
get_vbytes_v1 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
get_vbytes_v1 (ctf_dict_t *fp, unsigned short kind, ssize_t size, size_t vlen)
{
switch (kind)
{
@ -189,7 +189,7 @@ get_vbytes_v1 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
}
static ssize_t
get_vbytes_v2 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
get_vbytes_v2 (ctf_dict_t *fp, unsigned short kind, ssize_t size, size_t vlen)
{
switch (kind)
{
@ -208,7 +208,7 @@ get_vbytes_v2 (ctf_file_t *fp, unsigned short kind, ssize_t size, size_t vlen)
return (get_vbytes_common (fp, kind, size, vlen));
}
static const ctf_fileops_t ctf_fileops[] = {
static const ctf_dictops_t ctf_dictops[] = {
{NULL, NULL, NULL, NULL, NULL},
/* CTF_VERSION_1 */
{get_kind_v1, get_root_v1, get_vlen_v1, get_ctt_size_v1, get_vbytes_v1},
@ -225,7 +225,7 @@ static const ctf_fileops_t ctf_fileops[] = {
STT_OBJECT entry in the symbol table. */
static int
init_symtab (ctf_file_t *fp, const ctf_header_t *hp,
init_symtab (ctf_dict_t *fp, const ctf_header_t *hp,
const ctf_sect_t *sp, const ctf_sect_t *strp)
{
const unsigned char *symp = sp->cts_data;
@ -311,14 +311,14 @@ init_symtab (ctf_file_t *fp, const ctf_header_t *hp,
}
/* Reset the CTF base pointer and derive the buf pointer from it, initializing
everything in the ctf_file that depends on the base or buf pointers.
everything in the ctf_dict that depends on the base or buf pointers.
The original gap between the buf and base pointers, if any -- the original,
unconverted CTF header -- is kept, but its contents are not specified and are
never used. */
static void
ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
ctf_set_base (ctf_dict_t *fp, const ctf_header_t *hp, unsigned char *base)
{
fp->ctf_buf = base + (fp->ctf_buf - fp->ctf_base);
fp->ctf_base = base;
@ -330,8 +330,8 @@ ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
+ hp->cth_stroff;
fp->ctf_str[CTF_STRTAB_0].cts_len = hp->cth_strlen;
/* If we have a parent container name and label, store the relocated
string pointers in the CTF container for easy access later. */
/* If we have a parent dict name and label, store the relocated string
pointers in the CTF dict for easy access later. */
/* Note: before conversion, these will be set to values that will be
immediately invalidated by the conversion process, but the conversion
@ -359,11 +359,11 @@ ctf_set_base (ctf_file_t *fp, const ctf_header_t *hp, unsigned char *base)
caller must ensure this has been done in advance. */
static void
ctf_set_version (ctf_file_t *fp, ctf_header_t *cth, int ctf_version)
ctf_set_version (ctf_dict_t *fp, ctf_header_t *cth, int ctf_version)
{
fp->ctf_version = ctf_version;
cth->cth_version = ctf_version;
fp->ctf_fileops = &ctf_fileops[ctf_version];
fp->ctf_dictops = &ctf_dictops[ctf_version];
}
@ -397,7 +397,7 @@ upgrade_header (ctf_header_t *hp)
Type kinds not checked here due to nonexistence in older formats:
CTF_K_SLICE. */
static int
upgrade_types_v1 (ctf_file_t *fp, ctf_header_t *cth)
upgrade_types_v1 (ctf_dict_t *fp, ctf_header_t *cth)
{
const ctf_type_v1_t *tbuf;
const ctf_type_v1_t *tend;
@ -621,7 +621,7 @@ upgrade_types_v1 (ctf_file_t *fp, ctf_header_t *cth)
/* Upgrade from any earlier version. */
static int
upgrade_types (ctf_file_t *fp, ctf_header_t *cth)
upgrade_types (ctf_dict_t *fp, ctf_header_t *cth)
{
switch (cth->cth_version)
{
@ -649,7 +649,7 @@ upgrade_types (ctf_file_t *fp, ctf_header_t *cth)
recension of libctf supports upgrading. */
static int
init_types (ctf_file_t *fp, ctf_header_t *cth)
init_types (ctf_dict_t *fp, ctf_header_t *cth)
{
const ctf_type_t *tbuf;
const ctf_type_t *tend;
@ -659,8 +659,8 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
uint32_t id, dst;
uint32_t *xp;
/* We determine whether the container is a child or a parent based on
the value of cth_parname. */
/* We determine whether the dict is a child or a parent based on the value of
cth_parname. */
int child = cth->cth_parname != 0;
int nlstructs = 0, nlunions = 0;
@ -704,11 +704,11 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
if (child)
{
ctf_dprintf ("CTF container %p is a child\n", (void *) fp);
ctf_dprintf ("CTF dict %p is a child\n", (void *) fp);
fp->ctf_flags |= LCTF_CHILD;
}
else
ctf_dprintf ("CTF container %p is a parent\n", (void *) fp);
ctf_dprintf ("CTF dict %p is a parent\n", (void *) fp);
/* Now that we've counted up the number of each type, we can allocate
the hash tables, type translation table, and pointer table. */
@ -885,9 +885,9 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
}
case CTF_K_POINTER:
/* If the type referenced by the pointer is in this CTF container,
then store the index of the pointer type in
fp->ctf_ptrtab[ index of referenced type ]. */
/* If the type referenced by the pointer is in this CTF dict, then
store the index of the pointer type in fp->ctf_ptrtab[ index of
referenced type ]. */
if (LCTF_TYPE_ISCHILD (fp, tp->ctt_type) == child
&& LCTF_TYPE_TO_INDEX (fp, tp->ctt_type) <= fp->ctf_typemax)
@ -1045,7 +1045,7 @@ flip_vars (void *start, size_t len)
ctf_stype followed by variable data. */
static int
flip_types (ctf_file_t *fp, void *start, size_t len)
flip_types (ctf_dict_t *fp, void *start, size_t len)
{
ctf_type_t *t = start;
@ -1203,7 +1203,7 @@ flip_types (ctf_file_t *fp, void *start, size_t len)
data, this is no real loss. */
static int
flip_ctf (ctf_file_t *fp, ctf_header_t *cth, unsigned char *buf)
flip_ctf (ctf_dict_t *fp, ctf_header_t *cth, unsigned char *buf)
{
flip_lbls (buf + cth->cth_lbloff, cth->cth_objtoff - cth->cth_lbloff);
flip_objts (buf + cth->cth_objtoff, cth->cth_funcoff - cth->cth_objtoff);
@ -1214,9 +1214,9 @@ flip_ctf (ctf_file_t *fp, ctf_header_t *cth, unsigned char *buf)
return flip_types (fp, buf + cth->cth_typeoff, cth->cth_stroff - cth->cth_typeoff);
}
/* Set up the ctl hashes in a ctf_file_t. Called by both writable and
/* Set up the ctl hashes in a ctf_dict_t. Called by both writable and
non-writable dictionary initialization. */
void ctf_set_ctl_hashes (ctf_file_t *fp)
void ctf_set_ctl_hashes (ctf_dict_t *fp)
{
/* Initialize the ctf_lookup_by_name top-level dictionary. We keep an
array of type name prefixes and the corresponding ctf_hash to use. */
@ -1239,7 +1239,7 @@ void ctf_set_ctl_hashes (ctf_file_t *fp)
/* Open a CTF file, mocking up a suitable ctf_sect. */
ctf_file_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
ctf_dict_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
const char *symsect, size_t symsect_size,
size_t symsect_entsize,
const char *strsect, size_t strsect_size,
@ -1253,7 +1253,7 @@ ctf_file_t *ctf_simple_open (const char *ctfsect, size_t ctfsect_size,
/* Open a CTF file, mocking up a suitable ctf_sect and overriding the external
strtab with a synthetic one. */
ctf_file_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
ctf_dict_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
const char *symsect, size_t symsect_size,
size_t symsect_entsize,
const char *strsect, size_t strsect_size,
@ -1300,11 +1300,11 @@ ctf_file_t *ctf_simple_open_internal (const char *ctfsect, size_t ctfsect_size,
}
/* Decode the specified CTF buffer and optional symbol table, and create a new
CTF container representing the symbolic debugging information. This code can
CTF dict representing the symbolic debugging information. This code can
be used directly by the debugger, or it can be used as the engine for
ctf_fdopen() or ctf_open(), below. */
ctf_file_t *
ctf_dict_t *
ctf_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_sect_t *strsect, int *errp)
{
@ -1313,7 +1313,7 @@ ctf_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
/* Like ctf_bufopen, but overriding the external strtab with a synthetic one. */
ctf_file_t *
ctf_dict_t *
ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_sect_t *strsect, ctf_dynhash_t *syn_strtab,
int writable, int *errp)
@ -1321,7 +1321,7 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
const ctf_preamble_t *pp;
size_t hdrsz = sizeof (ctf_header_t);
ctf_header_t *hp;
ctf_file_t *fp;
ctf_dict_t *fp;
int foreign_endian = 0;
int err;
@ -1393,10 +1393,10 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
if (ctfsect->cts_size < hdrsz)
return (ctf_set_open_errno (errp, ECTF_NOCTFBUF));
if ((fp = malloc (sizeof (ctf_file_t))) == NULL)
if ((fp = malloc (sizeof (ctf_dict_t))) == NULL)
return (ctf_set_open_errno (errp, ENOMEM));
memset (fp, 0, sizeof (ctf_file_t));
memset (fp, 0, sizeof (ctf_dict_t));
if (writable)
fp->ctf_flags |= LCTF_RDWR;
@ -1511,7 +1511,7 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
}
/* Once we have uncompressed and validated the CTF data buffer, we can
proceed with initializing the ctf_file_t we allocated above.
proceed with initializing the ctf_dict_t we allocated above.
Nothing that depends on buf or base should be set directly in this function
before the init_types() call, because it may be reallocated during
@ -1575,8 +1575,8 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
ctf_set_base (fp, hp, fp->ctf_base);
/* No need to do anything else for dynamic containers: they do not support
symbol lookups, and the type table is maintained in the dthashes. */
/* No need to do anything else for dynamic dicts: they do not support symbol
lookups, and the type table is maintained in the dthashes. */
if (fp->ctf_flags & LCTF_RDWR)
{
fp->ctf_refcnt = 1;
@ -1624,37 +1624,37 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
bad:
ctf_set_open_errno (errp, err);
ctf_err_warn_to_open (fp);
ctf_file_close (fp);
ctf_dict_close (fp);
return NULL;
}
/* Bump the refcount on the specified CTF container, to allow export of
ctf_file_t's from iterators that open and close the ctf_file_t around the
loop. (This does not extend their lifetime beyond that of the ctf_archive_t
in which they are contained.) */
/* Bump the refcount on the specified CTF dict, to allow export of ctf_dict_t's
from iterators that open and close the ctf_dict_t around the loop. (This
does not extend their lifetime beyond that of the ctf_archive_t in which they
are contained.) */
void
ctf_ref (ctf_file_t *fp)
ctf_ref (ctf_dict_t *fp)
{
fp->ctf_refcnt++;
}
/* Close the specified CTF container and free associated data structures. Note
that ctf_file_close() is a reference counted operation: if the specified file
is the parent of other active containers, its reference count will be greater
than one and it will be freed later when no active children exist. */
/* Close the specified CTF dict and free associated data structures. Note that
ctf_dict_close() is a reference counted operation: if the specified file is
the parent of other active dict, its reference count will be greater than one
and it will be freed later when no active children exist. */
void
ctf_file_close (ctf_file_t *fp)
ctf_dict_close (ctf_dict_t *fp)
{
ctf_dtdef_t *dtd, *ntd;
ctf_dvdef_t *dvd, *nvd;
ctf_err_warning_t *err, *nerr;
if (fp == NULL)
return; /* Allow ctf_file_close(NULL) to simplify caller code. */
return; /* Allow ctf_dict_close(NULL) to simplify caller code. */
ctf_dprintf ("ctf_file_close(%p) refcnt=%u\n", (void *) fp, fp->ctf_refcnt);
ctf_dprintf ("ctf_dict_close(%p) refcnt=%u\n", (void *) fp, fp->ctf_refcnt);
if (fp->ctf_refcnt > 1)
{
@ -1672,7 +1672,7 @@ ctf_file_close (ctf_file_t *fp)
free (fp->ctf_dyncuname);
free (fp->ctf_dynparname);
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
ctf_file_close (fp->ctf_parent);
ctf_dict_close (fp->ctf_parent);
for (dtd = ctf_list_next (&fp->ctf_dtdefs); dtd != NULL; dtd = ntd)
{
@ -1743,6 +1743,13 @@ ctf_file_close (ctf_file_t *fp)
free (fp);
}
/* Backward compatibility. */
void
ctf_file_close (ctf_file_t *fp)
{
ctf_dict_close (fp);
}
/* The converse of ctf_open(). ctf_open() disguises whatever it opens as an
archive, so closing one is just like closing an archive. */
void
@ -1751,36 +1758,42 @@ ctf_close (ctf_archive_t *arc)
ctf_arc_close (arc);
}
/* Get the CTF archive from which this ctf_file_t is derived. */
/* Get the CTF archive from which this ctf_dict_t is derived. */
ctf_archive_t *
ctf_get_arc (const ctf_file_t *fp)
ctf_get_arc (const ctf_dict_t *fp)
{
return fp->ctf_archive;
}
/* Return the ctfsect out of the core ctf_impl. Useful for freeing the
ctfsect's data * after ctf_file_close(), which is why we return the actual
ctfsect's data * after ctf_dict_close(), which is why we return the actual
structure, not a pointer to it, since that is likely to become a pointer to
freed data before the return value is used under the expected use case of
ctf_getsect()/ ctf_file_close()/free(). */
ctf_getsect()/ ctf_dict_close()/free(). */
ctf_sect_t
ctf_getdatasect (const ctf_file_t *fp)
ctf_getdatasect (const ctf_dict_t *fp)
{
return fp->ctf_data;
}
/* Return the CTF handle for the parent CTF container, if one exists.
Otherwise return NULL to indicate this container has no imported parent. */
ctf_file_t *
ctf_parent_file (ctf_file_t *fp)
/* Return the CTF handle for the parent CTF dict, if one exists. Otherwise
return NULL to indicate this dict has no imported parent. */
ctf_dict_t *
ctf_parent_dict (ctf_dict_t *fp)
{
return fp->ctf_parent;
}
/* Return the name of the parent CTF container, if one exists. Otherwise
return NULL to indicate this container is a root container. */
/* Backward compatibility. */
ctf_dict_t *
ctf_parent_file (ctf_dict_t *fp)
{
return ctf_parent_dict (fp);
}
/* Return the name of the parent CTF dict, if one exists, or NULL otherwise. */
const char *
ctf_parent_name (ctf_file_t *fp)
ctf_parent_name (ctf_dict_t *fp)
{
return fp->ctf_parname;
}
@ -1788,7 +1801,7 @@ ctf_parent_name (ctf_file_t *fp)
/* Set the parent name. It is an error to call this routine without calling
ctf_import() at some point. */
int
ctf_parent_name_set (ctf_file_t *fp, const char *name)
ctf_parent_name_set (ctf_dict_t *fp, const char *name)
{
if (fp->ctf_dynparname != NULL)
free (fp->ctf_dynparname);
@ -1800,16 +1813,16 @@ ctf_parent_name_set (ctf_file_t *fp, const char *name)
}
/* Return the name of the compilation unit this CTF file applies to. Usually
non-NULL only for non-parent containers. */
non-NULL only for non-parent dicts. */
const char *
ctf_cuname (ctf_file_t *fp)
ctf_cuname (ctf_dict_t *fp)
{
return fp->ctf_cuname;
}
/* Set the compilation unit name. */
int
ctf_cuname_set (ctf_file_t *fp, const char *name)
ctf_cuname_set (ctf_dict_t *fp, const char *name)
{
if (fp->ctf_dyncuname != NULL)
free (fp->ctf_dyncuname);
@ -1820,11 +1833,11 @@ ctf_cuname_set (ctf_file_t *fp, const char *name)
return 0;
}
/* Import the types from the specified parent container by storing a pointer
to it in ctf_parent and incrementing its reference count. Only one parent
is allowed: if a parent already exists, it is replaced by the new parent. */
/* Import the types from the specified parent dict by storing a pointer to it in
ctf_parent and incrementing its reference count. Only one parent is allowed:
if a parent already exists, it is replaced by the new parent. */
int
ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
ctf_import (ctf_dict_t *fp, ctf_dict_t *pfp)
{
if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
return (ctf_set_errno (fp, EINVAL));
@ -1833,7 +1846,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
return (ctf_set_errno (fp, ECTF_DMODEL));
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
ctf_file_close (fp->ctf_parent);
ctf_dict_close (fp->ctf_parent);
fp->ctf_parent = NULL;
if (pfp != NULL)
@ -1858,7 +1871,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
caller must do all freeing itself. Used internally to avoid refcount
loops. */
int
ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
ctf_import_unref (ctf_dict_t *fp, ctf_dict_t *pfp)
{
if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
return (ctf_set_errno (fp, EINVAL));
@ -1867,7 +1880,7 @@ ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
return (ctf_set_errno (fp, ECTF_DMODEL));
if (fp->ctf_parent && !fp->ctf_parent_unreffed)
ctf_file_close (fp->ctf_parent);
ctf_dict_close (fp->ctf_parent);
fp->ctf_parent = NULL;
if (pfp != NULL)
@ -1886,9 +1899,9 @@ ctf_import_unref (ctf_file_t *fp, ctf_file_t *pfp)
return 0;
}
/* Set the data model constant for the CTF container. */
/* Set the data model constant for the CTF dict. */
int
ctf_setmodel (ctf_file_t *fp, int model)
ctf_setmodel (ctf_dict_t *fp, int model)
{
const ctf_dmodel_t *dp;
@ -1904,24 +1917,24 @@ ctf_setmodel (ctf_file_t *fp, int model)
return (ctf_set_errno (fp, EINVAL));
}
/* Return the data model constant for the CTF container. */
/* Return the data model constant for the CTF dict. */
int
ctf_getmodel (ctf_file_t *fp)
ctf_getmodel (ctf_dict_t *fp)
{
return fp->ctf_dmodel->ctd_code;
}
/* The caller can hang an arbitrary pointer off each ctf_file_t using this
/* The caller can hang an arbitrary pointer off each ctf_dict_t using this
function. */
void
ctf_setspecific (ctf_file_t *fp, void *data)
ctf_setspecific (ctf_dict_t *fp, void *data)
{
fp->ctf_specific = data;
}
/* Retrieve the arbitrary pointer again. */
void *
ctf_getspecific (ctf_file_t *fp)
ctf_getspecific (ctf_dict_t *fp)
{
return fp->ctf_specific;
}

View File

@ -23,7 +23,7 @@
/* 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)];
@ -58,7 +58,7 @@ ctf_strraw_explicit (ctf_file_t *fp, uint32_t name, ctf_strs_t *strtab)
/* 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);
}
@ -66,7 +66,7 @@ ctf_strraw (ctf_file_t *fp, uint32_t name)
/* 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 : "(?)");
@ -99,7 +99,7 @@ ctf_str_free_atom (void *a)
/* 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);
@ -131,7 +131,7 @@ ctf_str_create_atoms (ctf_file_t *fp)
/* 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);
@ -143,7 +143,7 @@ ctf_str_free_atoms (ctf_file_t *fp)
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;
@ -215,7 +215,7 @@ ctf_str_add_ref_internal (ctf_file_t *fp, const char *str,
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)
@ -232,7 +232,7 @@ ctf_str_add (ctf_file_t *fp, const char *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)
@ -248,7 +248,7 @@ ctf_str_add_ref (ctf_file_t *fp, const char *str, uint32_t *ref)
/* 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)
@ -264,7 +264,7 @@ ctf_str_add_external (ctf_file_t *fp, const char *str, uint32_t offset)
/* 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;
@ -297,7 +297,7 @@ ctf_str_rollback_atom (void *key _libctf_unused_, void *value, void *arg)
/* 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);
}
@ -313,7 +313,7 @@ ctf_str_purge_one_atom_refs (void *key _libctf_unused_, void *value,
/* 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);
@ -410,7 +410,7 @@ ctf_str_sort_strtab (const void *a, const void *b)
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;
@ -472,7 +472,7 @@ ctf_str_write_strtab (ctf_file_t *fp)
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);

View File

@ -201,7 +201,7 @@ static ctf_list_t open_errors;
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;
@ -244,7 +244,7 @@ ctf_err_warn (ctf_file_t *fp, int is_warning, int err,
/* 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);
}
@ -266,7 +266,7 @@ ctf_err_warn_to_open (ctf_file_t *fp)
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;
@ -335,7 +335,7 @@ ctf_errwarning_next (ctf_file_t *fp, ctf_next_t **it, int *is_warning,
}
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"),

View File

@ -24,13 +24,13 @@
/* 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));
}
@ -39,9 +39,9 @@ ctf_type_ischild (ctf_file_t * fp, ctf_id_t 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;
@ -109,10 +109,10 @@ ctf_member_iter (ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
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;
@ -227,9 +227,9 @@ ctf_member_next (ctf_file_t *fp, ctf_id_t type, ctf_next_t **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;
@ -279,10 +279,10 @@ ctf_enum_iter (ctf_file_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
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;
@ -388,7 +388,7 @@ ctf_enum_next (ctf_file_t *fp, ctf_id_t type, ctf_next_t **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
@ -396,7 +396,7 @@ ctf_enum_next (ctf_file_t *fp, ctf_id_t type, ctf_next_t **it,
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);
@ -412,7 +412,7 @@ ctf_type_iter (ctf_file_t *fp, ctf_type_f *func, void *arg)
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
@ -420,7 +420,7 @@ ctf_type_iter (ctf_file_t *fp, ctf_type_f *func, void *arg)
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);
@ -437,7 +437,7 @@ ctf_type_iter_all (ctf_file_t *fp, ctf_type_all_f *func, void *arg)
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.
@ -446,7 +446,7 @@ ctf_type_iter_all (ctf_file_t *fp, ctf_type_all_f *func, void *arg)
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;
@ -486,11 +486,11 @@ ctf_type_next (ctf_file_t *fp, ctf_next_t **it, int *flag, int want_hidden)
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;
@ -520,12 +520,12 @@ ctf_variable_iter (ctf_file_t *fp, ctf_variable_f *func, void *arg)
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;
@ -586,10 +586,10 @@ ctf_variable_next (ctf_file_t *fp, ctf_next_t **it, const char **name)
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)
@ -627,7 +627,7 @@ ctf_type_resolve (ctf_file_t *fp, ctf_id_t type)
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;
@ -645,7 +645,7 @@ ctf_type_resolve_unsliced (ctf_file_t *fp, ctf_id_t type)
/* 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);
}
@ -654,7 +654,7 @@ ctf_id_t ctf_lookup_by_rawname (ctf_file_t *fp, int kind, const char *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;
@ -669,7 +669,7 @@ ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *fp, ctf_names_t *np, const char *nam
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;
@ -710,7 +710,7 @@ ctf_type_aname (ctf_file_t *fp, ctf_id_t type)
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);
@ -837,7 +837,7 @@ ctf_type_aname (ctf_file_t *fp, ctf_id_t type)
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;
@ -859,17 +859,17 @@ ctf_type_lname (ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
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;
@ -883,7 +883,7 @@ ctf_type_name_raw (ctf_file_t *fp, ctf_id_t type)
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);
@ -897,7 +897,7 @@ ctf_type_aname_raw (ctf_file_t *fp, ctf_id_t 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;
@ -947,10 +947,10 @@ ctf_type_size (ctf_file_t *fp, ctf_id_t type)
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)
@ -1039,7 +1039,7 @@ ctf_type_align (ctf_file_t *fp, ctf_id_t type)
/* 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;
@ -1053,7 +1053,7 @@ ctf_type_kind_unsliced (ctf_file_t *fp, ctf_id_t type)
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;
@ -1073,7 +1073,7 @@ ctf_type_kind (ctf_file_t *fp, ctf_id_t type)
/* 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;
@ -1094,9 +1094,9 @@ ctf_type_kind_forwarded (ctf_file_t *fp, ctf_id_t type)
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)
@ -1139,12 +1139,12 @@ ctf_type_reference (ctf_file_t *fp, ctf_id_t type)
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)
@ -1168,9 +1168,9 @@ ctf_type_pointer (ctf_file_t *fp, ctf_id_t type)
/* 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;
@ -1247,7 +1247,7 @@ ctf_type_encoding (ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep)
}
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;
@ -1284,8 +1284,8 @@ ctf_type_cmp (ctf_file_t *lfp, ctf_id_t ltype, ctf_file_t *rfp,
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;
@ -1360,9 +1360,9 @@ ctf_type_compat (ctf_file_t *lfp, ctf_id_t ltype,
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;
@ -1383,10 +1383,10 @@ ctf_member_count (ctf_file_t *fp, ctf_id_t type)
/* 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;
@ -1459,9 +1459,9 @@ ctf_member_info (ctf_file_t *fp, ctf_id_t type, const char *name,
/* 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;
@ -1493,9 +1493,9 @@ ctf_array_info (ctf_file_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
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;
@ -1546,9 +1546,9 @@ ctf_enum_name (ctf_file_t *fp, ctf_id_t type, int value)
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;
@ -1607,7 +1607,7 @@ ctf_enum_value (ctf_file_t * fp, ctf_id_t type, const char *name, int *valp)
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;
@ -1649,7 +1649,7 @@ ctf_func_type_info (ctf_file_t *fp, ctf_id_t type, ctf_funcinfo_t *fip)
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;
@ -1686,7 +1686,7 @@ ctf_func_type_args (ctf_file_t *fp, ctf_id_t type, uint32_t argc, ctf_id_t *argv
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;
@ -1765,7 +1765,7 @@ ctf_type_rvisit (ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func,
/* 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));
}

View File

@ -162,7 +162,7 @@ ctf_str_append_noerr (char *s, const char *append)
/* 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)
{
@ -184,11 +184,11 @@ ctf_set_open_errno (int *errp, int error)
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;

View File

@ -174,3 +174,9 @@ LIBCTF_1.0 {
local:
*;
};
LIBCTF_1.1 {
global:
ctf_dict_close;
ctf_parent_dict;
} LIBCTF_1.0;