Re: virtual method structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> << In boilerplate $vtbl_ptr_type, what are the fields delta, index,
>> pfn and delta2 used for? >>
>>  
>> So is there somewhere a description of these fields? I would like to
>> get the address of a virtual method of an object (so pObj->vptr->index
>> ->method or something like that).
>
>A virtual table is just a list of function pointers; you can think of
>as a struct whose fields have the type of pointers to functions
>implementing the methods.
>
>Perhaps you are looking at a pointer-to-member?  Or a thunk, which is
>a bit of code used for multiple inheritance?
>
>In this context, "delta" is typically the offset from the start of the
>object to the start of the object from which the method is inherited.
>That is, normally delta == 0, but in cases of multiple inheritance it
>may have a non-zero value.
>
>The "index" field is presumably the index into the virtual table.

Thanks for the information. I don't use multiple inheritance here,
so delta is 0 and index is 8 which is about right (9th entry in vtable).

Maybe I should have given more info about my problem here. I was
specifically looking for the types and limits of these fields. I already
have a working solution to get method pointers and call them, even for
virtual methods. But I have one case where this fails. The problem seems
to be that the offset between object address and virtual table is bigger
than 0x9000. But the delta2 field seems to be a signed short, so it
can't hold this value bigger 0x7FFF. I was now wondering if this is
really a limitation or if I have to compute things differently. That's why
I was looking for a description of these fields.

>Sorry, I don't know what pfn or delta2 are without more context.

pfn should be the address of the normal method, or delta2 should
be the offset to the virtual table. In my case it has a value of -16000,
but that's not the real value, it's also not the limit, it's just some
value I don't know what to do with it.

Thanks

bye  Fabi


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux