Template arg resolution with PDB type information (original) (raw)
February 17, 2025, 2:30am 1
Currently this information is lost, since CodeView objects, unlike DWARF, don’t have a “first party” option for storing template args. For reference, I’m coming from a Rust perspective, but this is true for C++ as well. There’s quite a few formatter script tricks that rely on template args, and things like the byte-code interpreter more or less require template args for any kind of useful output for generic containers (vec, hashmap, etc.)
There are a few ways to resolve this:
- Extract from the type name string at some point during processing. This is probably the “least effort”, but also somewhat slow and fragile. From what I can tell, it could be done as early as the PDB parsing step or as late as when a TypeSystem requests the template args.
- Take advantage of the “CustomType”/OEM Generic Type objects, which allow storing an array of types. It should be possible to use these to store the “base type” at the first index, and the template args in the remainder of the array and retrieve those at debug-time. Technically it wants a “microsoft-assigned OEM identifier” (which llvm might already have?) but tbh i doubt it matters much.