This is an archive of the discontinued LLVM Phabricator instance.

Make obj2yaml and yaml2obj support .debug$S and .debug$T sections
ClosedPublic

Authored by zturner on Jun 12 2017, 5:57 PM.

Details

Summary

This allows us to use yaml2obj and obj2yaml to round-trip CodeView symbol and type information without having to manually specify the bytes of the section. This makes for much easier to maintain tests. See the tests under lld/COFF in this patch for example. Before they just said SectionData: <blob> whereas now we can use meaningful record descriptions. Note that it still supports the SectionData yaml field, which could be useful for initializing a section to invalid bytes for testing, for example.

Diff Detail

Event Timeline

zturner created this revision.Jun 12 2017, 5:57 PM
rnk added inline comments.Jun 12 2017, 6:31 PM
lld/test/COFF/Inputs/pdb1.yaml
33–34

Is there a way we can fold !Symbols and Records: together? They're both plural, but !Symbols always consists of a list of records.

72

Excellent! =D

zturner added inline comments.Jun 13 2017, 8:56 AM
lld/test/COFF/Inputs/pdb1.yaml
33–34

Looked into this and while I think it's technically supported by the YAML spec (What goes under a tag is defined to be "application specific", so I guess it could be anything, and example 2.24 even seems to be an exact match for what we want to do (e.g. the !shape tag followed immediately by a list)), I don't think our YAML parser supports it. In order to map a block sequence, we have to give it a name. The specification for block sequences doesn't seem to require that a block sequence have a name, but otoh the syntax used in the yaml spec is hard to make sense of, so maybe I missed something.

TL;DR - Probably could do it, but non-trivial.

rnk edited edge metadata.Jun 13 2017, 9:45 AM
rnk added a subscriber: inglorion.

I skimmed over the rest of the code, and I didn't have any major comments. Do you want to give @inglorion a chance to review, or go ahead and commit?

lld/test/COFF/Inputs/pdb1.yaml
33–34

Oh well.

This revision was automatically updated to reflect the committed changes.
chapuni added inline comments.
llvm/trunk/tools/obj2yaml/coff2yaml.cpp
13 ↗(On Diff #102478)

They introduce LLVMDebugInfoCodeView in libdeps.

llvm/trunk/tools/yaml2obj/yaml2coff.cpp
21 ↗(On Diff #102478)

ditto.

rnk added inline comments.Jun 15 2017, 2:52 PM
llvm/trunk/lib/DebugInfo/CodeView/StringsAndChecksums.cpp
35 ↗(On Diff #102478)

This should propagate the Error on failure, this is library code.

46 ↗(On Diff #102478)

ditto

zturner added inline comments.Jun 15 2017, 3:19 PM
llvm/trunk/lib/DebugInfo/CodeView/StringsAndChecksums.cpp
35 ↗(On Diff #102478)

In that case can I just assert if it fails? We've got a corrupt object file at that point.