Skip to content

chore(natvis): Add natvis files for all used wwlib containers - #3283

Open
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/add-wwlib-container-natvis
Open

chore(natvis): Add natvis files for all used wwlib containers#3283
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/add-wwlib-container-natvis

Conversation

@xezon

@xezon xezon commented Sep 13, 2026

Copy link
Copy Markdown

This change adds natvis files for all used wwlib containers. It allows to inspect them properly in Visual Studio.

I only looked at DynamicVectorClass in Visual Studio and it looked fine.

image

Coverage

Twelve new files in a new resources/visualstudio/wwlib/ subfolder, one per WWLib header,
matching the existing one-family-per-file naming. The subfolder keeps the WWLib set from
crowding the four existing top-level files and makes the source library each visualizer
belongs to obvious from the path.

New file Types
vector.natvis VectorClass<T>, DynamicVectorClass<T>, BooleanVectorClass
simplevec.natvis SimpleVecClass<T>, SimpleDynVecClass<T>
sharebuf.natvis ShareBufferClass<T>
uarray.natvis UniqueArrayClass<T>
listnode.natvis GenericNode, GenericList, Node<T>, List<T>, DataNode<T>
slist.natvis SList<T>, SLNode<T>
multilist.natvis MultiListObjectClass, GenericMultiListClass, MultiListClass<T>, RefMultiListClass<T>, GenericMultiListIterator, MultiListIterator<T>, RefMultiListIterator<T>
hash.natvis HashTableClass, HashTableIteratorClass
hashtemplate.natvis HashTemplateClass<K,V>, HashTemplateIterator<K,V>
wwstring.natvis StringClass
widestring.natvis WideStringClass
mpsc_intrusive_queue.natvis MPSCIntrusiveQueue<T>

Deliberately not covered: IndexClass (INDEX.h), NTreeClass/NTreeLeafClass,
BinaryHeapClass, HashListClass, DoubleNode, Buffer — zero instantiations outside
WWLib, so the rules could not be validated against real data. hashtab.h is entirely
inside #if 0, search.h is a dead duplicate of INDEX.h, and STLUtils.h
range/const_range are trivial iterator pairs.

AI Use

This was a one shot generation with Claude Opus 5. It claimed to have verified all of them with Visual Studio.

  • Schema — all 12 validate clean against VS2022's natvis.xsd.
  • Live debugger — a harness linking the prebuilt wwlib.lib/wwdebug.lib/wwstub.lib, driven headlessly by cdb.exe with .nvload + dx -r2. All 12 files reported "Successfully loaded visualizers", no <error> nodes, and every container's contents matched what the harness wrote — g_dynvec{ size=3 } 10/20/30, the MultiList → 301/302/303, the hash table → alpha/beta, g_string"hello natvis" length 12.

Covers
VectorClass<T>, DynamicVectorClass<T>, BooleanVectorClass
SimpleVecClass<T>, SimpleDynVecClass<T>
ShareBufferClass<T>
UniqueArrayClass<T>
GenericNode, GenericList, Node<T>, List<T>, DataNode<T>
SList<T>, SLNode<T>
MultiListObjectClass, GenericMultiListClass, MultiListClass<T>, RefMultiListClass<T>, GenericMultiListIterator, MultiListIterator<T>, RefMultiListIterator<T>
HashTableClass, HashTableIteratorClass
HashTemplateClass<K,V>, HashTemplateIterator<K,V>
StringClass
WideStringClass
MPSCIntrusiveQueue<T>
@xezon xezon added the Debug Is mostly debug functionality label Sep 13, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add Visual Studio visualizers for WWLib containers

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Adds Visual Studio visualizers for actively used WWLib container families.
• Exposes container contents, metadata, strings, and iterator state through debugger views.
• Registers all visualizers with the resources target for MSVC IDE builds.
Diagram

graph TD
  CMAKE["Resources CMake"] --> MSVC{"MSVC IDE?"} -->|yes| TARGET["Resources Target"] --> NATVIS["WWLib Natvis"] --> DEBUGGER["VS Debugger"] --> VIEWS["Structured Views"]
  INSTANCES["WWLib Instances"] --> DEBUGGER
Loading
High-Level Assessment

The header-family-per-file structure is appropriate because it mirrors WWLib ownership, keeps expressions close to related container layouts, and avoids crowding existing top-level visualizers. A monolithic WWLib Natvis file would reduce file count but make validation and maintenance harder, while embedding visualizers into C++ headers would unnecessarily couple debugger configuration to production sources.

Files changed (13) +432 / -0

Enhancement (12) +420 / -0
hash.natvisVisualize chained WWLib hash tables and iterators +36/-0

