[llvm-dev] Dumping the Vtable

Damilola Orikogbo via llvm-dev llvm-dev at lists.llvm.org
Tue May 30 20:23:42 PDT 2017


Hi Hans,

Thanks for the reply. I apologize for the unclear question. I am new to
using clang and llvm.

I have tried this but the version I have for some reason won't allow me to
use this command line option. Furthermore, I am trying to get this
information via the IR  and writing a pass to get this information to use
at a later point.


-Dami

On Tue, May 30, 2017 at 12:56 PM, Hans Wennborg <hans at chromium.org> wrote:

> Hi Damilola,
>
> On Mon, May 29, 2017 at 5:20 AM, Damilola Orikogbo via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > Can someone help me with how to dump the vtable and the vptr addresses
> > within it?
>
> I'm not sure if this answers your question exactly, but you can pass
> "-Xclang -fdump-vtable-layouts" to ask Clang to dump the layout of
> generated vtables. For example:
>
> $ cat /tmp/a.cc
> struct S {
>   virtual void f() {};
> };
>
> void f(S * s) {
>   s->f();
> }
> $ bin/clang++ -c /tmp/a.cc -Xclang -fdump-vtable-layouts
> Vtable for 'S' (3 entries).
>    0 | offset_to_top (0)
>    1 | S RTTI
>        -- (S, 0) vtable address --
>    2 | void S::f()
>
> VTable indices for 'S' (1 entries).
>    0 | void S::f()
>
>
>  - Hans
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170530/b8cc0e82/attachment.html>


More information about the llvm-dev mailing list