clayborg wrote: FYI: There is already VTable support in our lldb::SBValue class and it is part of the public API in LLDB and doesn't require any of this: ``` /// If this value represents a C++ class that has a vtable, return an value /// that represents the virtual function table. /// /// SBValue::GetError() will be in the success state if this value represents /// a C++ class with a vtable, or an appropriate error describing that the /// object isn't a C++ class with a vtable or not a C++ class. /// /// SBValue::GetName() will be the demangled symbol name for the virtual /// function table like "vtable for <classname>". /// /// SBValue::GetValue() will be the address of the first vtable entry if the /// current SBValue is a class with a vtable, or nothing the current SBValue /// is not a C++ class or not a C++ class that has a vtable. /// /// SBValue::GetValueAtUnsigned(...) will return the address of the first /// vtable entry. /// /// SBValue::GetLoadAddress() will return the address of the vtable pointer /// found in the parent SBValue. /// /// SBValue::GetNumChildren() will return the number of virtual function /// pointers in the vtable, or zero on error. /// /// SBValue::GetChildAtIndex(...) will return each virtual function pointer /// as a SBValue object. /// /// The child SBValue objects will have the following values: /// /// SBValue::GetError() will indicate success if the vtable entry was /// successfully read from memory, or an error if not. /// /// SBValue::GetName() will be the vtable function index in the form "[%u]" /// where %u is the index. /// /// SBValue::GetValue() will be the virtual function pointer value as a /// string. /// /// SBValue::GetValueAtUnsigned(...) will return the virtual function /// pointer value. /// /// SBValue::GetLoadAddress() will return the address of the virtual function /// pointer. /// /// SBValue::GetNumChildren() returns 0 lldb::SBValue lldb::SBValue::GetVTable(); ```
So you can do this: ``` $ cat main.cpp 1 #include <stdio.h> 2 3 class Foo { 4 public: 5 virtual ~Foo() = default; 6 virtual void Dump() { 7 puts(__PRETTY_FUNCTION__); 8 } 9 }; 10 11 int main(int argc, const char **argv) { 12 Foo f; 13 f.Dump(); 14 return 0; 15 } ``` Then when you debug: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> v = lldb.frame.FindVariable('f') >>> v.GetVTable() vtable for Foo = 0x0000000100004030 { [0] = 0x0000000100003ea4 a.out`Foo::~Foo() at main.cpp:5 [1] = 0x0000000100003ef4 a.out`Foo::~Foo() at main.cpp:5 [2] = 0x0000000100003e7c a.out`Foo::Dump() at main.cpp:6 } ``` Doesn't require any debug info. https://github.com/llvm/llvm-project/pull/130255 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits