aboutsummaryrefslogtreecommitdiff
path: root/libctf/testsuite
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-03-18 12:37:52 +0000
committerNick Alcock <nick.alcock@oracle.com>2021-03-18 12:40:40 +0000
commit08c428aff4a793b63c7dd2229ae172879623e3a2 (patch)
treed6c1e1a4945afb465889f9ff8d0337b548c6e111 /libctf/testsuite
parent77d724a7ecdb3fa84557b0ee5c8b7ea949ce56a5 (diff)
downloadgdb-08c428aff4a793b63c7dd2229ae172879623e3a2.zip
gdb-08c428aff4a793b63c7dd2229ae172879623e3a2.tar.gz
gdb-08c428aff4a793b63c7dd2229ae172879623e3a2.tar.bz2
libctf: eliminate dtd_u, part 5: structs / unions
Eliminate the dynamic member storage for structs and unions as we have for other dynamic types. This is much like the previous enum elimination, except that structs and unions are the only types for which a full-sized ctf_type_t might be needed. Up to now, this decision has been made in the individual ctf_add_{struct,union}_sized functions and duplicated in ctf_add_member_offset. The vlen machinery lets us simplify this, always allocating a ctf_lmember_t and setting the dtd_data's ctt_size to CTF_LSIZE_SENT: we figure out whether this is really justified and (almost always) repack things down into a ctf_stype_t at ctf_serialize time. This allows us to eliminate the dynamic member paths from the iterators and query functions in ctf-types.c in favour of always using the large-structure vlen stuff for dynamic types (the diff is ugly but that's just because of the volume of reindentation this calls for). This also means the large-structure vlen stuff gets more heavily tested, which is nice because it was an almost totally unused code path before now (it only kicked in for structures of size >4GiB, and how often do you see those?) The only extra complexity here is ctf_add_type. Back in the days of the nondeduplicating linker this was called a ridiculous number of times for countless identical copies of structures: eschewing the repeated lookups of the dtd in ctf_add_member_offset and adding the members directly saved an amazing amount of time. Now the nondeduplicating linker is gone, this is extreme overoptimization: we can rip out the direct addition and use ctf_member_next and ctf_add_member_offset, just like ctf_dedup_emit does. We augment a ctf_add_type test to try adding a self-referential struct, the only thing the ctf_add_type part of this change really perturbs. This completes the elimination of dtd_u. libctf/ChangeLog 2021-03-18 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h (ctf_dtdef_t) <dtu_members>: Remove. <dtd_u>: Likewise. (ctf_dmdef_t): Remove. (struct ctf_next) <u.ctn_dmd>: Remove. * ctf-create.c (INITIAL_VLEN): New, more-or-less arbitrary initial vlen size. (ctf_add_enum): Use it. (ctf_dtd_delete): Do not free the (removed) dmd; remove string refs from the vlen on struct deletion. (ctf_add_struct_sized): Populate the vlen: do it by hand if promoting forwards. Always populate the full-size lsizehi/lsizelo members. (ctf_add_union_sized): Likewise. (ctf_add_member_offset): Set up the vlen rather than the dmd. Expand it as needed, repointing string refs via ctf_str_move_pending. Add the member names as pending strings. Always populate the full-size lsizehi/lsizelo members. (membadd): Remove, folding back into... (ctf_add_type_internal): ... here, adding via an ordinary ctf_add_struct_sized and _next iteration rather than doing everything by hand. * ctf-serialize.c (ctf_copy_smembers): Remove this... (ctf_copy_lmembers): ... and this... (ctf_emit_type_sect): ... folding into here. Figure out if a ctf_stype_t is needed here, not in ctf_add_*_sized. (ctf_type_sect_size): Figure out the ctf_stype_t stuff the same way here. * ctf-types.c (ctf_member_next): Remove the dmd path and always use the vlen. Force large-structure usage for dynamic types. (ctf_type_align): Likewise. (ctf_member_info): Likewise. (ctf_type_rvisit): Likewise. * testsuite/libctf-regression/type-add-unnamed-struct-ctf.c: Add a self-referential type to this test. * testsuite/libctf-regression/type-add-unnamed-struct.c: Adjusted accordingly. * testsuite/libctf-regression/type-add-unnamed-struct.lk: Likewise.
Diffstat (limited to 'libctf/testsuite')
-rw-r--r--libctf/testsuite/libctf-regression/type-add-unnamed-struct-ctf.c1
-rw-r--r--libctf/testsuite/libctf-regression/type-add-unnamed-struct.c2
-rw-r--r--libctf/testsuite/libctf-regression/type-add-unnamed-struct.lk1
3 files changed, 3 insertions, 1 deletions
diff --git a/libctf/testsuite/libctf-regression/type-add-unnamed-struct-ctf.c b/libctf/testsuite/libctf-regression/type-add-unnamed-struct-ctf.c
index d319aaf..a1573a7 100644
--- a/libctf/testsuite/libctf-regression/type-add-unnamed-struct-ctf.c
+++ b/libctf/testsuite/libctf-regression/type-add-unnamed-struct-ctf.c
@@ -12,6 +12,7 @@ struct foo
struct
{
int baz;
+ struct foo *foo;
};
};
};
diff --git a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
index 43c3934..16ff094 100644
--- a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
+++ b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
@@ -13,7 +13,7 @@ main (int argc, char *argv[])
ctf_id_t newtype;
const char *memb;
ctf_membinfo_t mi;
- const char *membs[] = { "bar", "baz", NULL };
+ const char *membs[] = { "bar", "baz", "foo", NULL };
const char **walk;
int err;
diff --git a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.lk b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.lk
index caa8934..b818a24 100644
--- a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.lk
+++ b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.lk
@@ -1,3 +1,4 @@
# source: type-add-unnamed-struct-ctf.c
Looked up bar, type [0-9a-f]*, offset [0-9a-f]*
Looked up baz, type [0-9a-f]*, offset [0-9a-f]*
+Looked up foo, type [0-9a-f]*, offset [0-9a-f]*