jimingham wrote:

> > This is an oft-requested feature so thanks for doing this!
> > My only real complaint is that the code that determines the C++ "dynamic 
> > type" does much of the work that the ValueObjectVTable has to do to find 
> > the vtable pointer, and it's enough code that it seems a shame to have two 
> > copies of it. Maybe there should be a LanguageRuntime "GetVTablePointer" 
> > that factors out the part of GetDynamicTypeAndAddress that finds the 
> > VTable. Then you can get the LanguageRuntime from the Object and call this 
> > generic API. That would also make it clear that this support is for the 
> > ItaniamuABI C++ runtime, so that if another runtime comes along that does 
> > some other clever thing, it will be straightforward to support it.
> 
> I mention this in my inline comments, but we don't want to detect the dynamic 
> type here, we just want to use what ever vtable pointer we find in the 
> current ValueObject that we use to ask for the vtable. We might have dynamic 
> typing on or off, and we don't want to adjust the pointer at all. If we have 
> dynamic typing off, then we will just be in the middle of someone else's 
> vtable, which we will locate by finding the symbol that contains it, so that 
> is ok. If we have dynamic typing on, then the value we ask for the vtable for 
> will point to the first vtable entry for the modified type. So there is no 
> complexity here like there is in the GetDynamicTypeAndAddress(). We just read 
> a pointer and look for the vtable symbol.

I don't think this is how it works.  If you have your hands on a C++ object, 
even when viewed as a subclass or even one of the more complex 
multi-inheritance base class, and you find it's vtable pointer, it will point 
to the vtable of the most specific class.  That's actually how we figure out 
what the dynamic type is, and that's true in the object, that's not something 
lldb makes up.  So in all cases, the first step is to get the vtable.

The additional complexity in GetDynamicValueAndType is all AFTER we've found 
the dynamic class, where we peer further into the runtime to determine the 
"offset to top".  But you don't need to do any of that to get the dynamic 
class, you just get the vtable & demangle its name...  So I am pretty sure the 
"get the vtable" part is going to be identical between your code and the 
GetDynamicValueAndType, and you can factor that bit out and share it between 
GetDynamicValueAndType and your Update.



https://github.com/llvm/llvm-project/pull/67599
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to