Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-25 Thread Jeremy Morse via Dwarf-discuss
Hi all, The LLVM discussion linked [0] happens to be us Sony folks, and it's supporting the use-case Kyle described of automatic downcasting, i.e. identifying the most-derived-class of an object from its vtable pointer. Having to demangle the symbol table is a real pain (Tom, CC'd knows more) espe

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-24 Thread Cary Coutant via Dwarf-discuss
> > Actually, for GCC and LLVM, the location is an *index* into vtable, *not* > an offset. We have a compiler abstraction that knows how to convert the > DWARF DW_AT_vtable_elem_location to our internal representation of a > location, because various compilers generate the DWARF differently and the

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-24 Thread John DelSignore via Dwarf-discuss
On 4/23/25 22:46, Cary Coutant via Dwarf-discuss wrote: Looking at the DWARF generated by GCC (and I'm guessing LLVM does the same), I see vtable_elem_location attributes that look like this: <1b8> DW_AT_vtable_elem_location: 2 byte block: 10 0 (DW_OP_constu: 0) This is not correct DWARF!

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-23 Thread Kyle Huey via Dwarf-discuss
On Wed, Apr 23, 2025 at 7:46 PM Cary Coutant wrote: >> >> The first part of this is straightforward. The DWARF for Base will >> contain a member for the vtable pointer, and that plus knowledge of >> how the ABI lays out vtables allows the debugger to effectively do a >> dynamic_cast to obtain a po

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-23 Thread Cary Coutant via Dwarf-discuss
> > The first part of this is straightforward. The DWARF for Base will > contain a member for the vtable pointer, and that plus knowledge of > how the ABI lays out vtables allows the debugger to effectively do a > dynamic_cast to obtain a pointer to the most derived object. > From there the vtable

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-23 Thread Kyle Huey via Dwarf-discuss
On Wed, Apr 23, 2025 at 8:45 AM Michael Buch wrote: > > Sounds like this is what > https://github.com/llvm/llvm-project/pull/130255 is trying to achieve? Yes, though that may be trying to achieve other things too (there's some discussion of trying to go from the class definition in the DWARF to t

[Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-23 Thread Kyle Huey via Dwarf-discuss
Consider the following C++ program #include class Base { public: virtual const char* method1() = 0; void method2() { printf("%s\n", method1()); } }; class DerivedOne : public Base { virtual const char* method1() override { return "DerivedOne"; } }; template class DerivedTwo :

Re: [Dwarf-discuss] Representing vtables in DWARF for downcasting

2025-04-23 Thread Michael Buch via Dwarf-discuss
Sounds like this is what https://github.com/llvm/llvm-project/pull/130255 is trying to achieve? If we could simplify that part of LLDB that'd be great! On Wed, 23 Apr 2025 at 16:32, Kyle Huey via Dwarf-discuss wrote: > > Consider the following C++ program > > #include > > class Base { > public: