[PATCH] D33807: [CodeView] Allow Debug Subsections to be read/written in any order

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 15:43:59 PDT 2017


zturner created this revision.
Herald added a subscriber: eraman.

Debug Subsections (Checksums, Line Info, Frame Data, etc) present an interesting challenge when it comes to reading and writing, especially to and from YAML.  Some of these challenges are:

1. Depending on whether the CodeView container is a PDB or an Object File, these show up in slightly different ways.  For example, in an Object File, string tables appear in the `.debug$S` section as a "debug subsection", while in a PDB file the string table is global to the entire file and exists
2. They can appear in any order, even though some subsections reference other subsections.  For example, you might have a Lines subsection followed by a Checksums subsection followed by a String Table subsection.  But the Lines subsection references the Checksums subsection, and the Checksum subsection references the String Table subsection.  So you can't interpret the data until you've read everything.

When going from Obj to Yaml, you might read (for example) a File Checksums subsection, which references a String Table subsection which you haven't actually read yet.  But in Pdb to Yaml, you'll already have the string table section because it's global to the file.

Prior to this patch, we handled in this in sort of a crude way.  When going from PDB to YAML, we would find the checksums subsection and write it to YAML first, then write subsequent sections later.  In a sense mandating a topological sorting similar to type record streams.  But this has a drawback.  It means that we can't easily test our ability to work with arbitrary files, because the only files we can produce are laid out a specific way.  Furthermore, it means that round-tripping will end up producing a different PDB than what you started with, because some of the subsections will be in a different order.

Finally, it makes things even more complicated when we start trying to do Obj -> Yaml -> Obj, because now these have a String Table subsection and various other subsections with cross subsection dependencies, and maintaining the topological sorting becomes cumbersome.  So I consider this work a precursor to getting CodeView Obj <-> Yaml support working.

In short, if it is a valid object (or PDB) file, we would like to be able to produce it.

This patch allows subsections to be specified in any order.  While this complicates some of the internal Yaml <-> Native data structure conversion logic, it greatly simplifies the portion of the library which actually writes subsections out, because you no longer have to have complicated sanitization checks to ensure things are written out in a specified order.  You can just write whatever you want and it will just work.


https://reviews.llvm.org/D33807

Files:
  llvm/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h
  llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
  llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
  llvm/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h
  llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
  llvm/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
  llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
  llvm/include/llvm/ObjectYAML/CodeViewYAMLContext.h
  llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h
  llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
  llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
  llvm/lib/DebugInfo/PDB/Native/PDBStringTable.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
  llvm/test/DebugInfo/PDB/Inputs/simple-line-info.yaml
  llvm/test/DebugInfo/PDB/pdbdump-yaml-lineinfo.test
  llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
  llvm/tools/llvm-pdbdump/PdbYaml.cpp
  llvm/tools/llvm-pdbdump/PdbYaml.h
  llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
  llvm/tools/llvm-pdbdump/YAMLOutputStyle.h
  llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33807.101127.patch
Type: text/x-patch
Size: 51932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170601/96a2fff9/attachment-0001.bin>


More information about the llvm-commits mailing list