Visualize chained WWLib hash tables and iterators

• Adds debugger views for HashTableClass bucket chains and HashTableIteratorClass state. Entries are traversed across buckets through HashableClass links.

resources/visualstudio/wwlib/hash.natvis

hashtemplate.natvisVisualize templated hash maps and iterators +36/-0

Visualize templated hash maps and iterators

• Adds key-value expansion for HashTemplateClass<K,V> by traversing bucket handles and table chains. Iterator views expose the current key, value, bucket, and backing table.

resources/visualstudio/wwlib/hashtemplate.natvis

listnode.natvisVisualize generic, typed, and data list nodes +64/-0

Visualize generic, typed, and data list nodes

• Adds sentinel-aware traversal for GenericList and List<T>, plus link views for GenericNode and Node<T>. DataNode<T> displays its value and typed neighboring nodes.

resources/visualstudio/wwlib/listnode.natvis

mpsc_intrusive_queue.natvisVisualize intrusive MPSC queue chains +19/-0

Visualize intrusive MPSC queue chains

• Adds a debugger expansion for MPSCIntrusiveQueue<T> that walks the intrusive head chain. The displayed order is documented as newest-first, before consumer-side reversal.

resources/visualstudio/wwlib/mpsc_intrusive_queue.natvis

multilist.natvisVisualize circular multi-lists, memberships, and iterators +103/-0

Visualize circular multi-lists, memberships, and iterators

• Adds sentinel-aware views for generic, typed, and reference multi-lists, including object list memberships and node links. Generic and typed iterator views expose current entries and completion state.

resources/visualstudio/wwlib/multilist.natvis

sharebuf.natvisVisualize shared buffer contents and ownership metadata +16/-0

Visualize shared buffer contents and ownership metadata

• Adds array expansion for ShareBufferClass<T> with size and reference-count metadata. The debug-only message field is handled as optional.

resources/visualstudio/wwlib/sharebuf.natvis

simplevec.natvisVisualize simple fixed and dynamic vectors +27/-0

Visualize simple fixed and dynamic vectors

• Adds array views for SimpleVecClass<T> and SimpleDynVecClass<T>. Dynamic vectors use their active count for displayed elements while retaining capacity metadata.

resources/visualstudio/wwlib/simplevec.natvis

slist.natvisVisualize typed singly linked lists and nodes +27/-0

Visualize typed singly linked lists and nodes

• Adds linked traversal for SList<T>, casting generic payload and link pointers back to their element types. SLNode<T> exposes typed data and next-node fields.

resources/visualstudio/wwlib/slist.natvis

uarray.natvisVisualize unique array values and capacity +17/-0

Visualize unique array values and capacity

• Adds indexed expansion for UniqueArrayClass<T> through its internal HashItem vector. The view also exposes active size, vector capacity, and hash table size.

resources/visualstudio/wwlib/uarray.natvis

vector.natvisVisualize vectors, dynamic vectors, and packed booleans +44/-0

Visualize vectors, dynamic vectors, and packed booleans

• Adds logical array views and metadata for VectorClass<T> and DynamicVectorClass<T>. BooleanVectorClass expands packed bits while accounting for its cached, potentially unwritten current bit.

resources/visualstudio/wwlib/vector.natvis

widestring.natvisVisualize WWLib wide strings and buffer metadata +15/-0

Visualize WWLib wide strings and buffer metadata

• Adds Unicode display and string views for WideStringClass. Non-empty buffers expose length and capacity from the allocation header while safely handling the shared empty string.

resources/visualstudio/wwlib/widestring.natvis

wwstring.natvisVisualize WWLib narrow strings and buffer metadata +16/-0

Visualize WWLib narrow strings and buffer metadata

• Adds narrow string display and expansion for StringClass. Non-empty buffers expose header-backed length and capacity while avoiding invalid header access for the shared empty string.

resources/visualstudio/wwlib/wwstring.natvis

Other (1) +12 / -0
CMakeLists.txtRegister WWLib visualizers for MSVC IDE builds +12/-0

Register WWLib visualizers for MSVC IDE builds

• Adds all twelve WWLib Natvis files to the resources target when generating a Visual Studio project, making the debugger definitions available in the IDE.

resources/CMakeLists.txt

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. New hash iterators show debugger errors 🐞 Bug ≡ Correctness
Description
The hash iterator visualizer dereferences CurrentEntry, although HashTableIteratorClass leaves
that member uninitialized until First() calls Next(). Inspecting an iterator after construction
but before First() can therefore evaluate an arbitrary pointer and produce an invalid debugger
display.
Code

