[Bug default/26672] detection of changes to an abstract base class
dodji at redhat dot com
sourceware-bugzilla@sourceware.org
Mon Sep 28 16:03:58 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=26672
--- Comment #1 from dodji at redhat dot com ---
Hello,
>From what I understand, this is rather related to showing changes to an
abstract class that contains only pure virtual functions (i.e, a pure
interface class).
yes, GCC doesn't generate any debug info for the pure interface class as
it is. What does LLVM do in that case btw?
I think, though, that if there was a concrete implementation of that
interface (a class deriving from that interface and implementing its
virtual functions) that could be instantiated, then GCC emits debug info
for that implementation, including debug info describing the pure
interface class). In that case, Libabigail should detect the interface
change (addition of a virtual function) on that concrete implementation
of the interface. If there is no such code (instantiating a concrete
implementation of that interface) anywhere in the source code, then I am
genuiously curious to know how the code in its whole is supposed to
work. I mean, surely, something needs to instantiate a concrete
implementation of that interface at some point, right? In any case, by
knowing more about that use case, maybe we can come up with a scheme to
catch the change.
So, here is the change I made to the your example to try to catch the
addition and illustrate what I mean by "concrete implementation of the
interface":
-------------------------------->8<----------------------------------
$ 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;
class Event : public MyCallback
{
void event1() {}
void event2() {}
};
MyCallback*
make_new_callback()
{
MyCallback *result = new Event;
return result;
}
$
$
$ 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;
class Event : public MyCallback
{
void event1() {}
void event2() {}
void event3() {}
};
MyCallback*
make_new_callback()
{
MyCallback *result = new Event;
return result;
}
$
$ g++ -g -c v0.cc
$ g++ -g -c v1.cc
$
$ abidiff v0.o v1.o
Functions changes summary: 0 Removed, 1 Changed, 1 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 Added function:
[A] 'method virtual void Event::event3()' {_ZN5Event6event3Ev}
note that this adds a new entry to the vtable of class Event
1 function with some indirect sub-type change:
[C] 'function MyCallback* make_new_callback()' at v1.cc:26:1 has some
indirect sub-type changes:
return type 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
$
-------------------------------->8<----------------------------------
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Libabigail
mailing list