[LLVMdev] [llvm-dev] DwarfDebug craziness
Josh Matthews
josh at joshmatthews.net
Sun Dec 18 22:43:10 PST 2011
>From DwarfDebug.cpp:
>/// GetOrCreateSourceID - Look up the source id with the given directory and
>/// source file names. If none currently exists, create a new id and insert it
>/// in the SourceIds map. This can update DirectoryNames and SourceFileNames
>/// maps as well.
>unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName,
> StringRef DirName) {
> // If FE did not provide a file name, then assume stdin.
> if (FileName.empty())
> return GetOrCreateSourceID("<stdin>", StringRef());
>
> // TODO: this might not belong here. See if we can factor this better.
> if (DirName == CompilationDir)
> DirName = "";
The last snippet weirds me out and breaks Rust debug information
generation. Specifically, when creating a new compile unit, we see
this:
>CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {
> DICompileUnit DIUnit(N);
> StringRef FN = DIUnit.getFilename();
> CompilationDir = DIUnit.getDirectory();
> unsigned ID = GetOrCreateSourceID(FN, CompilationDir);
Note how CompilationDir is passed to GetOrCreateSourceID as DirName?
That means that the map of compilation units is created entirely based
on file names excluding the path, so two compilation units that happen
to share a name generate identical source IDs and then attempt to
generate duplicate symbols for labels. For a temporary workaround
locally I've deleted the check in GetOrCreateSourceID, but I have no
idea if that has other negative consequences. Can someone who
understands what's going on here comment?
Cheers,
Josh
More information about the llvm-dev
mailing list