This is an archive of the discontinued LLVM Phabricator instance.

completely rewrite the llvm-pdbutil "raw" output style
ClosedPublic

Authored by zturner on Jun 13 2017, 7:46 PM.

Details

Summary

After some internal discussions, we agreed that the raw output style had outlived its usefulness. It was originally created before we had even thought of dumping to YAML, and it was intended to give us some insight into the internals of a PDB file. Now we have YAML mode which does almost exactly this but is more powerful in that it can round-trip back to a PDB, which the raw mode could not do. So the raw mode had become purely a maintenance burden.

One option was to just delete it. However, its original goal was to be as readable as possible while staying close to the "metal" - i.e. presenting the output in a way that maps directly to the underlying file format. We don't actually need that last requirement anymore since it's covered by the yaml mode, so we could repurpose "raw" mode to actually just be as readable as possible.

This patch implements about 80% of the functionality previously in raw mode, but in a completely different style that is more akin to what cvdump outputs. Records are very compressed, often times appearing on just one line. One nice thing about this is that it makes full record matching easier, because you can grep for indices, names, and leaf types on a single line often.

See the tests for some examples of what the new output looks like.

Note that this patch actually regresses the functionality of raw mode in a few areas, but only because the patch was already unreasonably large and going 100% would have been even worse. Specifically, this patch is missing:

  1. The ability to dump module debug subsections (checksums, lines, etc)
  2. The ability to dump section headers

Aside from that everything is here. While goign through the tests fixing them all up, I found many duplicate tests. They've been deleted. In subsequent patches I will go through and re-add the missing functionality.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Jun 13 2017, 7:46 PM
rnk edited edge metadata.Jun 15 2017, 10:45 AM

I like the new format, it is more readable. Ideally we'd add an option to print the types in reverse order to make them more FileCheck friendly, so you can CHECK for a LF_STRUCT, it's name, it's field list, and use that to find the next field list. Seems like something for later.

This also seems suitable to use from llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp. I'll probably take that on.

llvm/include/llvm/DebugInfo/CodeView/Formatters.h
50 ↗(On Diff #102471)

Is it possible to thread a TypeDatabase into the formatter so that we can print the string? My first idea is to make it work like this:

struct TypeWithDB { TypeIndex TI; TypeDatabase &TDB; };
...
  // method of MinimalDumper
  TypeWithDB typeWithDB(TypeIndex TI) { return TypeWithDB{TI, TDB}; }
...
  // usage
  P.formatLine("referent = {0}, modifiers = {1}", typeWithDB(Mod.ModifiedType),
               modifierOptions(Mod.Modifiers));

Totally reasonable to leave as a follow up.

rnk accepted this revision.Jun 15 2017, 10:50 AM

lgtm

llvm/include/llvm/Support/MathExtras.h
530 ↗(On Diff #102471)

numBaseTenDigits?

This revision is now accepted and ready to land.Jun 15 2017, 10:50 AM
This revision was automatically updated to reflect the committed changes.
llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.h