Repository navigation
Struct Layout and Cache Line Inspector
Compiler alignment rules can silently bloat C and C++ data structures with hidden padding bytes, and a single hot scalar straddling a 64-byte L1 cache-line boundary can trigger false sharing across OpenMP worker threads. GridLock pairs a built-in DWARF struct layout and cache-line analyzer with live typed memory overlays so you can spot wasted padding, eliminate cache-line splits, and inspect raw heap buffers using real struct field names and values.

Why use it: Find compiler alignment holes, fields crossing 64-byte cache-line boundaries, and how many bytes you can reclaim by reordering struct members.
- Load your ELF target compiled with DWARF debug symbols (
-gor-g -O0) from the main toolbar or build your workspace (Tools -> Build Target). - Open Tools -> Struct Layout & Cache-Line Inspector... (or open Search Everywhere with
Ctrl+Shift+Pand chooseStruct Layout & Cache-Line Inspector...). - Enter a C or C++ struct or class name in Struct / Class: (for example,
HaloParticleorParticle) and click Inspect (or pressEnter). - Review the summary banner across the top of the window:
- Total byte size (
sizeof), natural alignment (align), total padding bytes, and wasted byte percentage. - Total 64-byte cache lines spanned and whether multiple writable fields or split fields trigger a
FALSE-SHARING RISKwarning.
- Total byte size (
- Scan the byte-map table row by row:
-
Cache-Line Dividers (
Cache Line 0 [0..63],Cache Line 1 [64..127]): Mark every 64-byte boundary cleanly. -
Padding Holes (
/* XXX N-byte hole */,/* XXX N-byte tail padding */): Highlight amber alignment gaps inserted by the compiler. -
Bitfields (
+offset:bit) and Virtual Table Pointers (vptr): Show exact bit offsets/widths and hidden C++vptrslots. -
Straddle Warnings (
L0 -> L1): Flag any member whose byte span crosses a 64-byte cache-line boundary.
-
Cache-Line Dividers (
- Check Greedy Optimal Packed Layout Preview: at the bottom of the dialog to copy a member-reordering suggestion showing the compacted size and bytes saved.
Why use it: Replace raw hexadecimal bytes in Memory View with decoded field names, types, live values, and padding holes in one step.

- Open the Memory View tab under Debug in the bottom tool rail and select HEX DUMP.
- In the Addr: box, type a C-style typed pointer cast around a target hex address or expression, for example:
Modifiers such as
(Particle*)0x00404000constandstruct(for example,(const struct HaloParticle *)0x7fff1234) are accepted automatically. - Click Read (or press
Enter). GridLock reads memory at that address, resolves the struct's DWARF layout from the active binary, and displays aTYPED OVERLAYsummary banner at the top of the hex dump. - Read decoded field annotations (
tag(uint8_t)=42,energy(double)=128.75) and alignment holes (/* XXX 7-byte hole */) inline beside each matching 16-byte hex/ASCII row. - To return to an untyped hex dump, replace the
Addr:expression with a plain hex address (such as0x00404000) or register/symbol ($rsp) and click Read.
| Capability | Details |
|---|---|
| Menu & Palette Entry |
Tools -> Struct Layout & Cache-Line Inspector... / Search Everywhere > Struct Layout & Cache-Line Inspector...
|
| Cache-Line Width | Fixed 64-byte hardware cache-line boundaries (Line 0 [0..63], Line 1 [64..127], ...) |
| Supported Field Types | Scalars (bool, signed/unsigned 8/16/32/64-bit ints, float, double), pointers, vptr slots, fixed arrays, bitfields (offset:bit, width) |
| Typed Cast Grammar |
(TypeName*)0xHEX, (struct TypeName *)0xHEX, (const TypeName*)0xHEX inside Memory View -> Addr:
|
For related low-level workflows (hex diffing across MPI ranks, virtual memory treemaps, Pointer Graph, and 2D Control Flow Graphs), see Memory, Reverse Engineering, and Profiling.
GridLock Repository | Releases | Report an Issue | Roadmap | Accessibility | License (MIT)
Documentation mirrored from docs/ on master.
Getting Started & Tutorials
Debugging Workflows
- UI & Debugging Manual
- Server Rack View
- MPI Diagnostics & HPC
- OpenMP OMPD Inspector
- Memory, RE & Profiling
- Struct Layout & Cache Lines
- Reference Manual & Packages
Customization & Reference
- Configuration & Themes
- Keyboard Shortcuts
- GDB Reference & Cheat Sheet
- Screenshot Gallery
- Engineering Roadmap
Extending & Architecture