[llvm] 6343526 - Revert "Cleanup the plumbing for DILineInfoSpecifier. [NFC]"

Sterling Augustine via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 17:25:26 PDT 2020


Author: Sterling Augustine
Date: 2020-03-19T17:25:05-07:00
New Revision: 6343526d6400379011504e422b744b5a71903b7d

URL: https://github.com/llvm/llvm-project/commit/6343526d6400379011504e422b744b5a71903b7d
DIFF: https://github.com/llvm/llvm-project/commit/6343526d6400379011504e422b744b5a71903b7d.diff

LOG: Revert "Cleanup the plumbing for DILineInfoSpecifier. [NFC]"

This broke lldb. Will fix and resubmit.

This reverts commit 98ff6eb679cd5a2556d990d3d629e6c03c1da6a0.

Added: 
    

Modified: 
    llvm/include/llvm/DebugInfo/DIContext.h
    llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
    llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
    llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
    llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
    llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
    llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
    llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
    llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
    llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
index 29e62f24b49a..0bad415f6bfd 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -136,11 +136,7 @@ enum class DINameKind { None, ShortName, LinkageName };
 struct DILineInfoSpecifier {
   enum class FileLineInfoKind {
     None,
-    // RawValue is whatever the compiler stored in the filename table.  Could be
-    // a full path, could be something else.
-    RawValue,
-    BaseNameOnly,
-    // Relative to the compilation directory.
+    Default,
     RelativeFilePath,
     AbsoluteFilePath
   };
@@ -149,7 +145,7 @@ struct DILineInfoSpecifier {
   FileLineInfoKind FLIKind;
   FunctionNameKind FNKind;
 
-  DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::RawValue,
+  DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::Default,
                       FunctionNameKind FNKind = FunctionNameKind::None)
       : FLIKind(FLIKind), FNKind(FNKind) {}
 };

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
index 8d4c64915ffd..db7a61a8f160 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H
 #define LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H
 
-#include "llvm/DebugInfo/DIContext.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
@@ -35,6 +34,7 @@ class DIPrinter {
   bool PrintPretty;
   int PrintSourceContext;
   bool Verbose;
+  bool Basenames;
   OutputStyle Style;
 
   void print(const DILineInfo &Info, bool Inlined);
@@ -43,10 +43,11 @@ class DIPrinter {
 public:
   DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true,
             bool PrintPretty = false, int PrintSourceContext = 0,
-            bool Verbose = false, OutputStyle Style = OutputStyle::LLVM)
+            bool Verbose = false, bool Basenames = false,
+            OutputStyle Style = OutputStyle::LLVM)
       : OS(OS), PrintFunctionNames(PrintFunctionNames),
         PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext),
-        Verbose(Verbose), Style(Style) {}
+        Verbose(Verbose), Basenames(Basenames), Style(Style) {}
 
   DIPrinter &operator<<(const DILineInfo &Info);
   DIPrinter &operator<<(const DIInliningInfo &Info);
@@ -57,3 +58,4 @@ class DIPrinter {
 }
 
 #endif
