[llvm-dev] PDB questions

Andrew Kelley via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 30 23:49:36 PDT 2018


One more:

3. In the purpose of mapping source file index to string, I found this
code:

Expected<codeview::DebugChecksumsSubsectionRef>
ModuleDebugStreamRef::findChecksumsSubsection() const {
  codeview::DebugChecksumsSubsectionRef Result;
  for (const auto &SS : subsections()) {
    if (SS.kind() != DebugSubsectionKind::FileChecksums)
      continue;

    if (auto EC = Result.initialize(SS.getRecordData()))
      return std::move(EC);
    return Result;
  }
  return Result;
}

Subsections() is populated here:

  if (auto EC = Reader.readSubstream(C13LinesSubstream, C13Size))
    return EC;

  BinaryStreamReader SymbolReader(SymbolsSubstream.StreamData);
  if (auto EC =
          SymbolReader.readArray(SymbolArray,
SymbolReader.bytesRemaining()))
    return EC;

  BinaryStreamReader SubsectionsReader(C13LinesSubstream.StreamData);
  if (auto EC = SubsectionsReader.readArray(Subsections,

SubsectionsReader.bytesRemaining()))
    return EC;

So it looks like there should be one of these just after the C13Lines
substream:

struct DebugSubsectionHeader {
  support::ulittle32_t Kind;   // codeview::DebugSubsectionKind enum
  support::ulittle32_t Length; // number of bytes occupied by this record.
};

But when I look there with my own code I only see zeroes:

read C13 line info 142964 bytes
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
DebugSubsectionHeader{ .Kind = DebugSubsectionKind.None, .Length = 0 }
<repeats until end of stream>

Any clues?


On Fri, Aug 31, 2018 at 2:17 AM Andrew Kelley <superjoe30 at gmail.com> wrote:

> Zachary,
>
> Thanks for the help on IRC earlier. I've got code that can capture a stack
> trace and then discover for each address, its module, function, source
> index, line, and column.
>
> I still have a couple of loose ends though. Do you know what's going on
> here?
>
> 1. There appears to be 8 bytes before every LineFragmentHeader. Here's
> some of my own debug output, which matches llvm-pdbutil's output. You can
> see it says "unknown bytes: ...".
>
> read C13 line info 136720 bytes
> unknown bytes: f2 00 00 00  60 00 00 00
> LineFragmentHeader{ .RelocOffset = 0, .RelocSegment = 5, .Flags =
> LineFlags{ .LF_HaveColumns = true, .unused = 0 }, .CodeSize = 52 }
> has column: true
> LineBlockFragmentHeader{ .NameIndex = 0, .NumLines = 6, .BlockSize = 84 }
> LineNumberEntry{ .Offset = 0, .Flags = 101 } Flags{ .Start = 101, .End =
> 17, .IsStatement = false }
> <snip some LineNumberEntry's>
> ColumnNumberEntry{ .StartColumn = 5, .EndColumn = 0 }
> ColumnNumberEntry{ .StartColumn = 30, .EndColumn = 0 }
> unknown bytes: f2 00 00 00  f0 00 00 00
> LineFragmentHeader{ .RelocOffset = 64, .RelocSegment = 5, .Flags =
> LineFlags{ .LF_HaveColumns = true, .unused = 0 }, .CodeSize = 366 }
> has column: true
> LineBlockFragmentHeader{ .NameIndex = 8, .NumLines = 18, .BlockSize = 228 }
> LineNumberEntry{ .Offset = 0, .Flags = 53 } Flags{ .Start = 53, .End = 20,
> .IsStatement = false }
> LineNumberEntry{ .Offset = 20, .Flags = 54 } Flags{ .Start = 54, .End =
> 24, .IsStatement = false }
> <etc>
>
> Do you know what's going on with these 8 bytes? I have scoured
> llvm-pdbutil's source but I cannot find where these bytes are coming from.
>
> 2. Is there a simpler way to find out which is the /names (string table)
> stream index without porting the entire hash table implementation?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180831/c7e8c642/attachment.html>


More information about the llvm-dev mailing list