This is an archive of the discontinued LLVM Phabricator instance.

[dsymutil] Collect parseable Swift interfaces in the .dSYM bundle.
ClosedPublic

Authored by aprantl on Apr 12 2019, 4:04 PM.

Details

Summary

When a Swift module built with debug info imports a library without
debug info from a textual interface, the textual interface is
necessary to reconstruct types defined in the library's interface. By
recording the Swift interface files in DWARF dsymutil can collect them
and LLDB can find them.

This patch teaches dsymutil to look for DW_TAG_imported_modules and
records all references to parseable Swift interfrace files and copies
them to

    
`a.out.dSYM/Contents/Resources/<Arch>/<ModuleName>.swiftinterface`

rdar://problem/49751748

Diff Detail

Event Timeline

aprantl created this revision.Apr 12 2019, 4:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2019, 4:04 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
friss added inline comments.Apr 15 2019, 9:06 AM
llvm/tools/dsymutil/DwarfLinker.cpp
2159–2160

I haven't looked too deeply at the rest of the patch, but I think this comment was referring to DW_AT_comp_dir and is now stale and misleading.

JDevlieghere added inline comments.Apr 17 2019, 6:52 PM
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
169

Early return?

llvm/tools/dsymutil/CompileUnit.h
322

dwarf::SourceLanguage?

llvm/tools/dsymutil/DwarfLinker.cpp
273

Since it's passed already, can the helper append the path?

294

Maybe we should just make this a member function instead of passing ReportWarning as a callback.

2195

Aha, this answers my previous question: no because the helper is used here too.

2510

SmallString<0>? Also, how about moving this out of the loop and clearing it?

2518

nit: maybe be a little more verbose here

llvm/tools/dsymutil/DwarfLinker.h
497

Can you explain what the first and second string is? Can this be a StringMap?

aprantl marked an inline comment as done.Apr 18 2019, 9:50 AM
aprantl added inline comments.
llvm/tools/dsymutil/DwarfLinker.h
497

I thought about his, too. This is a map from ModuleName->FilePath (I'll add that to the comment). I need the entries to be uniqued and sorted and there are only few entries expected per compile unit. The iteration order over a StringMap isn't well-defined and the RHS would need to be std::strings anyway, so I thought a std::map fits the bill.

aprantl marked an inline comment as done.Apr 18 2019, 9:52 AM
aprantl added inline comments.
llvm/tools/dsymutil/DwarfLinker.cpp
2510

This variable is only going to be used in the unlikely case of Options.PrependPath being set, which basically only happens in the test suite. What's the benefit of hoisting the declaration out of the loop? Avoiding re-allocating the buffer? I think I can do that.

aprantl updated this revision to Diff 195941.Apr 19 2019, 5:00 PM
aprantl marked 3 inline comments as done.

Address review feedback. Thanks!

llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
169

I'm not convinced that this is much better. What do you think?

if (!V)
  return Default;

const char *Str = V->getAsCString()
if (!Str)
  return Default;

return Str;
llvm/tools/dsymutil/CompileUnit.h
322

Unfortunately SourceLanguage neither has a storage class nor an enumerator for 0 defined.

llvm/tools/dsymutil/DwarfLinker.cpp
273

No, the other user needs them separate. I tried to make the interface slightly less weird.

JDevlieghere added inline comments.Apr 22 2019, 9:17 AM
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
169

I would do the following, but doesn't really matter that much :-)

if (!V)
  return Default;


if (const char *Str = V->getAsCString())
  return Str;

return Default;
llvm/tools/dsymutil/DwarfLinker.h
497

Makes sense with the comment.

llvm/tools/dsymutil/dsymutil.cpp
290

Since the resource dir is always empty, maybe make it a default argument in the ctor?

aprantl marked an inline comment as done.Apr 22 2019, 9:35 AM
aprantl added inline comments.
llvm/tools/dsymutil/DwarfLinker.cpp
294

I just experimented with that, but then we need to pass the DebugMapObject around, which isn't much nicer than a reportWarning function. The static function has the advantage of making explicit what is being modified.

aprantl updated this revision to Diff 196084.Apr 22 2019, 9:35 AM

Add a comment to the map.

aprantl marked an inline comment as done.Apr 22 2019, 9:36 AM
aprantl added inline comments.
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
169

Seems like this is longer and not any easier to read, IMHO.

JDevlieghere accepted this revision.Apr 22 2019, 2:24 PM
This revision is now accepted and ready to land.Apr 22 2019, 2:24 PM
JDevlieghere closed this revision.Apr 26 2019, 2:09 PM

This was committed in rL358921