// symbol table to find its address as it might not be in the
// debug map (for common symbols).
Value = getMainBinarySymbolAddress(Name);
- if (Value == UnknownAddressOrSize)
- return;
break;
case MachO::N_FUN:
// Functions are scopes in STABS. They have an end marker that
CurrentObjectAddresses.clear();
for (auto Sym : CurrentObjectHolder.Get().symbols()) {
- StringRef Name;
- uint64_t Addr;
- if (Sym.getAddress(Addr) || Addr == UnknownAddressOrSize ||
- Sym.getName(Name))
+ uint64_t Addr = Sym.getValue();
+ ErrorOr<StringRef> Name = Sym.getName();
+ if (!Name)
continue;
- CurrentObjectAddresses[Name] = Addr;
+ CurrentObjectAddresses[*Name] = Addr;
}
}
uint64_t MachODebugMapParser::getMainBinarySymbolAddress(StringRef Name) {
auto Sym = MainBinarySymbolAddresses.find(Name);
if (Sym == MainBinarySymbolAddresses.end())
- return UnknownAddressOrSize;
+ return 0;
return Sym->second;
}
const MachOObjectFile &MainBinary = MainBinaryHolder.GetAs<MachOObjectFile>();
section_iterator Section = MainBinary.section_end();
for (const auto &Sym : MainBinary.symbols()) {
- SymbolRef::Type Type;
+ SymbolRef::Type Type = Sym.getType();
// Skip undefined and STAB entries.
- if (Sym.getType(Type) || (Type & SymbolRef::ST_Debug) ||
- (Type & SymbolRef::ST_Unknown))
+ if ((Type & SymbolRef::ST_Debug) || (Type & SymbolRef::ST_Unknown))
continue;
- StringRef Name;
- uint64_t Addr;
// The only symbols of interest are the global variables. These
// are the only ones that need to be queried because the address
// of common data won't be described in the debug map. All other
// addresses should be fetched for the debug map.
- if (Sym.getAddress(Addr) || Addr == UnknownAddressOrSize ||
- !(Sym.getFlags() & SymbolRef::SF_Global) || Sym.getSection(Section) ||
- Section->isText() || Sym.getName(Name) || Name.size() == 0 ||
- Name[0] == '\0')
+ if (!(Sym.getFlags() & SymbolRef::SF_Global) || Sym.getSection(Section) ||
+ Section == MainBinary.section_end() || Section->isText())
+ continue;
+ uint64_t Addr = Sym.getValue();
+ ErrorOr<StringRef> NameOrErr = Sym.getName();
+ if (!NameOrErr)
+ continue;
+ StringRef Name = *NameOrErr;
+ if (Name.size() == 0 || Name[0] == '\0')
continue;
MainBinarySymbolAddresses[Name] = Addr;
}
}
-ErrorOr<std::unique_ptr<DebugMap>>
-parseYAMLDebugMap(StringRef InputFile, StringRef PrependPath, bool Verbose) {
- auto ErrOrFile = MemoryBuffer::getFileOrSTDIN(InputFile);
- if (auto Err =ErrOrFile.getError())
- return Err;
-
- std::unique_ptr<DebugMap> Res;
- yaml::Input yin((*ErrOrFile)->getBuffer(), &PrependPath);
- yin >> Res;
-
- if (auto EC = yin.error())
- return EC;
-
- return std::move(Res);
-}
-
namespace llvm {
namespace dsymutil {
-llvm::ErrorOr<std::unique_ptr<DebugMap>>
-parseDebugMap(StringRef InputFile, StringRef PrependPath, bool Verbose, bool InputIsYAML) {
+llvm::ErrorOr<std::unique_ptr<DebugMap>> parseDebugMap(StringRef InputFile,
+ StringRef PrependPath,
+ bool Verbose,
+ bool InputIsYAML) {
if (!InputIsYAML) {
MachODebugMapParser Parser(InputFile, PrependPath, Verbose);
return Parser.parse();
} else {
- return parseYAMLDebugMap(InputFile, PrependPath, Verbose);
+ return DebugMap::parseYAMLDebugMap(InputFile, PrependPath, Verbose);
}
}
}