Skip to content

Commit 52ed679

Browse files
authored
Revert "LLVM symbolizer gsym support" (#139660)
Reverts #134847
1 parent 5fb742a commit 52ed679

File tree

13 files changed

+24
-410
lines changed

13 files changed

+24
-410
lines changed

llvm/include/llvm/DebugInfo/DIContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ struct DIDumpOptions {
238238

239239
class DIContext {
240240
public:
241-
enum DIContextKind { CK_DWARF, CK_PDB, CK_BTF, CK_GSYM };
241+
enum DIContextKind { CK_DWARF, CK_PDB, CK_BTF };
242242

243243
DIContext(DIContextKind K) : Kind(K) {}
244244
virtual ~DIContext() = default;

llvm/include/llvm/DebugInfo/GSYM/GsymDIContext.h

Lines changed: 0 additions & 66 deletions
This file was deleted.

llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ class LLVMSymbolizer {
5858
bool RelativeAddresses = false;
5959
bool UntagAddresses = false;
6060
bool UseDIA = false;
61-
bool DisableGsym = false;
6261
std::string DefaultArch;
6362
std::vector<std::string> DsymHints;
6463
std::string FallbackDebugPath;
6564
std::string DWPName;
6665
std::vector<std::string> DebugFileDirectory;
67-
std::vector<std::string> GsymFileDirectory;
6866
size_t MaxCacheSize =
6967
sizeof(size_t) == 4
7068
? 512 * 1024 * 1024 /* 512 MiB */
@@ -179,7 +177,6 @@ class LLVMSymbolizer {
179177
ObjectFile *lookUpBuildIDObject(const std::string &Path,
180178
const ELFObjectFileBase *Obj,
181179
const std::string &ArchName);
182-
std::string lookUpGsymFile(const std::string &Path);
183180

184181
bool findDebugBinary(const std::string &OrigPath,
185182
const std::string &DebuglinkName, uint32_t CRCHash,

llvm/lib/DebugInfo/GSYM/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ add_llvm_component_library(LLVMDebugInfoGSYM
44
FileWriter.cpp
55
FunctionInfo.cpp
66
GsymCreator.cpp
7-
GsymDIContext.cpp
87
GsymReader.cpp
98
InlineInfo.cpp
109
LineTable.cpp

llvm/lib/DebugInfo/GSYM/GsymDIContext.cpp

Lines changed: 0 additions & 166 deletions
This file was deleted.

llvm/lib/DebugInfo/Symbolize/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ add_llvm_component_library(LLVMSymbolize
1010

1111
LINK_COMPONENTS
1212
DebugInfoDWARF
13-
DebugInfoGSYM
1413
DebugInfoPDB
1514
DebugInfoBTF
1615
Object

llvm/lib/DebugInfo/Symbolize/Symbolize.cpp

Lines changed: 23 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include "llvm/ADT/STLExtras.h"
1616
#include "llvm/DebugInfo/BTF/BTFContext.h"
1717
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
18-
#include "llvm/DebugInfo/GSYM/GsymDIContext.h"
19-
#include "llvm/DebugInfo/GSYM/GsymReader.h"
2018
#include "llvm/DebugInfo/PDB/PDB.h"
2119
#include "llvm/DebugInfo/PDB/PDBContext.h"
2220
#include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
@@ -500,34 +498,6 @@ bool LLVMSymbolizer::getOrFindDebugBinary(const ArrayRef<uint8_t> BuildID,
500498
return false;
501499
}
502500

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-
531501
Expected<LLVMSymbolizer::ObjectPair>
532502
LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
533503
const std::string &ArchName) {
@@ -664,48 +634,30 @@ LLVMSymbolizer::getOrCreateModuleInfo(StringRef ModuleName) {
664634
std::unique_ptr<DIContext> Context;
665635
// If this is a COFF object containing PDB info and not containing DWARF
666636
// 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));
708659
}
660+
Context.reset(new PDBContext(*CoffObject, std::move(Session)));
709661
}
710662
}
711663
if (!Context)
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)