public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Guillermo Martinez <guillermo.e.martinez@oracle.com>
To: Dodji Seketeli <dodji@seketeli.org>
Cc: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org>
Subject: Re: [PATCH v2] Add regression tests for ctf reading
Date: Fri, 26 Nov 2021 13:37:43 +0000	[thread overview]
Message-ID: <2080240.pYWs873MX4@sali> (raw)
In-Reply-To: <87r1b3rwi7.fsf@seketeli.org>

On Friday, November 26, 2021 5:23:28 AM CST Dodji Seketeli wrote:
> Hello,
> 
> [...]
> 
> On Nov 24, 2021, at 8:36 AM, Dodji Seketeli <dodji@seketeli.org> wrote
> 
> >> So where exactly is the CTF test disabled?
> 
> Guillermo Martinez <guillermo.e.martinez@oracle.com> a écrit:
> 
> > I remove those test entries, so the possible problem detected using external diff
> > command in CTF is, for instance, in: test-read-common/test-PR26568-1-ctf.o.abi,
> > the first time that runtestreadctf is executed an abixml file  is generated:
> >
> > ...
> >     <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
> >       <data-member access='public' layout-offset-in-bits='0'>
> >         <var-decl name='x' type-id='type-id-4' visibility='default'/>
> >       </data-member>
> >     </class-decl>
> >     <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-5'>
> >       <data-member access='public' layout-offset-in-bits='0'>
> >         <var-decl name='y' type-id='type-id-6' visibility='default'/>
> >       </data-member>
> >     </class-decl>
> >
> > and this is second execution:
> > ...
> >     <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-5'>
> >       <data-member access='public' layout-offset-in-bits='0'>
> >         <var-decl name='y' type-id='type-id-6' visibility='default'/>
> >       </data-member>
> >     </class-decl>
> >     <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
> >       <data-member access='public' layout-offset-in-bits='0'>
> >         <var-decl name='x' type-id='type-id-4' visibility='default'/>
> >       </data-member>
> >     </class-decl>
> >
> > As we can see both abixml files  have *same nodes information* but the nodes
> > are in a different order, so the test should be marked as passed, however using
> > the external diff command the test fails. so my question is should we rely in diff
> > command to compare the corpus of the ELF input files (abixml files)?
> 
> So, you see here, this is exactly why we use the diff tool IN ADDITION
> to abidiff (which only look for ABI changes).
> 
> Here, you see that two invocations of abidw is yielding possibly two
> *DIFFERENT* abixml files.  They are different because some struct type
> definition come out in different order.
OK, but they represent the same ABI, because the nodes order is not
relevant here .. Is that correct?

> Why?
> 
> This is because we have two struct types that have the same (empty) name
> and yet they are different.  The abixml writer sorts types using their
> names, somehow.  So some times, one type comes first; some times, it's
> the other.
OK.
> Let's look at the issue a bit deeper.
> 
> These are anonymous struct.
> 
> For various reasons, we need to designate types in the Libabigail
> system.  So every single type needs to be given a name.  Even anonymous
> types.
> 
> Most of the time, in C, anonymous types are named using typedefs.  E.g:
> 
> typedef struct
> {
>   int x;
> } struct_name;
> 
> "typedef struct_name" is the 'naming typedef' of the struct type.  It's
> used to name it.  That's how it's designated to be later used.
> 
> The libabigail IR has the decl_base::set_naming_typedef() function to
> set naming typedefs on 
> 
> If you look at the code of the dwarf reader, in the function
> build_typedef_type, near the end, you'll see that it uses the
> set_naming_typedef method to set the naming typedef of the underlying
> anonymous class (or struct) it sees.
> 
> Once you've done that, the struct will be represented in the abixml file
> as having the name "struct_name".  And your problem will be solved, I
> think.
> 
> There are other techniques used in the dwarf-reader to handle anonymous
> types that are not named by a typedef.  But those are super rare,
> especially in C.  So I hope that using naming typedef should be good
> enough for a start, in practise.
> 
> It's precisely to detect cases like this that the "diff" tool is used.
So, is correct mark this test as failed as the current ctf/dwarf test harness does?

I'll isolate the scenario using anonymous types as you explained above :-).
Thanks so much for your hints!!
  
> I hope this helps.
> 
> [...]
> 
> Cheers,


  parent reply	other threads:[~2021-11-26 13:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 22:41 Regression tests for ctf reader: Avoid duplicating files Guillermo Martinez
2021-11-04  8:27 ` Jose E. Marchesi
2021-11-09  2:52   ` Guillermo Martinez
2021-11-09 14:47     ` Dodji Seketeli
2021-11-10 12:06       ` Jose E. Marchesi
2021-11-11 15:16       ` Guillermo Martinez
2021-11-15 13:49 ` [PATCH] Add regression tests for ctf reading Guillermo E. Martinez
2021-11-17  8:33   ` Dodji Seketeli
2021-11-18  4:02     ` Guillermo Martinez
2021-11-18  4:16     ` Guillermo E. Martinez
2021-11-18 13:52       ` Jose E. Marchesi
2021-11-18 15:14         ` Guillermo Martinez
2021-11-22 21:33       ` [PATCH v2] " Guillermo E. Martinez
2021-11-23 15:48         ` Jose E. Marchesi
2021-11-23 18:54           ` Guillermo Martinez
2021-11-25 10:40             ` Dodji Seketeli
2021-11-25 21:03               ` Guillermo Martinez
2021-11-26 10:02                 ` Dodji Seketeli
2021-11-24 16:36         ` Dodji Seketeli
2021-11-24 18:52           ` Guillermo Martinez
2021-11-26 11:23             ` Dodji Seketeli
2021-11-26 13:01               ` Jose E. Marchesi
2021-11-26 13:37               ` Guillermo Martinez [this message]
2021-11-24 19:09           ` Ben Woodard
2021-11-25  0:13             ` Ben Woodard
2021-11-25  6:50             ` Jose E. Marchesi
2021-11-25  9:47               ` Giuliano Procida
2021-12-01  3:18               ` Ben Woodard
2021-11-25  9:34             ` Giuliano Procida
2021-11-25 21:56               ` Ben Woodard
2021-11-26 10:27             ` Dodji Seketeli
2021-12-01  2:13               ` Ben Woodard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2080240.pYWs873MX4@sali \
    --to=guillermo.e.martinez@oracle.com \
    --cc=dodji@seketeli.org \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).