Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 2.9 KB

README.md

File metadata and controls

61 lines (39 loc) · 2.9 KB

StructLayout

Visual Studio Extension for C++ struct memory layout visualization

MarketPlace Donate

Download latest from the Visual Studio Marketplace

Motivation

In C++, the structure layout can be affected by different factors. In order to produce performant data cache oriented code or reduce the structure memory footprint, it is important to be aware of the class layouts at the same spot where code is created, updated, removed or debugged. This extension allows programmers to visualize their structures within Visual Studio with just 1 click.

Features

Right click on top of any C++ struct definition and select Show Struct Layout (or press Alt+L) in order to visualize the memory layout.

Interaction

Stack Mode

In this visualization mode the types with children are stacked in order to allow navigation in and out and get a better sense of overall structure.

Stack screenshot

Flat Mode

The flat mode skips all groups and only shows one layer, producing a more compact view.

Flat screenshot

How it works

Struct Layout uses Clang LibTooling internally to parse the C++ files and extract the memory layout information.

When a Layout request is made the extension does the following:

  • Retrieve the active document and cursor position.
  • Extract the relevant file and project properties (cl or nmake).
    1. Include directories
    2. Force includes
    3. Preprocessor definitions
    4. Exclude directories
  • Add the extra parameters from the extension options.
  • Trigger the LayoutParser (Clang libtooling application) with all the arguments gathered.
  • Visualize the results or print any issues found in the StructLayout Output Pane.

Documentation

References

Contributing

This project is open to code contributions.

If you found this extension useful you can always buy me a cup coffee.

paypal