public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: Dodji Seketeli <dodji@seketeli.org>
Cc: libabigail@sourceware.org, kernel-team@android.com,
	"Matthias Männich" <maennich@google.com>
Subject: Re: [PATCH 4/7] abidiff: Remove member function diff blank lines.
Date: Mon, 30 Mar 2020 14:50:44 +0000	[thread overview]
Message-ID: <CAGvU0HnA07MT2=E+he+KwNdiv9fU19YK=oOV=5AZuC=q19aGBg@mail.gmail.com> (raw)
In-Reply-To: <87bloeq6b9.fsf@seketeli.org>

Hi.

On Mon, 30 Mar 2020 at 15:13, Dodji Seketeli <dodji@seketeli.org> wrote:
>
> Giuliano Procida <gprocida@google.com> a écrit:
>
> > Currently, lists of member function deletions, additions and changes
> > are each followed by a blank line in abidiff output.
> >
> > While this formatting works reasonably well in leaf-changes-only mode
> > for top-level changes to types, it is inconsistent with everthing
> > else. In particular, when reporting member function diffs in default
> > mode, or more deeply nested in leaf mode, the blank lines are
> > jarring.
> >
> > There was also no test coverage for leaf-changes-only mode.
> >
> > This change removes these blank lines and associated state variables
> > and logic. It adds a test case for leaf-changes-only mode.
> >
> > Note that the patch also modifies default mode reporting of member
> > types, template member functions and template member classes
> > analogously, but I wasn't able to exercise those code paths.
>
> The template handling code can be ignored for now.  I initially started
> to work on it but it needed huge adaptations on the compiler side to
> have it emit debug info for non-instantiated templates.  I eventually
> gave up on doing that because of more pressing matters.  So until we
> have a compiler that emits debug information for non instantiated
> templates, I don't think that code will be exercised.

Good to know. It's worth adding some comments to the code to this
effect, so I'll do this.

> [...]
>
>
> > diff --git a/tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc b/tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc
> > new file mode 100644
> > index 00000000..0437584e
> > --- /dev/null
> > +++ b/tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc
> > @@ -0,0 +1,14 @@
> > +struct ops {
> > +  // TODO: type, name and size are differnent from deleted_var, but this is
> > +  // still reported as a change rather than a deletion and an addition.
> > +  long added_var;
> > +  virtual long added_fn() { return 0; }
>
> This is by design.  If a member variable S::foo_member at a given
> offset/ is replaced by another variable S::bar_member (foo_member and
> bar_member have the same offset), we chose to detect that foo_member was
> renamed into bar_member.
>
> So I think we can remove that TODO above.
>
> Would you agree?

I think the TODO has served its purpose which was to attract attention
(now or in the future). I'll remove it.

As to whether I agree... It was a little surprising. I think in most
large structs, if there are changes, the thing I'd mostly to discount
is offset, or perhaps name, next size (for arrays and perhaps integer
types on little endian architectures - but that is very risky) and
finally types. This doesn't really answer the question.

I think my mental model of comparing structs would be: list all the
names in offset order, compute a minimal edit based on names. Pair up
names that have been both removed and added and reclassify them as
moves (note that there may be more than one solution A,B -> B,A could
be A moving or B moving). Finally, perhaps, look at all (remaining)
possible matching removed/added pairs at the same position and see if
the type (including size) remains the same and reclassify these as
renames (this is also ambiguous and is more likely to be misleading
(bool flag1, bool flag2, -> bool flag3)).

If your structs correspond to network (wire) or hardware (DMA) data
structures, you're going to care about offsets an awful lot more.

Here are a couple more worth thinking about:

struct {
  char padding1[16];
  long foo;
  char padding2[8];
};

struct {
  char padding1[8];
  // did foo move and get renamed?
  long bar;
  char padding2[16];
};

and

struct {
  bool flag1;
  bool flag2;
};

struct {
  // flag1 deleted or flag1 renamed and flag2 deleted?
  bool flag2;
};

I'm happy for the code to be working as intended.

Regards.
Giuliano.

> Cheers,
>
> --
>                 Dodji
>
> --
> To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.
>

  reply	other threads:[~2020-03-30 14:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 14:00 [PATCH 0/7] Mostly whitespace changes and fixes Giuliano Procida
2020-03-27 14:00 ` [PATCH 1/7] abidiff: Clean up new lines between sections Giuliano Procida
2020-03-27 14:00 ` [PATCH 2/7] abidiff: Remove blank line after base class diffs Giuliano Procida
2020-03-27 14:00 ` [PATCH 3/7] abidiff: Fix enum impacted interfaces blank line Giuliano Procida
2020-03-27 14:00 ` [PATCH 4/7] abidiff: Remove member function diff blank lines Giuliano Procida
2020-03-30 14:13   ` Dodji Seketeli
2020-03-30 14:50     ` Giuliano Procida [this message]
2020-03-30 15:22       ` Dodji Seketeli
2020-03-27 14:00 ` [PATCH 5/7] abidiff: Fix variable declaration formatting Giuliano Procida
2020-03-27 14:00 ` [PATCH 6/7] abidiff: Eliminate leaf mode double blank lines Giuliano Procida
2020-03-27 14:00 ` [PATCH 7/7] abidiff: Remove new lines after parameter diffs Giuliano Procida
2020-03-29 17:29 ` [PATCH 0/7] Mostly whitespace changes and fixes Matthias Maennich
2020-03-31 10:37 ` Dodji Seketeli

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='CAGvU0HnA07MT2=E+he+KwNdiv9fU19YK=oOV=5AZuC=q19aGBg@mail.gmail.com' \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.com \
    /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).