]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: don't lose track of all valid types upon serialization
authorNick Alcock <nick.alcock@oracle.com>
Thu, 18 Mar 2021 12:37:52 +0000 (12:37 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 18 Mar 2021 12:40:40 +0000 (12:40 +0000)
One pattern which is rarely done in libctf but which is meant to work is
this:

ctf_create();
ctf_add_*(); // add stuff
ctf_type_*() // look stuff up
ctf_write_*();
ctf_add_*(); // should still work
ctf_type_*() // so should this
ctf_write_*(); // and this

i.e., writing out a dict should not break it and you should be able to
do everything you could do with it before, including writing it out
again.

Unfortunately this has been broken for a while because the field which
indicates the maximum valid type ID was not preserved across
serialization: so type additions after serialization would overwrite
types (obviously disastrous) and type lookups would just fail.

Fix trivial.

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

* ctf-serialize.c (ctf_serialize): Preserve ctf_typemax across
serialization.

libctf/ChangeLog
libctf/ctf-serialize.c

index 3eff44c146a278090b9446116f6aaeb1d44592ae..c27464110fcf9a7cb915b39b0e1425c8623db2e1 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-18  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-serialize.c (ctf_serialize): Preserve ctf_typemax across
+       serialization.
+
 2021-03-18  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-impl.h (ctf_dtdef_t) <dtd_u.dtu_argv>: Remove.
index 460ae1a510ed8e2934a05004cec4551a591171ed..17f11f67ffb8d315971000cc26961e222ad971f5 100644 (file)
@@ -1113,6 +1113,7 @@ ctf_serialize (ctf_dict_t *fp)
   nfp->ctf_dynsyms = fp->ctf_dynsyms;
   nfp->ctf_ptrtab = fp->ctf_ptrtab;
   nfp->ctf_pptrtab = fp->ctf_pptrtab;
+  nfp->ctf_typemax = fp->ctf_typemax;
   nfp->ctf_dynsymidx = fp->ctf_dynsymidx;
   nfp->ctf_dynsymmax = fp->ctf_dynsymmax;
   nfp->ctf_ptrtab_len = fp->ctf_ptrtab_len;