[fpc-devel] Dwarf3 and the encoding of classes
Joost van der Sluis
joost at cnoc.nl
Sun Jan 9 17:56:30 CET 2011
On Mon, 2011-01-03 at 13:38 +0100, Jonas Maebe wrote:
> On 03 Jan 2011, at 13:29, Joost van der Sluis wrote:
>
> > This has nothing to do with gdb, but with the debug-information that
> > fpc
> > (-gw3) generates. Now it handles classes as if they are not
> > pointers. I
> > think that this is closer to how a class is defined in Pascal. A class
> > is (imho) not a pointer, just like an ansistring is not a pointer.
> > After
> > all, we don't use AnObject^.Destroy....
>
> Delphi also allows skipping the ^ for e.g. pointers to records. A
> difference is that it does not allow using ^ at all for classes, but
> still...
>
> Also, in Delphi (and in FPC's Delphi mode) untyped pointers can be
> automatically converted by the compiler into class types, so they are
> quite close. I don't really see a big advantage in changing the
> encoding of class types in the debug information, especially since
> even now stuff like classinstance.fieldname works.
I've done some more tests with -gw2. 'p classinstance' gives you the
address of the class-instance and not the values within the class.
That's a big issue to me. To show the class, you have to use 'p
classinstance^', which is nonsense in a Pascal-way of view.
And if the classinstance is nil it shows '0x0' and not 'nil'. 'p
@classinstance' will give you rubbish.
Otoh, with gw3, this all works. The patch to show 'nil' when a class is
not assigned for gdb is two lines. And to be honest, I think the 'p
classinstance1=classinstance2' case is a real corner-case. The cases
explained above are more important, imho. (Delphi does allow
class-comparisons in the debugger, but you can't add or substract
anything form a classinstance. With gdb (gw2) you can)
Overall, I think that omitting the implicit-pointer as Dwarf-3 does now,
is the right way to go, so I'll continue with that.
Joost.
More information about the fpc-devel
mailing list