libctf, types: allow ctf_type_reference of dynamic slices
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Jun 2020 19:25:02 +0000 (20:25 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 16:57:24 +0000 (17:57 +0100)
One spot was missed when we rejigged ctf_update into ctf_serialize and
allowed all operations on dynamic containers: ctf_type_reference of
slices.  A dynamic slice's vlen state is stored in the dtu_slice member,
so fetch it from there.

libctf/
* ctf-types.c (ctf_type_reference): Add support for dynamic slices.

libctf/ChangeLog
libctf/ctf-types.c

index 598b93a0117fa4c4fba0e05730d876384137f405..8dd6651e07a79726229edec17182124822c9a431 100644 (file)
@@ -1,3 +1,7 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-types.c (ctf_type_reference): Add support for dynamic slices.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-create.c (ctf_serialize): Add cast.
index 35253cb3cbc4d802c3c66e702e5120cacea871e2..9c10905ea11aca624dcdd2acce5cbb6844917dc1 100644 (file)
@@ -680,10 +680,19 @@ ctf_type_reference (ctf_file_t *fp, ctf_id_t type)
       /* Slices store their type in an unusual place.  */
     case CTF_K_SLICE:
       {
+       ctf_dtdef_t *dtd;
        const ctf_slice_t *sp;
-       ssize_t increment;
-       (void) ctf_get_ctt_size (fp, tp, NULL, &increment);
-       sp = (const ctf_slice_t *) ((uintptr_t) tp + increment);
+
+       if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
+         {
+           ssize_t increment;
+
+           (void) ctf_get_ctt_size (fp, tp, NULL, &increment);
+           sp = (const ctf_slice_t *) ((uintptr_t) tp + increment);
+         }
+       else
+         sp = &dtd->dtd_u.dtu_slice;
+
        return sp->cts_type;
       }
     default: