diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2020-11-20 13:34:04 +0000 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2020-11-20 13:34:04 +0000 |
commit | 139633c307eb6f5746ea04f94a0b6382e51bccb9 (patch) | |
tree | 6c070eeecd42d5c5bc93041be7fcc1279495a266 /libctf/ctf-archive.c | |
parent | cbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378 (diff) | |
download | gdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.zip gdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.tar.gz gdb-139633c307eb6f5746ea04f94a0b6382e51bccb9.tar.bz2 |
libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_t
The naming of the ctf_file_t type in libctf is a historical curiosity.
Back in the Solaris days, CTF dictionaries were originally generated as
a separate file and then (sometimes) merged into objects: hence the
datatype was named ctf_file_t, and known as a "CTF file". Nowadays, raw
CTF is essentially never written to a file on its own, and the datatype
changed name to a "CTF dictionary" years ago. So the term "CTF file"
refers to something that is never a file! This is at best confusing.
The type has also historically been known as a 'CTF container", which is
even more confusing now that we have CTF archives which are *also* a
sort of container (they contain CTF dictionaries), but which are never
referred to as containers in the source code.
So fix this by completing the renaming, renaming ctf_file_t to
ctf_dict_t throughout, and renaming those few functions that refer to
CTF files by name (keeping compatibility aliases) to refer to dicts
instead. Old users who still refer to ctf_file_t will see (harmless)
pointer-compatibility warnings at compile time, but the ABI is unchanged
(since C doesn't mangle names, and ctf_file_t was always an opaque type)
and things will still compile fine as long as -Werror is not specified.
All references to CTF containers and CTF files in the source code are
fixed to refer to CTF dicts instead.
Further (smaller) renamings of annoyingly-named functions to come, as
part of the process of souping up queries across whole archives at once
(needed for the function info and data object sections).
binutils/ChangeLog
2020-11-20 Nick Alcock <nick.alcock@oracle.com>
* objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
(dump_ctf_archive_member): Likewise.
(dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close.
* readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
(dump_ctf_archive_member): Likewise.
(dump_section_as_ctf): Likewise. Use ctf_dict_close, not
ctf_file_close.
gdb/ChangeLog
2020-11-20 Nick Alcock <nick.alcock@oracle.com>
* ctfread.c: Change uses of ctf_file_t to ctf_dict_t.
(ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close.
include/ChangeLog
2020-11-20 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (ctf_file_t): Rename to...
(ctf_dict_t): ... this. Keep ctf_file_t around for compatibility.
(struct ctf_file): Likewise rename to...
(struct ctf_dict): ... this.
(ctf_file_close): Rename to...
(ctf_dict_close): ... this, keeping compatibility function.
(ctf_parent_file): Rename to...
(ctf_parent_dict): ... this, keeping compatibility function.
All callers adjusted.
* ctf.h: Rename references to ctf_file_t to ctf_dict_t.
(struct ctf_archive) <ctfa_nfiles>: Rename to...
<ctfa_ndicts>: ... this.
ld/ChangeLog
2020-11-20 Nick Alcock <nick.alcock@oracle.com>
* ldlang.c (ctf_output): This is a ctf_dict_t now.
(lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t.
(ldlang_open_ctf): Adjust comment.
(lang_merge_ctf): Use ctf_dict_close, not ctf_file_close.
* ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to
ctf_dict_t. Change opaque declaration accordingly.
* ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust.
* ldemul.h (examine_strtab_for_ctf): Likewise.
(ldemul_examine_strtab_for_ctf): Likewise.
* ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise.
libctf/ChangeLog
2020-11-20 Nick Alcock <nick.alcock@oracle.com>
* ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations
adjusted.
(ctf_fileops): Rename to...
(ctf_dictops): ... this.
(ctf_dedup_t) <cd_id_to_file_t>: Rename to...
<cd_id_to_dict_t>: ... this.
(ctf_file_t): Fix outdated comment.
<ctf_fileops>: Rename to...
<ctf_dictops>: ... this.
(struct ctf_archive_internal) <ctfi_file>: Rename to...
<ctfi_dict>: ... this.
* ctf-archive.c: Rename ctf_file_t to ctf_dict_t.
Rename ctf_archive.ctfa_nfiles to ctfa_ndicts.
Rename ctf_file_close to ctf_dict_close. All users adjusted.
* ctf-create.c: Likewise. Refer to CTF dicts, not CTF containers.
(ctf_bundle_t) <ctb_file>: Rename to...
<ctb_dict): ... this.
* ctf-decl.c: Rename ctf_file_t to ctf_dict_t.
* ctf-dedup.c: Likewise. Rename ctf_file_close to
ctf_dict_close. Refer to CTF dicts, not CTF containers.
* ctf-dump.c: Likewise.
* ctf-error.c: Likewise.
* ctf-hash.c: Likewise.
* ctf-inlines.h: Likewise.
* ctf-labels.c: Likewise.
* ctf-link.c: Likewise.
* ctf-lookup.c: Likewise.
* ctf-open-bfd.c: Likewise.
* ctf-string.c: Likewise.
* ctf-subr.c: Likewise.
* ctf-types.c: Likewise.
* ctf-util.c: Likewise.
* ctf-open.c: Likewise.
(ctf_file_close): Rename to...
(ctf_dict_close): ...this.
(ctf_file_close): New trivial wrapper around ctf_dict_close, for
compatibility.
(ctf_parent_file): Rename to...
(ctf_parent_dict): ... this.
(ctf_parent_file): New trivial wrapper around ctf_parent_dict, for
compatibility.
* libctf.ver: Add ctf_dict_close and ctf_parent_dict.
Diffstat (limited to 'libctf/ctf-archive.c')
-rw-r--r-- | libctf/ctf-archive.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c index 799c3fb..90780da 100644 --- a/libctf/ctf-archive.c +++ b/libctf/ctf-archive.c @@ -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; |