This is an archive of the discontinued LLVM Phabricator instance.

[PDB] Add a module descriptor for every object file
ClosedPublic

Authored by rnk on Jun 12 2017, 5:54 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.Jun 12 2017, 5:54 PM
zturner added inline comments.Jun 13 2017, 7:30 AM
lld/COFF/PDB.cpp
113–115 ↗(On Diff #102269)

A slightly cleaner way to do this would be to make an ExitOnError outside of this for loop, then just write auto &MD = Err(Builder.getDbiBuilder().addModuleInfo(Path);

ExitOnError Err("Error while adding objects to PDB");
for (...) {
  auto &MD = Err(Builder.getDbiBuilder().addModuleInfo(Path));
lld/test/COFF/pdb-lib.s
3–4 ↗(On Diff #102269)

I know this keeps it all in one file, but sed on the input file is kind of a huge hack, what about putting the code in an input file under Inputs/?

Maybe in the future we could remove dependency on sed by making a tool which essentially strips a file of everything but a single label. Like:

llvm-strip --keep-label=BAR --remove-label-headers < %s > bar.asm
12 ↗(On Diff #102269)

I'd remove anything fragile like debug stream indices.

llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
296 ↗(On Diff #102269)

Is this correct? Shouldn't it be the index of the section?

rnk added inline comments.Jun 13 2017, 8:14 AM
lld/test/COFF/pdb-lib.s
3–4 ↗(On Diff #102269)

I'd like something like llvm-strip, or maybe llvm-split, which splits something like this up into multiple inputs:

// ==> file_a.h <==
struct Foo { ... };
extern Foo my_global;

// ==> file_b.c <==
#include "file_a.h"
Foo my_global;

// ==> file_c.c <==
#include "file_a.h"
int use_global() { return my_global.x; }

That's basically the format people use to file bugs. And then you get editor syntax highlighting that works.

Let's just use Inputs for now.

12 ↗(On Diff #102269)

OK, I'll remove that. I want to keep the line info, source file name, etc, since these are .s files without any .debug$S data and those *should* remain zero.

llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
296 ↗(On Diff #102269)

I haven't figured out what it's supposed to be yet, but zero isn't correct, because it's not the null representation used in microsoft-pdb.

I did some experiments but I wasn't able to nail it down by the end of the day, so I figured I'd send what I have and we can improve on it later.

zturner accepted this revision.Jun 13 2017, 8:24 AM

looks good after the agreed upon changes.

This revision is now accepted and ready to land.Jun 13 2017, 8:24 AM
rnk added inline comments.Jun 13 2017, 8:47 AM
lld/COFF/PDB.cpp
113–115 ↗(On Diff #102269)

(forgot to respond to this) Thanks, I tried check() first, but that doesn't work because it isn't overloaded for Expected<T&>.

This revision was automatically updated to reflect the committed changes.