[Bug default/26672] detection of changes to an abstract base class

dodji at redhat dot com sourceware-bugzilla@sourceware.org
Tue Sep 29 09:59:19 GMT 2020


https://sourceware.org/bugzilla/show_bug.cgi?id=26672

--- Comment #3 from dodji at redhat dot com ---
"jiyong at google dot com" <sourceware-bugzilla@sourceware.org> writes:

> https://sourceware.org/bugzilla/show_bug.cgi?id=26672
>
> --- Comment #2 from jiyong at google dot com ---
>>  I am genuiously curious to know how the code in its whole is supposed to
> work
>
> The abstract class `MyCallback` is expected to be implemented by a client, not
> by the library that is implementing `MyClass`.

Ahh, okay, I see.

So, maybe in that case, you might want to try to use the GCC option
-femit-class-debug-always.

The problem with that option is that it duplicates debug info for
classes, making the whole thing potentially much bigger.

Otherwise, the debug info for a vtable would be emitted only in files
where the virtual method are emitted.  Look for "key method" at
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Vague-Linkage.html#Vague-Linkage
to understand the details.

Here is what I am getting with -femit-class-debug-always:

$ cat v0.cc
class MyCallback {
public:
  virtual void event1() = 0;
  virtual void event2() = 0;
};

class MyClass {
public:
  void doSomething() {cb->event1(); cb->event2();}
  void registerCallback(MyCallback* cb) {this->cb = cb;}
private:
  MyCallback* cb;
};

static MyClass a;

void
foo(MyClass&)
{
}
dodji@ayevide:PR26672$ cat v1.cc
class MyCallback {
public:
  virtual void event1() = 0;
  virtual void event2() = 0;
  virtual void event3() = 0; // added
};

class MyClass {
public:
  void doSomething() {cb->event1(); cb->event2(); cb->event3();}
  void registerCallback(MyCallback* cb) {this->cb = cb;}
private:
  MyCallback* cb;
};

static MyClass a;

void
foo(MyClass&)
{
}
$ 
$ 
$ g++ -g -femit-class-debug-always -c v0.cc
$ g++ -g -femit-class-debug-always -c v1.cc
$ 
$ 
$ abidiff v0.o v1.o
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'function void foo(MyClass&)' at v1.cc:19:1 has some indirect sub-type
changes:
    parameter 1 of type 'MyClass&' has sub-type changes:
      in referenced type 'class MyClass' at v1.cc:8:1:
        type size hasn't changed
        1 data member change:
          type of 'MyCallback* MyClass::cb' changed:
            in pointed to type 'class MyCallback' at v1.cc:1:1:
              type size hasn't changed
              1 member function insertion:
                'method virtual void MyCallback::event3()' at v1.cc:5:1,
virtual at voffset 2/2

$ 

Would that help you?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Libabigail mailing list