diff options
Diffstat (limited to 'lib/Analysis/ModuleDebugInfoPrinter.cpp')
| -rw-r--r-- | lib/Analysis/ModuleDebugInfoPrinter.cpp | 68 | 
1 files changed, 56 insertions, 12 deletions
| diff --git a/lib/Analysis/ModuleDebugInfoPrinter.cpp b/lib/Analysis/ModuleDebugInfoPrinter.cpp index f645558bd814..36c47141a45f 100644 --- a/lib/Analysis/ModuleDebugInfoPrinter.cpp +++ b/lib/Analysis/ModuleDebugInfoPrinter.cpp @@ -55,28 +55,72 @@ bool ModuleDebugInfoPrinter::runOnModule(Module &M) {    return false;  } +static void printFile(raw_ostream &O, StringRef Filename, StringRef Directory, +                      unsigned Line = 0) { +  if (Filename.empty()) +    return; + +  O << " from "; +  if (!Directory.empty()) +    O << Directory << "/"; +  O << Filename; +  if (Line) +    O << ":" << Line; +} +  void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const { -  for (DICompileUnit CU : Finder.compile_units()) { -    O << "Compile Unit: "; -    CU.print(O); +  // Printing the nodes directly isn't particularly helpful (since they +  // reference other nodes that won't be printed, particularly for the +  // filenames), so just print a few useful things. +  for (DICompileUnit *CU : Finder.compile_units()) { +    O << "Compile unit: "; +    if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage())) +      O << Lang; +    else +      O << "unknown-language(" << CU->getSourceLanguage() << ")"; +    printFile(O, CU->getFilename(), CU->getDirectory());      O << '\n';    } -  for (DISubprogram S : Finder.subprograms()) { -    O << "Subprogram: "; -    S.print(O); +  for (DISubprogram *S : Finder.subprograms()) { +    O << "Subprogram: " << S->getName(); +    printFile(O, S->getFilename(), S->getDirectory(), S->getLine()); +    if (!S->getLinkageName().empty()) +      O << " ('" << S->getLinkageName() << "')";      O << '\n';    } -  for (DIGlobalVariable GV : Finder.global_variables()) { -    O << "GlobalVariable: "; -    GV.print(O); +  for (const DIGlobalVariable *GV : Finder.global_variables()) { +    O << "Global variable: " << GV->getName(); +    printFile(O, GV->getFilename(), GV->getDirectory(), GV->getLine()); +    if (!GV->getLinkageName().empty()) +      O << " ('" << GV->getLinkageName() << "')";      O << '\n';    } -  for (DIType T : Finder.types()) { -    O << "Type: "; -    T.print(O); +  for (const DIType *T : Finder.types()) { +    O << "Type:"; +    if (!T->getName().empty()) +      O << ' ' << T->getName(); +    printFile(O, T->getFilename(), T->getDirectory(), T->getLine()); +    if (auto *BT = dyn_cast<DIBasicType>(T)) { +      O << " "; +      if (const char *Encoding = +              dwarf::AttributeEncodingString(BT->getEncoding())) +        O << Encoding; +      else +        O << "unknown-encoding(" << BT->getEncoding() << ')'; +    } else { +      O << ' '; +      if (const char *Tag = dwarf::TagString(T->getTag())) +        O << Tag; +      else +        O << "unknown-tag(" << T->getTag() << ")"; +    } +    if (auto *CT = dyn_cast<DICompositeType>(T)) { +      if (auto *S = CT->getRawIdentifier()) +        O << " (identifier: '" << S->getString() << "')"; +    }      O << '\n';    }  } | 
