[binutils-gdb] libctf: ctf_archive_next should set the parent name consistently
Nick Alcock
nix@sourceware.org
Tue Mar 2 15:11:41 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eaa2913a7acead8654e7e79ba13c0d22fd70a452
commit eaa2913a7acead8654e7e79ba13c0d22fd70a452
Author: Nick Alcock <nick.alcock@oracle.com>
Date: Thu Feb 18 16:56:23 2021 +0000
libctf: ctf_archive_next should set the parent name consistently
The top level of CTF containers is a "CTF archive", which contains a
collection of named members (each a CTF dictionary). In the serialized
file format, this is optional and skipped if the archive would have only
one member, as when no ambiguous types are present: so it is commonplace
to have a simple ctf_dict_t written out, with no archive container
wrapped around it.
But, unlike ctf_archive_iter, ctf_archive_next didn't quite handle this
case right. It should set the name of this fake "member" to
_CTF_SECTION, i.e. ".ctf", but it was failing to do so, so callers got
an unintialized variable back instead and were understandably confused.
So set the name properly.
libctf/ChangeLog
2021-03-02 Nick Alcock <nick.alcock@oracle.com>
* ctf-archive.c (ctf_archive_next): Set the name of parents in
single-member archives.
Diff:
---
libctf/ChangeLog | 5 +++++
libctf/ctf-archive.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index da27a8fed6b..db44cae5ad3 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-02 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-archive.c (ctf_archive_next): Set the name of parents in
+ single-member archives.
+
2021-02-26 Alan Modra <amodra@gmail.com>
* Makefile.in: Regenerate.
diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index 6d9c75c9013..6e1bf151f1a 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -1165,6 +1165,8 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
if (!skip_parent)
{
wrapper->ctfi_dict->ctf_refcnt++;
+ if (name)
+ *name = _CTF_SECTION;
return wrapper->ctfi_dict;
}
}
More information about the Binutils-cvs
mailing list