[Lazarus] Viewing interface object in debugger

Benito van der Zander benito at benibela.de
Fri Oct 19 01:20:40 CEST 2012


> Do you have a small sample app, so I can test? 
Here:

program Project1;

{$mode objfpc}{$H+}

uses classes;

type
ITest = interface
end;
TTest = class(TInterfacedObject, ITest)
   a: integer;
end;

var c : TTest;
     i : ITest;
begin
   c := TTest.Create;
   c.a := 42;
   i := c;
   writeln(c.a);
end.


Evaluating "i" only shows <ITEST> = {
<IUNKNOWN> = {},
   }

but what I want to see is something like it prints for "c" (or both 
together):

<TTEST> = {
<TINTERFACEDOBJECT> = {
<TOBJECT> = {
       _vptr$TOBJECT = $671c10},
     FREFCOUNT = 1,
     REFCOUNT = 1},
   A = 42}


(although I just noticed that ttest((pointer(i)) - 0x20) prints that, 
but is that reliable?
it will probably break if a class implements multiple interfaces)


Benito



On 10/18/2012 04:17 PM, Martin wrote:
> On 18/10/2012 14:23, Benito van der Zander wrote:
>> Hi,
>> is there anyway to view the content of an interfaced object with the
>> Lazarus debugger?
>
> Do you have a small sample app, so I can test?
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




More information about the Lazarus mailing list