This is an archive of the discontinued LLVM Phabricator instance.

Define DbiStreamBuilder::addSectionContribs.
ClosedPublic

Authored by ruiu on Nov 1 2016, 1:02 PM.

Details

Summary

This patch defines a new function to add a SectionContribs stream
to a PDB file. Unlike SectionMap, SectionContribs contains a list
of input sections as opposed to output sections.

Note that this patch needs improving because currently we do not
set Module field in SectionContribs entries. In a follow-up patch,
I'll add Modules and then fix it after that.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 76619.Nov 1 2016, 1:02 PM
ruiu retitled this revision from to Define DbiStreamBuilder::addSectionContribs..
ruiu updated this object.
ruiu added a reviewer: zturner.
ruiu added a subscriber: llvm-commits.
ruiu added a comment.Nov 11 2016, 2:20 PM

Ping. I noticed that this wasn't committed yet.

zturner added inline comments.Nov 11 2016, 2:29 PM
include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h
68 ↗(On Diff #76619)

This line looks like it wraps too soon.

lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
315 ↗(On Diff #76619)

I think you should try to fill out Entry.ISect and Entry.IMod. The first one seems like it's probably just the index, so you could get it by iterating over using llvm::enumerate(). Not sure how you will get the last one, but it seems important nonetheless. What do you think?

ruiu added inline comments.Nov 11 2016, 2:32 PM
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
315 ↗(On Diff #76619)

I will fill ISect but probably not IMod in this patch because I don't understand the meaning of the field yet.

zturner added inline comments.Nov 11 2016, 2:42 PM
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
315 ↗(On Diff #76619)

IMod is the index of the module in the DBI Stream's ModInfo array. For example, if this section contribution is for foo.obj, and foo.obj is the 7th entry in the ModInfo array, then IMod would be 7. For example, if I run -section-contribs against empty.pdb I get this:

Section Contributions [
  Contribution {
    ISect: 1
    Off: 0
    Size: 10
    Characteristics [ (0x60000020)
      IMAGE_SCN_CNT_CODE (0x20)
      IMAGE_SCN_MEM_EXECUTE (0x20000000)
      IMAGE_SCN_MEM_READ (0x40000000)
    ]
    Module {
      Index: 1
      Name: * Linker *
    }
    Data CRC: 0
    Reloc CRC: 0
  }
  Contribution {
    ISect: 1
    Off: 16
    Size: 10
    Characteristics [ (0x60500020)
      IMAGE_SCN_ALIGN_16BYTES (0x500000)
      IMAGE_SCN_CNT_CODE (0x20)
      IMAGE_SCN_MEM_EXECUTE (0x20000000)
      IMAGE_SCN_MEM_READ (0x40000000)
    ]
    Module {
      Index: 0
      Name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
    }
    Data CRC: 3617027124
    Reloc CRC: 0
  }

We have indices of 1 and 0. Now if I run with -modules, I get this:

Modules [
  {
    Name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
    Debug Stream Index: 12
    Object File Name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
    Num Files: 1
    Source File Name Idx: 0
    Pdb File Name Idx: 0
    Line Info Byte Size: 0
    C13 Line Info Byte Size: 88
    Symbol Byte Size: 208
    Type Server Index: 0
    Has EC Info: No
  }
  {
    Name: * Linker *
    Debug Stream Index: 14
    Object File Name:
    Num Files: 0
    Source File Name Idx: 0
    Pdb File Name Idx: 1
    Line Info Byte Size: 0
    C13 Line Info Byte Size: 0
    Symbol Byte Size: 516
    Type Server Index: 0
    Has EC Info: No
  }

and we can see that the IMod field matches up with the order of the module in the module info array.

ruiu marked an inline comment as done.Nov 11 2016, 3:27 PM
ruiu added inline comments.
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
315 ↗(On Diff #76619)

Thanks. But I'll do that later because we haven't added Modules yet.

zturner accepted this revision.Nov 11 2016, 3:42 PM
zturner edited edge metadata.
This revision is now accepted and ready to land.Nov 11 2016, 3:42 PM
This revision was automatically updated to reflect the committed changes.