|
15 | 15 | #include "llvm/ADT/STLExtras.h"
|
16 | 16 | #include "llvm/DebugInfo/BTF/BTFContext.h"
|
17 | 17 | #include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
18 |
| -#include "llvm/DebugInfo/GSYM/GsymDIContext.h" |
19 |
| -#include "llvm/DebugInfo/GSYM/GsymReader.h" |
20 | 18 | #include "llvm/DebugInfo/PDB/PDB.h"
|
21 | 19 | #include "llvm/DebugInfo/PDB/PDBContext.h"
|
22 | 20 | #include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
|
@@ -500,34 +498,6 @@ bool LLVMSymbolizer::getOrFindDebugBinary(const ArrayRef<uint8_t> BuildID,
|
500 | 498 | return false;
|
501 | 499 | }
|
502 | 500 |
|
503 |
| -std::string LLVMSymbolizer::lookUpGsymFile(const std::string &Path) { |
504 |
| - if (Opts.DisableGsym) |
505 |
| - return {}; |
506 |
| - |
507 |
| - auto CheckGsymFile = [](const llvm::StringRef &GsymPath) { |
508 |
| - sys::fs::file_status Status; |
509 |
| - std::error_code EC = llvm::sys::fs::status(GsymPath, Status); |
510 |
| - return !EC && !llvm::sys::fs::is_directory(Status); |
511 |
| - }; |
512 |
| - |
513 |
| - // First, look beside the binary file |
514 |
| - if (const auto GsymPath = Path + ".gsym"; CheckGsymFile(GsymPath)) |
515 |
| - return GsymPath; |
516 |
| - |
517 |
| - // Then, look in the directories specified by GsymFileDirectory |
518 |
| - |
519 |
| - for (const auto &Directory : Opts.GsymFileDirectory) { |
520 |
| - SmallString<16> GsymPath = llvm::StringRef{Directory}; |
521 |
| - llvm::sys::path::append(GsymPath, |
522 |
| - llvm::sys::path::filename(Path) + ".gsym"); |
523 |
| - |
524 |
| - if (CheckGsymFile(GsymPath)) |
525 |
| - return static_cast<std::string>(GsymPath); |
526 |
| - } |
527 |
| - |
528 |
| - return {}; |
529 |
| -} |
530 |
| - |
531 | 501 | Expected<LLVMSymbolizer::ObjectPair>
|
532 | 502 | LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
|
533 | 503 | const std::string &ArchName) {
|
@@ -664,48 +634,30 @@ LLVMSymbolizer::getOrCreateModuleInfo(StringRef ModuleName) {
|
664 | 634 | std::unique_ptr<DIContext> Context;
|
665 | 635 | // If this is a COFF object containing PDB info and not containing DWARF
|
666 | 636 | // section, use a PDBContext to symbolize. Otherwise, use DWARF.
|
667 |
| - // Create a DIContext to symbolize as follows: |
668 |
| - // - If there is a GSYM file, create a GsymDIContext. |
669 |
| - // - Otherwise, if this is a COFF object containing PDB info, create a |
670 |
| - // PDBContext. |
671 |
| - // - Otherwise, create a DWARFContext. |
672 |
| - const auto GsymFile = lookUpGsymFile(BinaryName.str()); |
673 |
| - if (!GsymFile.empty()) { |
674 |
| - auto ReaderOrErr = gsym::GsymReader::openFile(GsymFile); |
675 |
| - |
676 |
| - if (ReaderOrErr) { |
677 |
| - std::unique_ptr<gsym::GsymReader> Reader = |
678 |
| - std::make_unique<gsym::GsymReader>(std::move(*ReaderOrErr)); |
679 |
| - |
680 |
| - Context = std::make_unique<gsym::GsymDIContext>(std::move(Reader)); |
681 |
| - } |
682 |
| - } |
683 |
| - if (!Context) { |
684 |
| - if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) { |
685 |
| - const codeview::DebugInfo *DebugInfo; |
686 |
| - StringRef PDBFileName; |
687 |
| - auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName); |
688 |
| - // Use DWARF if there're DWARF sections. |
689 |
| - bool HasDwarf = llvm::any_of( |
690 |
| - Objects.first->sections(), [](SectionRef Section) -> bool { |
691 |
| - if (Expected<StringRef> SectionName = Section.getName()) |
692 |
| - return SectionName.get() == ".debug_info"; |
693 |
| - return false; |
694 |
| - }); |
695 |
| - if (!EC && !HasDwarf && DebugInfo != nullptr && !PDBFileName.empty()) { |
696 |
| - using namespace pdb; |
697 |
| - std::unique_ptr<IPDBSession> Session; |
698 |
| - |
699 |
| - PDB_ReaderType ReaderType = |
700 |
| - Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native; |
701 |
| - if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(), |
702 |
| - Session)) { |
703 |
| - Modules.emplace(ModuleName, std::unique_ptr<SymbolizableModule>()); |
704 |
| - // Return along the PDB filename to provide more context |
705 |
| - return createFileError(PDBFileName, std::move(Err)); |
706 |
| - } |
707 |
| - Context.reset(new PDBContext(*CoffObject, std::move(Session))); |
| 637 | + if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) { |
| 638 | + const codeview::DebugInfo *DebugInfo; |
| 639 | + StringRef PDBFileName; |
| 640 | + auto EC = CoffObject->getDebugPDBInfo(DebugInfo, PDBFileName); |
| 641 | + // Use DWARF if there're DWARF sections. |
| 642 | + bool HasDwarf = |
| 643 | + llvm::any_of(Objects.first->sections(), [](SectionRef Section) -> bool { |
| 644 | + if (Expected<StringRef> SectionName = Section.getName()) |
| 645 | + return SectionName.get() == ".debug_info"; |
| 646 | + return false; |
| 647 | + }); |
| 648 | + if (!EC && !HasDwarf && DebugInfo != nullptr && !PDBFileName.empty()) { |
| 649 | + using namespace pdb; |
| 650 | + std::unique_ptr<IPDBSession> Session; |
| 651 | + |
| 652 | + PDB_ReaderType ReaderType = |
| 653 | + Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native; |
| 654 | + if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(), |
| 655 | + Session)) { |
| 656 | + Modules.emplace(ModuleName, std::unique_ptr<SymbolizableModule>()); |
| 657 | + // Return along the PDB filename to provide more context |
| 658 | + return createFileError(PDBFileName, std::move(Err)); |
708 | 659 | }
|
| 660 | + Context.reset(new PDBContext(*CoffObject, std::move(Session))); |
709 | 661 | }
|
710 | 662 | }
|
711 | 663 | if (!Context)
|
|
0 commit comments