mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
77d724a7ec
This is the first tricky one, the first complex multi-entry vlen containing strings. To handle this in vlen form, we have to handle pending refs moving around on realloc. We grow vlen regions using a new ctf_grow_vlen function, and iterate through the existing enums every time a grow happens, telling the string machinery the distance between the old and new vlen region and letting it adjust the pending refs accordingly. (This avoids traversing all outstanding refs to find the refs that need adjusting, at the cost of having to traverse one enum: an obvious major performance win.) Addition of enums themselves (and also structs/unions later) is a bit trickier than earlier forms, because the type might be being promoted from a forward, and forwards have no vlen: so we have to spot that and create it if needed. Serialization of enums simplifies down to just telling the string machinery about the string refs; all the enum type-lookup code loses all its dynamic member lookup complexity entirely. A new test is added that iterates over (and gets values of) an enum with enough members to force a round of vlen growth. libctf/ChangeLog 2021-03-18 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h (ctf_dtdef_t) <dtd_vlen_alloc>: New. (ctf_str_move_pending): Declare. * ctf-string.c (ctf_str_add_ref_internal): Fix error return. (ctf_str_move_pending): New. * ctf-create.c (ctf_grow_vlen): New. (ctf_dtd_delete): Zero out the vlen_alloc after free. Free the vlen later: iterate over it and free enum name refs first. (ctf_add_generic): Populate dtd_vlen_alloc from vlen. (ctf_add_enum): populate the vlen; do it by hand if promoting forwards. (ctf_add_enumerator): Set up the vlen rather than the dmd. Expand it as needed, repointing string refs via ctf_str_move_pending. Add the enumerand names as pending strings. * ctf-serialize.c (ctf_copy_emembers): Remove. (ctf_emit_type_sect): Copy the vlen into place and ref the strings. * ctf-types.c (ctf_enum_next): The dynamic portion now uses the same code as the non-dynamic. (ctf_enum_name): Likewise. (ctf_enum_value): Likewise. * testsuite/libctf-lookup/enum-many-ctf.c: New test. * testsuite/libctf-lookup/enum-many.lk: New test.
102 lines
2.9 KiB
Plaintext
102 lines
2.9 KiB
Plaintext
# source: enum-many-ctf.c
|
|
# lookup: enum.c
|
|
# link: on
|
|
Enum e enumerand ENUMSAMPLE_1 has value 0
|
|
Enum e enumerand ENUMSAMPLE_2 has value 1
|
|
iter test: IE_0 has value -10
|
|
iter test: IE_1 has value -9
|
|
iter test: IE_2 has value -8
|
|
iter test: IE_3 has value -7
|
|
iter test: IE_4 has value -6
|
|
iter test: IE_5 has value -5
|
|
iter test: IE_6 has value -4
|
|
iter test: IE_7 has value -3
|
|
iter test: IE_8 has value -2
|
|
iter test: IE_9 has value -1
|
|
iter test: IE_A has value 0
|
|
iter test: IE_B has value 1
|
|
iter test: IE_C has value 2
|
|
iter test: IE_D has value 3
|
|
iter test: IE_E has value 4
|
|
iter test: IE_F has value 5
|
|
iter test: IE_10 has value 6
|
|
iter test: IE_11 has value 7
|
|
iter test: IE_12 has value 8
|
|
iter test: IE_13 has value 9
|
|
iter test: IE_14 has value 10
|
|
iter test: IE_15 has value 11
|
|
iter test: IE_16 has value 12
|
|
iter test: IE_17 has value 13
|
|
iter test: IE_18 has value 14
|
|
iter test: IE_19 has value 15
|
|
iter test: IE_1A has value 16
|
|
iter test: IE_1B has value 17
|
|
iter test: IE_1C has value 18
|
|
iter test: IE_1D has value 19
|
|
iter test: IE_1E has value 20
|
|
iter test: IE_1F has value 21
|
|
iter test: IE_20 has value 22
|
|
iter test: IE_21 has value 23
|
|
iter test: IE_22 has value 24
|
|
iter test: IE_23 has value 25
|
|
iter test: IE_24 has value 26
|
|
iter test: IE_25 has value 27
|
|
iter test: IE_26 has value 28
|
|
iter test: IE_27 has value 29
|
|
iter test: IE_28 has value 30
|
|
iter test: IE_29 has value 31
|
|
iter test: IE_2A has value 32
|
|
iter test: IE_2B has value 33
|
|
iter test: IE_2C has value 34
|
|
iter test: IE_2D has value 35
|
|
iter test: IE_2E has value 36
|
|
iter test: IE_2F has value 37
|
|
next test: IE_0 has value -10
|
|
next test: IE_1 has value -9
|
|
next test: IE_2 has value -8
|
|
next test: IE_3 has value -7
|
|
next test: IE_4 has value -6
|
|
next test: IE_5 has value -5
|
|
next test: IE_6 has value -4
|
|
next test: IE_7 has value -3
|
|
next test: IE_8 has value -2
|
|
next test: IE_9 has value -1
|
|
next test: IE_A has value 0
|
|
next test: IE_B has value 1
|
|
next test: IE_C has value 2
|
|
next test: IE_D has value 3
|
|
next test: IE_E has value 4
|
|
next test: IE_F has value 5
|
|
next test: IE_10 has value 6
|
|
next test: IE_11 has value 7
|
|
next test: IE_12 has value 8
|
|
next test: IE_13 has value 9
|
|
next test: IE_14 has value 10
|
|
next test: IE_15 has value 11
|
|
next test: IE_16 has value 12
|
|
next test: IE_17 has value 13
|
|
next test: IE_18 has value 14
|
|
next test: IE_19 has value 15
|
|
next test: IE_1A has value 16
|
|
next test: IE_1B has value 17
|
|
next test: IE_1C has value 18
|
|
next test: IE_1D has value 19
|
|
next test: IE_1E has value 20
|
|
next test: IE_1F has value 21
|
|
next test: IE_20 has value 22
|
|
next test: IE_21 has value 23
|
|
next test: IE_22 has value 24
|
|
next test: IE_23 has value 25
|
|
next test: IE_24 has value 26
|
|
next test: IE_25 has value 27
|
|
next test: IE_26 has value 28
|
|
next test: IE_27 has value 29
|
|
next test: IE_28 has value 30
|
|
next test: IE_29 has value 31
|
|
next test: IE_2A has value 32
|
|
next test: IE_2B has value 33
|
|
next test: IE_2C has value 34
|
|
next test: IE_2D has value 35
|
|
next test: IE_2E has value 36
|
|
next test: IE_2F has value 37
|