[v2] ctf-reader: Add support to undefined forward declaration types
Commit Message
This is the patch v2 intended to fix undefined forward declarations
in ctf reader back-end.
Changes from v1 is update tests/data/Makefile.am to include test
input/expected files.
Comments will be appreciated.
Kind Regards,
Guillermo
Undefined struct/union forward declaration types are not serialized in
abixml representation using `class-decl' node.
For instance, consider:
struct key_type;
typedef void (*key_restrict_link_func_t)(struct key_type *type);
Expected node:
<class-decl name='key_type' ... is-declaration-only='yes'.../>
* src/abg-ctf-reader.cc (process_ctf_forward_type): New
function.
(process_ctf_type): New CTF_K_FORWARD case.
* tests/data/test-read-ctf/test-forward-undefine-type-decl.c:
New testcase.
* tests/data/test-read-ctf/test-forward-undefine-type-decl.abi:
New expected result.
* tests/data/test-read-ctf/test-forward-undefine-type-decl.o
New test input.
* tests/test-read-ctf.cc: Add new testcase to test harness.
* tests/data/Makefile.am: Add new test input files to test harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
src/abg-ctf-reader.cc | 53 ++++++++++++++++++
tests/data/Makefile.am | 3 +
.../test-forward-undefine-type-decl.abi | 31 ++++++++++
.../test-forward-undefine-type-decl.c | 17 ++++++
.../test-forward-undefine-type-decl.o | Bin 0 -> 1488 bytes
tests/test-read-ctf.cc | 8 +++
6 files changed, 112 insertions(+)
create mode 100644 tests/data/test-read-ctf/test-forward-undefine-type-decl.abi
create mode 100644 tests/data/test-read-ctf/test-forward-undefine-type-decl.c
create mode 100644 tests/data/test-read-ctf/test-forward-undefine-type-decl.o
Comments
Hello,
Any comment about this patch?
Thanks,
Guillermo
On Thursday, March 17, 2022 7:30:36 PM CST Guillermo E. Martinez wrote:
> This is the patch v2 intended to fix undefined forward declarations
> in ctf reader back-end.
>
> Changes from v1 is update tests/data/Makefile.am to include test
> input/expected files.
>
> Comments will be appreciated.
>
> Kind Regards,
> Guillermo
>
> Undefined struct/union forward declaration types are not serialized in
> abixml representation using `class-decl' node.
>
> For instance, consider:
>
> struct key_type;
> typedef void (*key_restrict_link_func_t)(struct key_type *type);
> [...]
Hello libabigail team,
Any comment about this patch?
Thanks,
Guillermo
On Thursday, March 31, 2022 3:12:38 PM CDT Guillermo Martinez via Libabigail
wrote:
> Hello,
>
> Any comment about this patch?
>
> Thanks,
> Guillermo
>
> On Thursday, March 17, 2022 7:30:36 PM CST Guillermo E. Martinez wrote:
> > This is the patch v2 intended to fix undefined forward declarations
> > in ctf reader back-end.
> >
> > Changes from v1 is update tests/data/Makefile.am to include test
> > input/expected files.
> >
> > Comments will be appreciated.
> >
> > Kind Regards,
> > Guillermo
> >
> > Undefined struct/union forward declaration types are not serialized in
> > abixml representation using `class-decl' node.
> >
> > For instance, consider:
> > struct key_type;
> > typedef void (*key_restrict_link_func_t)(struct key_type *type);
> >
> > [...]
On Thursday, March 17, 2022 7:30:36 PM CDT Guillermo E. Martinez wrote:
Hello libabigail team,
Any comment about this patch?
Thanks,
Guillermo
> Undefined struct/union forward declaration types are not serialized in
> abixml representation using `class-decl' node.
>
> For instance, consider:
>
> struct key_type;
> typedef void (*key_restrict_link_func_t)(struct key_type *type);
>
> Expected node:
>
> [..]
I’ve seen several internal emails from Dodji suggesting that he’s aware of the growing patch queue. I have a couple of patches pending myself. I believe right now he’s really trying to land the fixes branch but before he does that, he needs to fix the 37 or so regressions that I reported to him with that branch. I think that kind of derailed his plans to merge the fixes branch, run through the patch queue, and then release 2.1. I don’t think he’s ignoring you, it is just I through a spanner in the works.
-ben
> On Apr 25, 2022, at 11:37 AM, Guillermo E. Martinez via Libabigail <libabigail@sourceware.org> wrote:
>
> On Thursday, March 17, 2022 7:30:36 PM CDT Guillermo E. Martinez wrote:
> Hello libabigail team,
>
> Any comment about this patch?
>
> Thanks,
> Guillermo
>
>> Undefined struct/union forward declaration types are not serialized in
>> abixml representation using `class-decl' node.
>>
>> For instance, consider:
>>
>> struct key_type;
>> typedef void (*key_restrict_link_func_t)(struct key_type *type);
>>
>> Expected node:
>>
>> [..]
>
>
On Monday, April 25, 2022 2:45:45 PM CDT Ben Woodard wrote:
Ok, thanks Ben,
> I’ve seen several internal emails from Dodji suggesting that he’s aware of the growing patch queue. I have a couple of patches pending myself. I believe right now he’s really trying to land the fixes branch but before he does that, he needs to fix the 37 or so regressions that I reported to him with that branch. I think that kind of derailed his plans to merge the fixes branch, run through the patch queue, and then release 2.1. I don’t think he’s ignoring you, it is just I through a spanner in the works.
>
> -ben
> [...]
Guillermo
Hello,
"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
écrit:
[...]
> +static type_base_sptr
> +process_ctf_forward_type(read_context *ctxt,
> + corpus_sptr corp,
> + translation_unit_sptr tunit,
> + ctf_dict_t *ctf_dictionary,
> + ctf_id_t ctf_type)
This function lacks a doxgen comment. I have added it.
Also, the 'corp' parameter is not used in the body of the function. So
I have removed it.
[...]
> /// Build and return a struct type libabigail IR.
> ///
> /// @param ctxt the read context.
> @@ -813,6 +860,12 @@ process_ctf_type(read_context *ctxt,
> result = is_type(struct_decl);
> break;
> }
> + case CTF_K_FORWARD:
> + {
> + result = process_ctf_forward_type(ctxt, corp, tunit, ctf_dictionary,
> + ctf_type);
I have updated this call to remove the "corp" parameter as it's not
there anymore.
> + }
> + break;
> case CTF_K_UNION:
> {
[...]
> * src/abg-ctf-reader.cc (process_ctf_forward_type): New
> function.
> (process_ctf_type): New CTF_K_FORWARD case.
> * tests/data/test-read-ctf/test-forward-undefine-type-decl.c:
> New testcase.
> * tests/data/test-read-ctf/test-forward-undefine-type-decl.abi:
> New expected result.
> * tests/data/test-read-ctf/test-forward-undefine-type-decl.o
> New test input.
> * tests/test-read-ctf.cc: Add new testcase to test harness.
> * tests/data/Makefile.am: Add new test input files to test harness.
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Applying this to master, thanks!
Cheers,
On Friday, April 29, 2022 5:57:27 AM CDT Dodji Seketeli wrote:
> Hello,
Hello Dodji,
> "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
> écrit:
>
> [...]
>
> > +static type_base_sptr
> > +process_ctf_forward_type(read_context *ctxt,
> > + corpus_sptr corp,
> > + translation_unit_sptr tunit,
> > + ctf_dict_t *ctf_dictionary,
> > + ctf_id_t ctf_type)
>
> This function lacks a doxgen comment. I have added it.
Thanks
> Also, the 'corp' parameter is not used in the body of the function. So
> I have removed it.
great
> [...]
>
> > /// Build and return a struct type libabigail IR.
> > ///
> > /// @param ctxt the read context.
> > @@ -813,6 +860,12 @@ process_ctf_type(read_context *ctxt,
> > result = is_type(struct_decl);
> > break;
> > }
> > + case CTF_K_FORWARD:
> > + {
> > + result = process_ctf_forward_type(ctxt, corp, tunit, ctf_dictionary,
> > + ctf_type);
>
> I have updated this call to remove the "corp" parameter as it's not
> there anymore.
> > + }
> > + break;
> > case CTF_K_UNION:
> > {
>
> [...]
>
> > * src/abg-ctf-reader.cc (process_ctf_forward_type): New
> > function.
> > (process_ctf_type): New CTF_K_FORWARD case.
> > * tests/data/test-read-ctf/test-forward-undefine-type-decl.c:
> > New testcase.
> > * tests/data/test-read-ctf/test-forward-undefine-type-decl.abi:
> > New expected result.
> > * tests/data/test-read-ctf/test-forward-undefine-type-decl.o
> > New test input.
> > * tests/test-read-ctf.cc: Add new testcase to test harness.
> > * tests/data/Makefile.am: Add new test input files to test harness.
> >
> > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
>
> Applying this to master, thanks!
Thanks!! :-)
> Cheers,
guillermo
@@ -384,6 +384,53 @@ process_ctf_sou_members(read_context *ctxt,
fprintf(stderr, "ERROR from ctf_member_next\n");
}
+static type_base_sptr
+process_ctf_forward_type(read_context *ctxt,
+ corpus_sptr corp,
+ translation_unit_sptr tunit,
+ ctf_dict_t *ctf_dictionary,
+ ctf_id_t ctf_type)
+{
+ decl_base_sptr result;
+ std::string type_name = ctf_type_name_raw(ctf_dictionary,
+ ctf_type);
+ bool type_is_anonymous = (type_name == "");
+ uint32_t kind = ctf_type_kind_forwarded (ctf_dictionary, ctf_type);
+
+ if (kind == CTF_K_UNION)
+ {
+ union_decl_sptr
+ union_fwd(new union_decl(ctxt->ir_env,
+ type_name,
+ /*alignment=*/0,
+ location(),
+ decl_base::VISIBILITY_DEFAULT,
+ type_is_anonymous));
+ union_fwd->set_is_declaration_only(true);
+ result = union_fwd;
+ }
+ else
+ {
+ class_decl_sptr
+ struct_fwd(new class_decl(ctxt->ir_env, type_name,
+ /*alignment=*/0, /*size=*/0,
+ true /* is_struct */,
+ location(),
+ decl_base::VISIBILITY_DEFAULT,
+ type_is_anonymous));
+ struct_fwd->set_is_declaration_only(true);
+ result = struct_fwd;
+ }
+
+ if (!result)
+ return is_type(result);
+
+ add_decl_to_scope(result, tunit->get_global_scope());
+ ctxt->add_type(ctf_type, is_type(result));
+
+ return is_type(result);
+}
+
/// Build and return a struct type libabigail IR.
///
/// @param ctxt the read context.
@@ -813,6 +860,12 @@ process_ctf_type(read_context *ctxt,
result = is_type(struct_decl);
break;
}
+ case CTF_K_FORWARD:
+ {
+ result = process_ctf_forward_type(ctxt, corp, tunit, ctf_dictionary,
+ ctf_type);
+ }
+ break;
case CTF_K_UNION:
{
union_decl_sptr union_decl
@@ -660,6 +660,9 @@ test-read-ctf/test-functions-declaration.o \
test-read-ctf/test-forward-type-decl.abi \
test-read-ctf/test-forward-type-decl.o \
test-read-ctf/test-forward-type-decl.c \
+test-read-ctf/test-forward-undefine-type-decl.abi \
+test-read-ctf/test-forward-undefine-type-decl.c \
+test-read-ctf/test-forward-undefine-type-decl.o \
test-read-ctf/test-list-struct.c \
test-read-ctf/test-list-struct.o \
test-read-ctf/test-list-struct.abi \
new file mode 100644
@@ -0,0 +1,31 @@
+<abi-corpus version='2.1' path='data/test-read-ctf/test-forward-undefine-type-decl.o'>
+ <elf-variable-symbols>
+ <elf-symbol name='k' size='24' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ </elf-variable-symbols>
+ <abi-instr address-size='64' language='LANG_C'>
+ <class-decl name='key_restriction' size-in-bits='192' alignment-in-bits='64' is-struct='yes' visibility='default' id='type-id-1'>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <var-decl name='check' type-id='type-id-2' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='64'>
+ <var-decl name='keytype' type-id='type-id-3' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='128'>
+ <var-decl name='keyutype' type-id='type-id-4' visibility='default'/>
+ </data-member>
+ </class-decl>
+ <typedef-decl name='key_restrict_link_func_t' type-id='type-id-5' id='type-id-2'/>
+ <pointer-type-def type-id='type-id-6' size-in-bits='64' alignment-in-bits='64' id='type-id-3'/>
+ <pointer-type-def type-id='type-id-7' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/>
+ <pointer-type-def type-id='type-id-8' size-in-bits='64' alignment-in-bits='64' id='type-id-5'/>
+ <class-decl name='key_type' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-6'/>
+ <var-decl name='k' type-id='type-id-1' mangled-name='k' visibility='default'/>
+ <function-type size-in-bits='64' alignment-in-bits='8' id='type-id-8'>
+ <parameter type-id='type-id-3'/>
+ <parameter type-id='type-id-4'/>
+ <return type-id='type-id-9'/>
+ </function-type>
+ <union-decl name='key_utype' visibility='default' is-declaration-only='yes' id='type-id-7'/>
+ <type-decl name='void' id='type-id-9'/>
+ </abi-instr>
+</abi-corpus>
new file mode 100644
@@ -0,0 +1,17 @@
+/* Test undefined forward declarations
+ * gcc -gctf -c test-forward-undefine-type-decl.c -o \
+ * test-forward-undefine-type-decl.o
+ */
+
+struct key_type;
+union key_utype;
+typedef void (*key_restrict_link_func_t)(struct key_type *type,
+ union key_utype *utype);
+
+struct key_restriction {
+ key_restrict_link_func_t check;
+ struct key_type *keytype;
+ union key_utype *keyutype;
+};
+
+struct key_restriction k;
new file mode 100644
GIT binary patch
literal 1488
zcmbtUOK#La5G@bk8!1dSh|k6d5fZ@m%q+7&77+v?gxIh^2#x&d$ynph$ZkWtf+fe`
z0C0!g1g-!VfO>X!#_9=dD5<)tUe)VQwc8(`ym&gWEYf1pBU(ioB^sVv`F`vAv`JU!
z*Y}Nq&b-wQ+YP0c*g}V_Us+FBFSEW;3SX^vfn7)&@}$?`U>+n?az__2w1q8QWo6m9
z*jbEQ=X*XjccY8%qh`X&yqnkAKJM^#f6v(WS+U+L)=#YMTJMV_riEyxvRR7OsZYI9
zRI*GWIZcy%F`d<UG?i_MP9#N6(Og6epqi%m<jsprcwrMZUQq^7D!i(Uyfg`eFgXg6
z)Tx&|y$CW-@;a3l2Qp|~hr!s1<gANkMfo8pW2eqzF-vmcU?C?KQR+rShX)7y_U_@!
z*L(JO;*Q*rJsC~LV^(`t94|$gWFnVAy2l4*!TD`g^pHt3AnOE}7E8tI&NRGcySw}O
z+f3YHU>i4}1ozMi&glH}C<`LDYBCvwY-QQmx%Q+umgJ&G<c3v6F87CrBE#{>%?l}9
zK9Ez%fUl#AkMi1GmIXIKHhLfbX>TzfXYYNd?Tmgqt`BA(Z*vK-Rfjr`-<h@1<lo~8
zytlvcPy4NA!n^FtLk`S2k@qpMd@+(nNMo)6HbQYveyG9+Jq)hqYrEgW`lXwA$Y+S=
z>C|&}@XpQhp#sc(p;vvud?pupUxD~fK=9uJr1`q9z|Gz>M4uJ^E`pwz``_l=S^RH`
L|E|Y{Yx4g9(}I;l
literal 0
HcmV?d00001
@@ -268,6 +268,14 @@ static InOutSpec in_out_specs[] =
"data/test-read-ctf/test-callback2.abi",
"output/test-read-ctf/test-callback2.abi",
},
+ {
+ "data/test-read-ctf/test-forward-undefine-type-decl.o",
+ "",
+ "",
+ SEQUENCE_TYPE_ID_STYLE,
+ "data/test-read-ctf/test-forward-undefine-type-decl.abi",
+ "output/test-read-ctf/test-forward-undefine-type-decl.abi",
+ },
// This should be the last entry.
{NULL, NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL}
};