summaryrefslogtreecommitdiff
path: root/libctf/ctf-archive.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
committerNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:05 +0000
commitae41200ba807f4342ae7ea5334a29cd6f519b02c (patch)
tree8f07eb4181e8e20ad4b91c0497fcae48252901d8 /libctf/ctf-archive.c
parent139633c307eb6f5746ea04f94a0b6382e51bccb9 (diff)
downloadbinutils-gdb-ae41200ba807f4342ae7ea5334a29cd6f519b02c.tar.gz
libctf, include, binutils, gdb: rename CTF-opening functions
The functions that return ctf_dict_t's given a ctf_archive_t and a name are very clumsily named. It sounds like they return *archives*, not dictionaries, and the names are very long and clunky. Why do we have a ctf_arc_open_by_name when it opens a dictionary, not an archive, and when there is no way to open a dictionary in any other way? The answer is purely internal: the function is located in ctf-archive.c, and everything in there was called ctf_arc_*, and there is another way to open a dict (by offset in the archive), that is internal to ctf-archive.c and that nothing else can call. This is clearly bad naming. The internal organization of the source tree should not dictate public API names! So rename things (keeping the old, bad names for compatibility), and adjust all users. You now open a dict using ctf_dict_open, and open it giving ELF sections via ctf_dict_open_sections. binutils/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * objdump.c (dump_ctf): Use ctf_dict_open, not ctf_arc_open_by_name. * readelf.c (dump_section_as_ctf): Likewise. gdb/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctfread.c (elfctf_build_psymtabs): Use ctf_dict_open, not ctf_arc_open_by_name. include/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (ctf_arc_open_by_name): Rename to... (ctf_dict_open): ... this, keeping compatibility function. (ctf_arc_open_by_name_sections): Rename to... (ctf_dict_open_sections): ... this, keeping compatibility function. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-archive.c (ctf_arc_open_by_offset): Rename to... (ctf_dict_open_by_offset): ... this. Adjust callers. (ctf_arc_open_by_name_internal): Rename to... (ctf_dict_open_internal): ... this. Adjust callers. (ctf_arc_open_by_name_sections): Rename to... (ctf_dict_open_sections): ... this, keeping compatibility function. (ctf_arc_open_by_name): Rename to... (ctf_dict_open): ... this, keeping compatibility function. * libctf.ver: New functions added. * ctf-link.c (ctf_link_one_input_archive): Adjusted accordingly. (ctf_link_deduplicating_open_inputs): Likewise.
Diffstat (limited to 'libctf/ctf-archive.c')
-rw-r--r--libctf/ctf-archive.c75
1 files changed, 46 insertions, 29 deletions
diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index 90780da3834..72cdef91ac4 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -33,10 +33,10 @@
#endif
static off_t arc_write_one_ctf (ctf_dict_t * f, int fd, size_t threshold);
-static ctf_dict_t *ctf_arc_open_by_offset (const struct ctf_archive *arc,
- const ctf_sect_t *symsect,
- const ctf_sect_t *strsect,
- size_t offset, int *errp);
+static ctf_dict_t *ctf_dict_open_by_offset (const struct ctf_archive *arc,
+ const ctf_sect_t *symsect,
+ const ctf_sect_t *strsect,
+ size_t offset, int *errp);
static int sort_modent_by_name (const void *one, const void *two, void *n);
static void *arc_mmap_header (int fd, size_t headersz);
static void *arc_mmap_file (int fd, size_t size);
@@ -506,10 +506,10 @@ ctf_arc_close (ctf_archive_t *arc)
/* 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_dict_t *
-ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
- const ctf_sect_t *symsect,
- const ctf_sect_t *strsect,
- const char *name, int *errp)
+ctf_dict_open_internal (const struct ctf_archive *arc,
+ const ctf_sect_t *symsect,
+ const ctf_sect_t *strsect,
+ const char *name, int *errp)
{
struct ctf_archive_modent *modent;
const char *search_nametbl;
@@ -517,7 +517,7 @@ ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
if (name == NULL)
name = _CTF_SECTION; /* The default name. */
- ctf_dprintf ("ctf_arc_open_by_name(%s): opening\n", name);
+ ctf_dprintf ("ctf_dict_open_internal(%s): opening\n", name);
modent = (ctf_archive_modent_t *) ((char *) arc
+ sizeof (struct ctf_archive));
@@ -536,8 +536,8 @@ ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
return NULL;
}
- return ctf_arc_open_by_offset (arc, symsect, strsect,
- le64toh (modent->ctf_offset), errp);
+ return ctf_dict_open_by_offset (arc, symsect, strsect,
+ le64toh (modent->ctf_offset), errp);
}
/* Return the ctf_dict_t with the given name, or NULL if none, setting 'err' if
@@ -547,17 +547,17 @@ ctf_arc_open_by_name_internal (const struct ctf_archive *arc,
Public entry point. */
ctf_dict_t *
-ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
- const ctf_sect_t *symsect,
- const ctf_sect_t *strsect,
- const char *name,
- int *errp)
+ctf_dict_open_sections (const ctf_archive_t *arc,
+ const ctf_sect_t *symsect,
+ const ctf_sect_t *strsect,
+ const char *name,
+ int *errp)
{
if (arc->ctfi_is_archive)
{
ctf_dict_t *ret;
- ret = ctf_arc_open_by_name_internal (arc->ctfi_archive, symsect, strsect,
- name, errp);
+ ret = ctf_dict_open_internal (arc->ctfi_archive, symsect, strsect,
+ name, errp);
if (ret)
ret->ctf_archive = (ctf_archive_t *) arc;
return ret;
@@ -581,7 +581,7 @@ ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
Public entry point. */
ctf_dict_t *
-ctf_arc_open_by_name (const ctf_archive_t *arc, const char *name, int *errp)
+ctf_dict_open (const ctf_archive_t *arc, const char *name, int *errp)
{
const ctf_sect_t *symsect = &arc->ctfi_symsect;
const ctf_sect_t *strsect = &arc->ctfi_strsect;
@@ -591,21 +591,21 @@ ctf_arc_open_by_name (const ctf_archive_t *arc, const char *name, int *errp)
if (strsect->cts_name == NULL)
strsect = NULL;
- return ctf_arc_open_by_name_sections (arc, symsect, strsect, name, errp);
+ return ctf_dict_open_sections (arc, symsect, strsect, name, errp);
}
/* Return the ctf_dict_t at the given ctfa_ctfs-relative offset, or NULL if
none, setting 'err' if non-NULL. */
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_dict_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_dict_t *fp;
- ctf_dprintf ("ctf_arc_open_by_offset(%lu): opening\n", (unsigned long) offset);
+ ctf_dprintf ("ctf_dict_open_by_offset(%lu): opening\n", (unsigned long) offset);
memset (&ctfsect, 0, sizeof (ctf_sect_t));
@@ -621,6 +621,24 @@ ctf_arc_open_by_offset (const struct ctf_archive *arc,
return fp;
}
+/* Backward compatibility. */
+ctf_dict_t *
+ctf_arc_open_by_name (const ctf_archive_t *arc, const char *name,
+ int *errp)
+{
+ return ctf_dict_open (arc, name, errp);
+}
+
+ctf_dict_t *
+ctf_arc_open_by_name_sections (const ctf_archive_t *arc,
+ const ctf_sect_t *symsect,
+ const ctf_sect_t *strsect,
+ const char *name,
+ int *errp)
+{
+ return ctf_dict_open_sections (arc, symsect, strsect, name, errp);
+}
+
/* Return the number of members in an archive. */
size_t
ctf_archive_count (const ctf_archive_t *wrapper)
@@ -699,8 +717,8 @@ ctf_archive_iter_internal (const ctf_archive_t *wrapper,
const char *name;
name = &nametbl[le64toh (modent[i].name_offset)];
- if ((f = ctf_arc_open_by_name_internal (arc, symsect, strsect,
- name, &rc)) == NULL)
+ if ((f = ctf_dict_open_internal (arc, symsect, strsect,
+ name, &rc)) == NULL)
return rc;
f->ctf_archive = (ctf_archive_t *) wrapper;
@@ -837,8 +855,7 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
if (name)
*name = name_;
- f = ctf_arc_open_by_name_internal (arc, symsect, strsect,
- name_, errp);
+ f = ctf_dict_open_internal (arc, symsect, strsect, name_, errp);
f->ctf_archive = (ctf_archive_t *) wrapper;
return f;
}