Skip to content

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

Open
xezon wants to merge 2 commits 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 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/add-wwlib-container-natvis

Conversation

@xezon

@xezon xezon commented Sep 13, 2026

Copy link
Copy Markdown

Merge with Rebase

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

It also improves the natvis for AsciiString and UnicodeString to better match what the WWStrings visualizers show.

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.

@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

qodo-free-for-open-source-projects Bot commented Sep 13, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (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

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

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 registers twelve new Visual Studio natvis files for WWLib containers and enriches the existing ASCII and Unicode string visualizers. The latest revision also fixes lazy-length display for StringClass and WideStringClass.

  • Adds debugger expansion for WWLib vectors, lists, hashes, strings, buffers, arrays, and the intrusive queue.
  • Registers the visualizers with the MSVC IDE resource target.
  • Computes effective string lengths when cached header lengths are unset.
  • Still needs the repository-required license and copyright prologues on the twelve newly created files.

Confidence Score: 4/5

The debugger behavior appears sound, but the explicit repository requirement for license and copyright prologues must be satisfied before merging.

The previous lazy-length finding is fully fixed by bounded fallback scans that match the string classes’ effective-length behavior. The only remaining issue is that all twelve newly created WWLib natvis files omit required GPL and TheSuperHackers prologues.

Files Needing Attention: resources/visualstudio/wwlib/*.natvis

Important Files Changed

Filename Overview
resources/CMakeLists.txt Registers all twelve WWLib natvis resources for MSVC IDE projects.
resources/visualstudio/asciistring.natvis Adds bounded length, capacity, reference-count, and string-view presentation.
resources/visualstudio/unicodestring.natvis Adds the corresponding bounded wide-string metadata and string view.
resources/visualstudio/wwlib/wwstring.natvis Correctly falls back to scanning the buffer when the cached length is unset, resolving the previous finding.
resources/visualstudio/wwlib/widestring.natvis Applies the same effective-length behavior to wide strings.
resources/visualstudio/wwlib/hash.natvis Adds chained-bucket visualization but, like the other new WWLib natvis files, lacks the required file prologue.
resources/visualstudio/wwlib/multilist.natvis Adds visualizers for multi-list containers, nodes, objects, and iterators; its required file prologue is missing.
resources/visualstudio/wwlib/vector.natvis Adds vector, dynamic-vector, and packed-boolean visualization; its required file prologue is missing.
Prompt To Fix All With AI
### Issue 1
resources/visualstudio/wwlib/hash.natvis:1
**Required Prologues Are Missing**

This new natvis file starts directly with the XML declaration and omits the required GPL license prologue and TheSuperHackers copyright notice. The same omission appears in all twelve new files under `resources/visualstudio/wwlib/`. This repository requirement must be satisfied before merging.

---

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

Reviews (2): Last reviewed commit: "chore(natvis): Show length, capacity and..." | Re-trigger Greptile

Comment thread resources/visualstudio/wwlib/wwstring.natvis
xezon and others added 2 commits September 14, 2026 08:50
…ontainers (#3283)

The WWLib containers showed up in the Visual Studio debugger as raw structs, so
reading their elements meant expanding pointers and slicing arrays by hand. Each
WWLib header that declares a container used by the game now has a matching natvis
file in resources/visualstudio/wwlib, registered alongside the existing natvis
files under MSVC_IDE, so the containers expand directly to their elements.

Covered are VectorClass, DynamicVectorClass, BooleanVectorClass, SimpleVecClass,
SimpleDynVecClass, ShareBufferClass, UniqueArrayClass, GenericList, List, Node,
DataNode, SList, the MultiList classes and their iterators, HashTableClass,
HashTemplateClass, StringClass, WideStringClass and MPSCIntrusiveQueue. Types with
no users outside WWLib are left out: IndexClass, NTreeClass, BinaryHeapClass,
HashListClass, DoubleNode and Buffer.

DynamicVectorClass, SimpleDynVecClass and the typed MultiList classes have rules of
their own because natvis rules are inherited, and the base class rule would list
the allocated slots instead of the live elements. BooleanVectorClass reports Copy
for LastIndex, because that bit is only written back into the packed array once a
different index is fetched. StringClass and WideStringClass count the characters
when the stored length is 0, as Get_Length does, since a write through Get_Buffer
leaves the stored length at 0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ing and UnicodeString (#3283)

The [data] item of both visualizers was bound to the ref counted header instead of
the text, so expanding it showed the reference count and the allocation size under
a misleading name, and the length was not shown at all.

Both visualizers now list [length], [capacity] and [refs] as named items. No length
is stored, so [length] counts the characters like getLength does, capped at the
allocation so that a missing terminator cannot read past the buffer. [capacity]
includes the slot for the terminator, matching StringClass. A [refs] above 1 means
the buffer is shared and will be copied on the next write. A StringView adds the
text visualizer for long strings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@xezon
xezon force-pushed the xezon/add-wwlib-container-natvis branch from 43d73d3 to bccf3f5 Compare September 14, 2026 06:50
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