Giter VIP home page Giter VIP logo

Comments (2)

andreasfertig avatar andreasfertig commented on May 26, 2024

Hello @rajendrasp,

thanks for raising this question.

Addressing the vtable:
What you're asking for isn't represented in the AST at the front-end stage. This is the main reason C++ Insights currently doesn't show that information. I have some idea of how to implement support for this, but it would be limited to the Itanium ABI, which is different from Microsoft and others.

Since you raised the question, how would you like to see the transformation?

Regarding the memory layout:
I'm not sure what you're missing here. There is an option to show padding information, giving you memory layout information.

Andreas

from cppinsights.

rajendrasp avatar rajendrasp commented on May 26, 2024

For vtable, I was thinking of seeing the memory layout of compiled object. Microsoft Visual C++ has following undocumented options that give layout information.

/d1reportSingleClassLayoutXXX
/d1reportAllClassLayout

https://stackoverflow.com/questions/2138890/layout-of-compiled-objects

Following is what it ouputs for a multiply-inherited classes.

Library.cpp

class IHen size(8):
+---
0 | +--- (base class IObject)
0 | | {vfptr}
| +---
+---

IHen::$vftable@:
| &IHen_meta
| 0
0 | &IObject::AddRef
1 | &IObject::Release
2 | &IObject::As
3 | &IHen::Cluck
4 | &IHen::Roost

IHen::Cluck this adjustor: 0
IHen::Roost this adjustor: 0

class IHen2 size(8):
+---
0 | +--- (base class IHen)
0 | | +--- (base class IObject)
0 | | | {vfptr}
| | +---
| +---
+---

IHen2::$vftable@:
| &IHen2_meta
| 0
0 | &IObject::AddRef
1 | &IObject::Release
2 | &IObject::As
3 | &IHen::Cluck
4 | &IHen::Roost
5 | &IHen2::Forage

IHen2::Forage this adjustor: 0

class Hen size(24):
+---
0 | +--- (base class IHen2)
0 | | +--- (base class IHen)
0 | | | +--- (base class IObject)
0 | | | | {vfptr}
| | | +---
| | +---
| +---
8 | +--- (base class IOfflineChicken)
8 | | +--- (base class IObject)
8 | | | {vfptr}
| | +---
| +---
16 | m_count
| (size=4)
+---

Hen::$vftable@IHen2@:
| &Hen_meta
| 0
0 | &Hen::AddRef
1 | &Hen::Release
2 | &Hen::As
3 | &Hen::Cluck
4 | &Hen::Roost
5 | &Hen::Forage

Hen::$vftable@IOfflineChicken@:
| -8
0 | &thunk: this-=8; goto Hen::AddRef
1 | &thunk: this-=8; goto Hen::Release
2 | &thunk: this-=8; goto Hen::As
3 | &Hen::Load
4 | &Hen::Save

I do not understand why thunk is used instead of just saying &Hen::AddRef in vtable "Hen::$vftable@IOfflineChicken@:".

But this is something I was hoping for with a bit of better presentation in the cppinsights.

I was also looking for code that initialises the this->_vptr in constructors. And compiler generated code in destructor if there is any.

Thanks.

from cppinsights.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.