+

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h b/llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
index 51e92b83eadb..506ecc424b4c 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
@@ -25,12 +25,11 @@ class SymbolizableModule {
   virtual ~SymbolizableModule() = default;
 
   virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,
-                                   DILineInfoSpecifier LineInfoSpecifier,
+                                   FunctionNameKind FNKind,
                                    bool UseSymbolTable) const = 0;
   virtual DIInliningInfo
   symbolizeInlinedCode(object::SectionedAddress ModuleOffset,
-                       DILineInfoSpecifier LineInfoSpecifier,
-                       bool UseSymbolTable) const = 0;
+                       FunctionNameKind FNKind, bool UseSymbolTable) const = 0;
   virtual DIGlobal
   symbolizeData(object::SectionedAddress ModuleOffset) const = 0;
   virtual std::vector<DILocal>

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
index b0972ed11581..632540c79b0d 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -32,13 +32,11 @@ namespace symbolize {
 using namespace object;
 
 using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
-using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind;
 
 class LLVMSymbolizer {
 public:
   struct Options {
     FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName;
-    FileLineInfoKind PathStyle = FileLineInfoKind::AbsoluteFilePath;
     bool UseSymbolTable = true;
     bool Demangle = true;
     bool RelativeAddresses = false;

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 3c8fd0da6296..66384745b58d 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1209,15 +1209,11 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
   if (!Name)
     return false;
   StringRef FileName = *Name;
-  if (Kind == FileLineInfoKind::RawValue ||
+  if (Kind == FileLineInfoKind::Default ||
       isPathAbsoluteOnWindowsOrPosix(FileName)) {
     Result = std::string(FileName);
     return true;
   }
-  if (Kind == FileLineInfoKind::BaseNameOnly) {
-    Result = std::string(llvm::sys::path::filename(FileName));
-    return true;
-  }
 
   SmallString<16> FilePath;
   StringRef IncludeDir;

diff  --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
index 10352237763c..223b6630d69d 100644
--- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
@@ -73,6 +73,8 @@ void DIPrinter::print(const DILineInfo &Info, bool Inlined) {
   std::string Filename = Info.FileName;
   if (Filename == DILineInfo::BadString)
     Filename = DILineInfo::Addr2LineBadString;
+  else if (Basenames)
+    Filename = std::string(llvm::sys::path::filename(Filename));
   if (!Verbose) {
     OS << Filename << ":" << Info.Line;
     if (Style == OutputStyle::LLVM)

diff  --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
index 9835fc039f5c..b4d49d9ff958 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
@@ -35,6 +35,12 @@ using namespace llvm;
 using namespace object;
 using namespace symbolize;
 
+static DILineInfoSpecifier
+getDILineInfoSpecifier(FunctionNameKind FNKind) {
+  return DILineInfoSpecifier(
+      DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, FNKind);
+}
+
 ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
 SymbolizableObjectFile::create(const object::ObjectFile *Obj,
                                std::unique_ptr<DIContext> DICtx,
@@ -245,16 +251,16 @@ bool SymbolizableObjectFile::shouldOverrideWithSymbolTable(
 
 DILineInfo
 SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
-                                      DILineInfoSpecifier LineInfoSpecifier,
+                                      FunctionNameKind FNKind,
                                       bool UseSymbolTable) const {
   if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
     ModuleOffset.SectionIndex =
         getModuleSectionIndexForAddress(ModuleOffset.Address);
-  DILineInfo LineInfo =
-      DebugInfoContext->getLineInfoForAddress(ModuleOffset, LineInfoSpecifier);
+  DILineInfo LineInfo = DebugInfoContext->getLineInfoForAddress(
+      ModuleOffset, getDILineInfoSpecifier(FNKind));
 
   // Override function name from symbol table if necessary.
-  if (shouldOverrideWithSymbolTable(LineInfoSpecifier.FNKind, UseSymbolTable)) {
+  if (shouldOverrideWithSymbolTable(FNKind, UseSymbolTable)) {
     std::string FunctionName;
     uint64_t Start, Size;
     if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset.Address,
@@ -266,20 +272,20 @@ SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
 }
 
 DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
-    object::SectionedAddress ModuleOffset,
-    DILineInfoSpecifier LineInfoSpecifier, bool UseSymbolTable) const {
+    object::SectionedAddress ModuleOffset, FunctionNameKind FNKind,
+    bool UseSymbolTable) const {
   if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
     ModuleOffset.SectionIndex =
         getModuleSectionIndexForAddress(ModuleOffset.Address);
   DIInliningInfo InlinedContext = DebugInfoContext->getInliningInfoForAddress(
-      ModuleOffset, LineInfoSpecifier);
+      ModuleOffset, getDILineInfoSpecifier(FNKind));
 
   // Make sure there is at least one frame in context.
   if (InlinedContext.getNumberOfFrames() == 0)
     InlinedContext.addFrame(DILineInfo());
 
   // Override the function name in lower frame with name from symbol table.
-  if (shouldOverrideWithSymbolTable(LineInfoSpecifier.FNKind, UseSymbolTable)) {
+  if (shouldOverrideWithSymbolTable(FNKind, UseSymbolTable)) {
     std::string FunctionName;
     uint64_t Start, Size;
     if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset.Address,

diff  --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
index ee5e7e745674..b5b9793a44d9 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
@@ -35,10 +35,10 @@ class SymbolizableObjectFile : public SymbolizableModule {
          bool UntagAddresses);
 
   DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,
-                           DILineInfoSpecifier LineInfoSpecifier,
+                           FunctionNameKind FNKind,
                            bool UseSymbolTable) const override;
   DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset,
-                                      DILineInfoSpecifier LineInfoSpecifier,
+                                      FunctionNameKind FNKind,
                                       bool UseSymbolTable) const override;
   DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override;
   std::vector<DILocal>

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 768c306dfe38..19a07f94a068 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -51,9 +51,8 @@ LLVMSymbolizer::symbolizeCodeCommon(SymbolizableModule *Info,
   if (Opts.RelativeAddresses)
     ModuleOffset.Address += Info->getModulePreferredBase();
 
-  DILineInfo LineInfo = Info->symbolizeCode(
-      ModuleOffset, DILineInfoSpecifier(Opts.PathStyle, Opts.PrintFunctions),
-      Opts.UseSymbolTable);
+  DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,
+                                            Opts.UseSymbolTable);
   if (Opts.Demangle)
     LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info);
   return LineInfo;
@@ -104,8 +103,7 @@ LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,
     ModuleOffset.Address += Info->getModulePreferredBase();
 
   DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(
-      ModuleOffset, DILineInfoSpecifier(Opts.PathStyle, Opts.PrintFunctions),
-      Opts.UseSymbolTable);
+      ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);
   if (Opts.Demangle) {
     for (int i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {
       auto *Frame = InlinedContext.getMutableFrame(i);

diff  --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 8f4a93fcc25d..96b2b72d8ba1 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -309,9 +309,6 @@ int main(int argc, char **argv) {
   Opts.FallbackDebugPath = ClFallbackDebugPath;
   Opts.DWPName = ClDwpName;
   Opts.DebugFileDirectory = ClDebugFileDirectory;
-  Opts.PathStyle = DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath;
-  if (ClBasenames)
-    Opts.PathStyle = DILineInfoSpecifier::FileLineInfoKind::BaseNameOnly;
 
   for (const auto &hint : ClDsymHint) {
     if (sys::path::extension(hint) == ".dSYM") {
@@ -325,7 +322,7 @@ int main(int argc, char **argv) {
 
   DIPrinter Printer(outs(), ClPrintFunctions != FunctionNameKind::None,
                     ClPrettyPrint, ClPrintSourceContextLines, ClVerbose,
-                    ClOutputStyle);
+                    ClBasenames, ClOutputStyle);
 
   if (ClInputAddresses.empty()) {
     const int kMaxInputStringLength = 1024;

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
index cf2fb5375c5c..2ffad829055c 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -1324,12 +1324,7 @@ TEST_F(DebugLineBasicFixture, PrintPathsProperly) {
   EXPECT_TRUE((*ExpectedLineTable)
                   ->Prologue.getFileNameByIndex(
                       1, CompDir,
-                      DILineInfoSpecifier::FileLineInfoKind::RawValue, Result));
-  EXPECT_TRUE((*ExpectedLineTable)
-                  ->Prologue.getFileNameByIndex(
-                      1, CompDir,
-                      DILineInfoSpecifier::FileLineInfoKind::BaseNameOnly,
-                      Result));
+                      DILineInfoSpecifier::FileLineInfoKind::Default, Result));
   EXPECT_STREQ(Result.c_str(), "b file");
   EXPECT_TRUE((*ExpectedLineTable)
                   ->Prologue.getFileNameByIndex(


        


More information about the llvm-commits mailing list