[PATCH] D32615: [pdb, lld] Write CodeView line tables to PDB.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 12:39:27 PDT 2017


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

In the global DBI stream, there is a list of module descriptors, one for each compiland.  These descriptors contain a StreamIndex field, and if it is set to something valid, this stream index contains much more debug info about the module, such as symbols and codeview line info.

Prior to this patch, we were not writing the CodeView line information portion of this stream.  This patch adds support for it.   The way to use the new functionality is as follows:

  PdbFileBuilder Pdb;
  auto &Dbi = Pdb.getDbiBuilder();
  auto &StringTable = Pdb.getStringTable();
  
  auto &Module = Dbi.addModuleInfo("foo.obj");
  
  StringTable.insert("foo.cpp");
  auto &Source = Dbi.addModuleSourceFile("foo.obj", "foo.cpp");
  
  auto Lines = llvm::make_unique<codeview::ModuleDebugLineFragment>();
  auto Checksums = llvm::make_unique<codeview::ModuleDebugChecksumFragment>();
  
  // All line contributions for foo.cpp
  
  // Line Number Name Offsets refer to the Dbi string.
  Lines->createBlock("foo.cpp", Dbi.getNameIndex("foo.cpp"));
  Lines->addLineInfo(CodeOffset, LineNumber);
  Lines->addLineInfo(CodeOffset2, LineNumber2);
  
  // All line contributions for foo.h
  Lines->createBlock("foo.h", Dbi.getNameIndex("foo.h"));
  Lines->addLineInfo(CodeOffset3, LineNumber3);
  
  // File checkum NameOffsets refer to the global string table.
  Checksums->addChecksum(StringTable.getNameIndex("foo.cpp"), FileChecksumKind::MD5, llvm::md5(getFileContents("foo.cpp")));
  
  Module.setC13LineInfo(std::move(Lines));
  Module.setC13ChecksumInfo(std::move(Checksums));
  
  Pdb.commit("out.pdb");


https://reviews.llvm.org/D32615

Files:
  llvm/include/llvm/DebugInfo/CodeView/CodeView.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h
  llvm/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h
  llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h
  llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
  llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
  llvm/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
  llvm/include/llvm/DebugInfo/PDB/Native/ModuleDebugStreamBuilder.h
  llvm/include/llvm/DebugInfo/PDB/Native/RawTypes.h
  llvm/include/llvm/DebugInfo/PDB/Native/StringTableBuilder.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
  llvm/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp
  llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
  llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp
  llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptor.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
  llvm/lib/DebugInfo/PDB/Native/ModuleDebugStreamBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/StringTableBuilder.cpp
  llvm/lib/MC/MCCodeView.cpp
  llvm/lib/Support/ScopedPrinter.cpp
  llvm/test/DebugInfo/PDB/Inputs/simple-line-info.yaml
  llvm/test/DebugInfo/PDB/pdbdump-yaml-lineinfo-write.test
  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/fuzzer/llvm-pdbdump-fuzzer.cpp
  llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
  llvm/tools/llvm-pdbdump/llvm-pdbdump.h
  llvm/tools/llvm-readobj/COFFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32615.96978.patch
Type: text/x-patch
Size: 54698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170427/63397a50/attachment.bin>


More information about the llvm-commits mailing list