You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
abstract methods are not excluded (since Delphi 2010) #3
This is the result of the enhanced RTTI information emitted into the binary and thus the linker keeping this method in.
There in fact exists code for every abstract method: a jump to System._AbstractError.
The proof is this code:
var
proc: procedure(obj: TObject);
begin
proc := @TClassA.Method;
proc(nil);
If you now place a breakpoint into the line that is being marked blue in your reports you will noticed that it calls that and then jumps to the _AbstractError proc.
Now because since Delphi 2010 enhanced RTTI is enabled for all public methods the linker does not remove this method body which is not being called otherwise. When doing a virtual call to that method it directly goes to _AbstractError as the compiler has its address put into every VMT slot that is abstract for that class - you can see that with this code:
with TClassA.Create do
try
Method; // put breakpoint here and step into (with debug dcus enabled you will end up in System._AbstractError
finally
Free;
end;
Something was changed in
.mapfile format since Delphi 2010 and CodeCoverage32 threatabstractmethods as executed non-covered code.Project settings
Linking / Map file:
DetailedCommand Line (32-bit)
CodeCoverage32 -e Project.exe -m Project.map -u SampleUnit -od Coverage -htmlCommand Line (64-bit)
CodeCoverage64 -e Project.exe -m Project.map -u SampleUnit -od Coverage -htmlMinimal code to reproduce
Project.dpr
SampleUnit.pas
Coverage Report
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit
32-bit
64-bit