[lazarus] RTL bug ?? TObject.FieldAddres

Sebastian Günther sguenther at gmx.de
Fri Jul 7 20:30:09 EDT 2000


Marc Weustink wrote:
> 
> I've to dive some deeper in it. As far as I understand (and I may
> completely wrong) TObject.FieldAddress is called to set a reference to a
> member var of a parent component. THe member var is looked up through the
> name of the component. In most cases (now) name is '' so you dont have to
> look them up.

OK, I will commit a patch tomorrow.


> >Checking objects is simple: When you dump an object in GDB, you should
> >get zero as result when you add the both values of the _vptr record. If
> >this is not the case, then either the object is corrupt or the object
> >pointer passed is wrong.
> 
> Has this a deeper meaning ?? (don't know the exact meaning of _vptr)

Yes: _vptr is the VMT (virtual method table) pointer: Object variables
are just pointer to a piece of memory; the first 4 bytes of this memory
is the VMT pointer. The VMT itself is a list of pointers to the virtual
methods of a specific class, but there are some additional fields.
However, GDB displays two of these special fields, the first one is the
size of a class instance in bytes, and the second one its the complement
of this value, which is used only as a checksum. To check if a VMT is
valid, just add these two values, and check if the result is zero (when
you do a 32 bit addition of course; e.g. $80000000+$80000000 is zero in
32-bit arithmetic)


- Sebastian






More information about the Lazarus mailing list