resources/visualstudio/wwlib/hash.natvis[28]

+        <DisplayString>{*CurrentEntry}</DisplayString>
Evidence
The iterator constructor initializes only Table, leaving Index, CurrentEntry, and NextEntry
indeterminate. CurrentEntry receives its first value only through First() and Next(), while
the new fallback display dereferences it whenever its indeterminate value does not compare equal to
null.

Core/Libraries/Source/WWVegas/WWLib/hash.h[93-108]
Core/Libraries/Source/WWVegas/WWLib/hash.cpp[131-145]
resources/visualstudio/wwlib/hash.natvis[26-33]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The hash iterator visualizer dereferences `CurrentEntry` even though the iterator constructor does not initialize it, so inspecting a newly constructed iterator before `First()` can produce a debugger evaluation error.

## Fix Focus Areas
- resources/visualstudio/wwlib/hash.natvis[27-28]

## Recommended Fix
Change the fallback display to show the `CurrentEntry` pointer without dereferencing it, or add a reliably initialized iterator-state condition before rendering the pointed-to object.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 13/18, lines 432/200; both must reach the floor). Router rationale: This adds substantial, independently authored debugger visualization logic across 12 files and many container layouts, creating numerous easy-to-miss expression, traversal, type-casting, and integration defects despite no runtime behavior change.

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread resources/visualstudio/wwlib/hash.natvis
@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds Visual Studio Natvis support for WWLib's vector, list, hash, string, and queue container families and registers all twelve files with the existing MSVC IDE resources target.

  • The container traversal and layout expressions generally match their corresponding WWLib implementations.
  • The newly created files need the repository-required GPL prologues.
  • The string visualizers should report effective rather than raw cached lengths for mutable buffers.

Confidence Score: 4/5

The visualizer logic is largely sound, but the PR should not merge until the repository-required GPL prologues are added; the inaccurate mutable-string length display should also be corrected.

The container layouts and traversal rules match the implementation, with no blocking runtime defect identified. The remaining behavioral issue is limited to misleading string lengths in the debugger, while the missing license prologues violate an explicit repository requirement.

Files Needing Attention: resources/visualstudio/wwlib/*.natvis, especially wwstring.natvis and widestring.natvis

Important Files Changed

Filename Overview
resources/CMakeLists.txt Registers all twelve nested WWLib Natvis files using the established MSVC IDE resource pattern.
resources/visualstudio/wwlib/vector.natvis Visualizes fixed, dynamic, and packed-boolean vectors with counts and storage expressions matching their implementations; its new-file prologue lacks the required license.
resources/visualstudio/wwlib/listnode.natvis Adds sentinel-aware visualizers for generic and typed intrusive lists; its new-file prologue lacks the required license.
resources/visualstudio/wwlib/multilist.natvis Adds circular-list, membership, node, and iterator visualizers consistent with the multilist layouts; its new-file prologue lacks the required license.
resources/visualstudio/wwlib/hash.natvis Adds bucket-chain and iterator visualization for the non-template hash table, but omits the required GPL prologue.
resources/visualstudio/wwlib/hashtemplate.natvis Adds sentinel-aware template hash and iterator visualization, but omits the required GPL prologue.
resources/visualstudio/wwlib/wwstring.natvis Visualizes narrow strings and allocation metadata, but reports the raw cached length and omits the required license prologue.
resources/visualstudio/wwlib/widestring.natvis Visualizes wide strings using the shared header layout, but has the same cached-length discrepancy and missing license prologue.
resources/visualstudio/wwlib/mpsc_intrusive_queue.natvis Adds newest-first raw-link traversal consistent with queue publication semantics; its new-file prologue lacks the required license.
Prompt To Fix All With AI
### Issue 1
resources/visualstudio/wwlib/hash.natvis:1
**Missing GPL license headers**

This new Natvis file starts with the XML declaration and omits the GPL license prologue required for newly created files. The same omission appears in the other eleven new files under `resources/visualstudio/wwlib/`. This repository requirement must be satisfied before merging.

### Issue 2
resources/visualstudio/wwlib/wwstring.natvis:11
**Length display can be wrong**

After a caller writes through a mutable string buffer, the stored header length may remain zero while `Get_Length()` computes the actual length from the terminator. Reading the raw header here therefore shows `[length] = 0` for a valid non-empty string. The equivalent expression in `widestring.natvis` has the same problem; both visualizers should use the class's effective-length behavior.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "chore(natvis): Add natvis files for all ..." | Re-trigger Greptile

Comment thread resources/visualstudio/wwlib/wwstring.natvis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Debug Is mostly debug functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant