mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[dsymutil] Replace TimeValue with TimePoint
Summary: All changes are pretty straight-forward. I chose to use TimePoints with second precision, as that is all that seems to be required here. Reviewers: friss, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25908 llvm-svn: 286358
This commit is contained in:
parent
02566c439c
commit
9a5b62fab8
@ -41,9 +41,8 @@ void BinaryHolder::changeBackingMemoryBuffer(
|
|||||||
CurrentMemoryBuffer = std::move(Buf);
|
CurrentMemoryBuffer = std::move(Buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>> BinaryHolder::GetMemoryBuffersForFile(
|
||||||
BinaryHolder::GetMemoryBuffersForFile(StringRef Filename,
|
StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
sys::TimeValue Timestamp) {
|
|
||||||
if (Verbose)
|
if (Verbose)
|
||||||
outs() << "trying to open '" << Filename << "'\n";
|
outs() << "trying to open '" << Filename << "'\n";
|
||||||
|
|
||||||
@ -85,9 +84,8 @@ BinaryHolder::GetMemoryBuffersForFile(StringRef Filename,
|
|||||||
*CurrentFatBinary);
|
*CurrentFatBinary);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>> BinaryHolder::GetArchiveMemberBuffers(
|
||||||
BinaryHolder::GetArchiveMemberBuffers(StringRef Filename,
|
StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
sys::TimeValue Timestamp) {
|
|
||||||
if (CurrentArchives.empty())
|
if (CurrentArchives.empty())
|
||||||
return make_error_code(errc::no_such_file_or_directory);
|
return make_error_code(errc::no_such_file_or_directory);
|
||||||
|
|
||||||
@ -106,10 +104,10 @@ BinaryHolder::GetArchiveMemberBuffers(StringRef Filename,
|
|||||||
for (auto Child : CurrentArchive->children(Err)) {
|
for (auto Child : CurrentArchive->children(Err)) {
|
||||||
if (auto NameOrErr = Child.getName()) {
|
if (auto NameOrErr = Child.getName()) {
|
||||||
if (*NameOrErr == Filename) {
|
if (*NameOrErr == Filename) {
|
||||||
Expected<sys::TimeValue> ModTimeOrErr = Child.getLastModified();
|
auto ModTimeOrErr = Child.getLastModified();
|
||||||
if (!ModTimeOrErr)
|
if (!ModTimeOrErr)
|
||||||
return errorToErrorCode(ModTimeOrErr.takeError());
|
return errorToErrorCode(ModTimeOrErr.takeError());
|
||||||
if (Timestamp != sys::TimeValue::PosixZeroTime() &&
|
if (Timestamp != sys::TimePoint<>() &&
|
||||||
Timestamp != ModTimeOrErr.get()) {
|
Timestamp != ModTimeOrErr.get()) {
|
||||||
if (Verbose)
|
if (Verbose)
|
||||||
outs() << "\tmember had timestamp mismatch.\n";
|
outs() << "\tmember had timestamp mismatch.\n";
|
||||||
@ -134,8 +132,8 @@ BinaryHolder::GetArchiveMemberBuffers(StringRef Filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>>
|
||||||
BinaryHolder::MapArchiveAndGetMemberBuffers(StringRef Filename,
|
BinaryHolder::MapArchiveAndGetMemberBuffers(
|
||||||
sys::TimeValue Timestamp) {
|
StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
StringRef ArchiveFilename = Filename.substr(0, Filename.find('('));
|
StringRef ArchiveFilename = Filename.substr(0, Filename.find('('));
|
||||||
|
|
||||||
auto ErrOrBuff = MemoryBuffer::getFileOrSTDIN(ArchiveFilename);
|
auto ErrOrBuff = MemoryBuffer::getFileOrSTDIN(ArchiveFilename);
|
||||||
@ -183,7 +181,8 @@ BinaryHolder::getObjfileForArch(const Triple &T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<const object::ObjectFile *>>
|
ErrorOr<std::vector<const object::ObjectFile *>>
|
||||||
BinaryHolder::GetObjectFiles(StringRef Filename, sys::TimeValue Timestamp) {
|
BinaryHolder::GetObjectFiles(StringRef Filename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
auto ErrOrMemBufferRefs = GetMemoryBuffersForFile(Filename, Timestamp);
|
auto ErrOrMemBufferRefs = GetMemoryBuffersForFile(Filename, Timestamp);
|
||||||
if (auto Err = ErrOrMemBufferRefs.getError())
|
if (auto Err = ErrOrMemBufferRefs.getError())
|
||||||
return Err;
|
return Err;
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#include "llvm/Object/Error.h"
|
#include "llvm/Object/Error.h"
|
||||||
#include "llvm/Object/MachOUniversal.h"
|
#include "llvm/Object/MachOUniversal.h"
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
|
#include "llvm/Support/Chrono.h"
|
||||||
#include "llvm/Support/Errc.h"
|
#include "llvm/Support/Errc.h"
|
||||||
#include "llvm/Support/ErrorOr.h"
|
#include "llvm/Support/ErrorOr.h"
|
||||||
#include "llvm/Support/TimeValue.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace dsymutil {
|
namespace dsymutil {
|
||||||
@ -54,7 +54,8 @@ class BinaryHolder {
|
|||||||
/// potential match for the given \p Filename in the currently
|
/// potential match for the given \p Filename in the currently
|
||||||
/// mapped archive if there is one.
|
/// mapped archive if there is one.
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>>
|
||||||
GetArchiveMemberBuffers(StringRef Filename, sys::TimeValue Timestamp);
|
GetArchiveMemberBuffers(StringRef Filename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
|
|
||||||
/// Interpret Filename as an archive member specification map the
|
/// Interpret Filename as an archive member specification map the
|
||||||
/// corresponding archive to memory and return the MemoryBufferRefs
|
/// corresponding archive to memory and return the MemoryBufferRefs
|
||||||
@ -62,7 +63,8 @@ class BinaryHolder {
|
|||||||
/// returned when there are multiple architectures available for the
|
/// returned when there are multiple architectures available for the
|
||||||
/// requested file.
|
/// requested file.
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>>
|
||||||
MapArchiveAndGetMemberBuffers(StringRef Filename, sys::TimeValue Timestamp);
|
MapArchiveAndGetMemberBuffers(StringRef Filename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
|
|
||||||
/// Return the MemoryBufferRef that holds the memory mapping for the
|
/// Return the MemoryBufferRef that holds the memory mapping for the
|
||||||
/// given \p Filename. This function will try to parse archive
|
/// given \p Filename. This function will try to parse archive
|
||||||
@ -74,7 +76,8 @@ class BinaryHolder {
|
|||||||
/// Multiple buffers are returned when there are multiple
|
/// Multiple buffers are returned when there are multiple
|
||||||
/// architectures available for the requested file.
|
/// architectures available for the requested file.
|
||||||
ErrorOr<std::vector<MemoryBufferRef>>
|
ErrorOr<std::vector<MemoryBufferRef>>
|
||||||
GetMemoryBuffersForFile(StringRef Filename, sys::TimeValue Timestamp);
|
GetMemoryBuffersForFile(StringRef Filename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
|
|
||||||
void changeBackingMemoryBuffer(std::unique_ptr<MemoryBuffer> &&MemBuf);
|
void changeBackingMemoryBuffer(std::unique_ptr<MemoryBuffer> &&MemBuf);
|
||||||
ErrorOr<const object::ObjectFile &> getObjfileForArch(const Triple &T);
|
ErrorOr<const object::ObjectFile &> getObjfileForArch(const Triple &T);
|
||||||
@ -91,13 +94,15 @@ public:
|
|||||||
/// multiple architectures available for the requested file.
|
/// multiple architectures available for the requested file.
|
||||||
ErrorOr<std::vector<const object::ObjectFile *>>
|
ErrorOr<std::vector<const object::ObjectFile *>>
|
||||||
GetObjectFiles(StringRef Filename,
|
GetObjectFiles(StringRef Filename,
|
||||||
sys::TimeValue Timestamp = sys::TimeValue::PosixZeroTime());
|
sys::TimePoint<std::chrono::seconds> Timestamp =
|
||||||
|
sys::TimePoint<std::chrono::seconds>());
|
||||||
|
|
||||||
/// Wraps GetObjectFiles() to return a derived ObjectFile type.
|
/// Wraps GetObjectFiles() to return a derived ObjectFile type.
|
||||||
template <typename ObjectFileType>
|
template <typename ObjectFileType>
|
||||||
ErrorOr<std::vector<const ObjectFileType *>>
|
ErrorOr<std::vector<const ObjectFileType *>>
|
||||||
GetFilesAs(StringRef Filename,
|
GetFilesAs(StringRef Filename,
|
||||||
sys::TimeValue Timestamp = sys::TimeValue::PosixZeroTime()) {
|
sys::TimePoint<std::chrono::seconds> Timestamp =
|
||||||
|
sys::TimePoint<std::chrono::seconds>()) {
|
||||||
auto ErrOrObjFile = GetObjectFiles(Filename, Timestamp);
|
auto ErrOrObjFile = GetObjectFiles(Filename, Timestamp);
|
||||||
if (auto Err = ErrOrObjFile.getError())
|
if (auto Err = ErrOrObjFile.getError())
|
||||||
return Err;
|
return Err;
|
||||||
|
@ -21,7 +21,7 @@ namespace dsymutil {
|
|||||||
using namespace llvm::object;
|
using namespace llvm::object;
|
||||||
|
|
||||||
DebugMapObject::DebugMapObject(StringRef ObjectFilename,
|
DebugMapObject::DebugMapObject(StringRef ObjectFilename,
|
||||||
sys::TimeValue Timestamp)
|
sys::TimePoint<std::chrono::seconds> Timestamp)
|
||||||
: Filename(ObjectFilename), Timestamp(Timestamp) {}
|
: Filename(ObjectFilename), Timestamp(Timestamp) {}
|
||||||
|
|
||||||
bool DebugMapObject::addSymbol(StringRef Name, Optional<uint64_t> ObjectAddress,
|
bool DebugMapObject::addSymbol(StringRef Name, Optional<uint64_t> ObjectAddress,
|
||||||
@ -62,8 +62,9 @@ void DebugMapObject::print(raw_ostream &OS) const {
|
|||||||
void DebugMapObject::dump() const { print(errs()); }
|
void DebugMapObject::dump() const { print(errs()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DebugMapObject &DebugMap::addDebugMapObject(StringRef ObjectFilePath,
|
DebugMapObject &
|
||||||
sys::TimeValue Timestamp) {
|
DebugMap::addDebugMapObject(StringRef ObjectFilePath,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
Objects.emplace_back(new DebugMapObject(ObjectFilePath, Timestamp));
|
Objects.emplace_back(new DebugMapObject(ObjectFilePath, Timestamp));
|
||||||
return *Objects.back();
|
return *Objects.back();
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ struct MappingTraits<dsymutil::DebugMapObject>::YamlDMO {
|
|||||||
dsymutil::DebugMapObject denormalize(IO &IO);
|
dsymutil::DebugMapObject denormalize(IO &IO);
|
||||||
|
|
||||||
std::string Filename;
|
std::string Filename;
|
||||||
sys::TimeValue::SecondsType Timestamp;
|
int64_t Timestamp;
|
||||||
std::vector<dsymutil::DebugMapObject::YAMLSymbolMapping> Entries;
|
std::vector<dsymutil::DebugMapObject::YAMLSymbolMapping> Entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ void MappingTraits<std::unique_ptr<dsymutil::DebugMap>>::mapping(
|
|||||||
MappingTraits<dsymutil::DebugMapObject>::YamlDMO::YamlDMO(
|
MappingTraits<dsymutil::DebugMapObject>::YamlDMO::YamlDMO(
|
||||||
IO &io, dsymutil::DebugMapObject &Obj) {
|
IO &io, dsymutil::DebugMapObject &Obj) {
|
||||||
Filename = Obj.Filename;
|
Filename = Obj.Filename;
|
||||||
Timestamp = Obj.getTimestamp().toEpochTime();
|
Timestamp = sys::toTimeT(Obj.getTimestamp());
|
||||||
Entries.reserve(Obj.Symbols.size());
|
Entries.reserve(Obj.Symbols.size());
|
||||||
for (auto &Entry : Obj.Symbols)
|
for (auto &Entry : Obj.Symbols)
|
||||||
Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue()));
|
Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue()));
|
||||||
@ -240,9 +241,7 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sys::TimeValue TV;
|
dsymutil::DebugMapObject Res(Path, sys::toTimePoint(Timestamp));
|
||||||
TV.fromEpochTime(Timestamp);
|
|
||||||
dsymutil::DebugMapObject Res(Path, TV);
|
|
||||||
for (auto &Entry : Entries) {
|
for (auto &Entry : Entries) {
|
||||||
auto &Mapping = Entry.second;
|
auto &Mapping = Entry.second;
|
||||||
Optional<uint64_t> ObjAddress;
|
Optional<uint64_t> ObjAddress;
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/ADT/iterator_range.h"
|
#include "llvm/ADT/iterator_range.h"
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
|
#include "llvm/Support/Chrono.h"
|
||||||
#include "llvm/Support/ErrorOr.h"
|
#include "llvm/Support/ErrorOr.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/TimeValue.h"
|
|
||||||
#include "llvm/Support/YAMLTraits.h"
|
#include "llvm/Support/YAMLTraits.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -92,8 +92,9 @@ public:
|
|||||||
|
|
||||||
/// This function adds an DebugMapObject to the list owned by this
|
/// This function adds an DebugMapObject to the list owned by this
|
||||||
/// debug map.
|
/// debug map.
|
||||||
DebugMapObject &addDebugMapObject(StringRef ObjectFilePath,
|
DebugMapObject &
|
||||||
sys::TimeValue Timestamp);
|
addDebugMapObject(StringRef ObjectFilePath,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
|
|
||||||
const Triple &getTriple() const { return BinaryTriple; }
|
const Triple &getTriple() const { return BinaryTriple; }
|
||||||
|
|
||||||
@ -149,7 +150,9 @@ public:
|
|||||||
|
|
||||||
llvm::StringRef getObjectFilename() const { return Filename; }
|
llvm::StringRef getObjectFilename() const { return Filename; }
|
||||||
|
|
||||||
sys::TimeValue getTimestamp() const { return Timestamp; }
|
sys::TimePoint<std::chrono::seconds> getTimestamp() const {
|
||||||
|
return Timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
iterator_range<StringMap<SymbolMapping>::const_iterator> symbols() const {
|
iterator_range<StringMap<SymbolMapping>::const_iterator> symbols() const {
|
||||||
return make_range(Symbols.begin(), Symbols.end());
|
return make_range(Symbols.begin(), Symbols.end());
|
||||||
@ -162,10 +165,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class DebugMap;
|
friend class DebugMap;
|
||||||
/// DebugMapObjects can only be constructed by the owning DebugMap.
|
/// DebugMapObjects can only be constructed by the owning DebugMap.
|
||||||
DebugMapObject(StringRef ObjectFilename, sys::TimeValue Timestamp);
|
DebugMapObject(StringRef ObjectFilename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
|
|
||||||
std::string Filename;
|
std::string Filename;
|
||||||
sys::TimeValue Timestamp;
|
sys::TimePoint<std::chrono::seconds> Timestamp;
|
||||||
StringMap<SymbolMapping> Symbols;
|
StringMap<SymbolMapping> Symbols;
|
||||||
DenseMap<uint64_t, DebugMapEntry *> AddressToMapping;
|
DenseMap<uint64_t, DebugMapEntry *> AddressToMapping;
|
||||||
|
|
||||||
|
@ -3294,7 +3294,7 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
|
|||||||
sys::path::append(Path, Filename);
|
sys::path::append(Path, Filename);
|
||||||
BinaryHolder ObjHolder(Options.Verbose);
|
BinaryHolder ObjHolder(Options.Verbose);
|
||||||
auto &Obj =
|
auto &Obj =
|
||||||
ModuleMap.addDebugMapObject(Path, sys::TimeValue::PosixZeroTime());
|
ModuleMap.addDebugMapObject(Path, sys::TimePoint<std::chrono::seconds>());
|
||||||
auto ErrOrObj = loadObject(ObjHolder, Obj, ModuleMap);
|
auto ErrOrObj = loadObject(ObjHolder, Obj, ModuleMap);
|
||||||
if (!ErrOrObj) {
|
if (!ErrOrObj) {
|
||||||
// Try and emit more helpful warnings by applying some heuristics.
|
// Try and emit more helpful warnings by applying some heuristics.
|
||||||
|
@ -65,7 +65,9 @@ private:
|
|||||||
std::unique_ptr<DebugMap> parseOneBinary(const MachOObjectFile &MainBinary,
|
std::unique_ptr<DebugMap> parseOneBinary(const MachOObjectFile &MainBinary,
|
||||||
StringRef BinaryPath);
|
StringRef BinaryPath);
|
||||||
|
|
||||||
void switchToNewDebugMapObject(StringRef Filename, sys::TimeValue Timestamp);
|
void
|
||||||
|
switchToNewDebugMapObject(StringRef Filename,
|
||||||
|
sys::TimePoint<std::chrono::seconds> Timestamp);
|
||||||
void resetParserState();
|
void resetParserState();
|
||||||
uint64_t getMainBinarySymbolAddress(StringRef Name);
|
uint64_t getMainBinarySymbolAddress(StringRef Name);
|
||||||
void loadMainBinarySymbols(const MachOObjectFile &MainBinary);
|
void loadMainBinarySymbols(const MachOObjectFile &MainBinary);
|
||||||
@ -110,8 +112,8 @@ void MachODebugMapParser::resetParserState() {
|
|||||||
/// Create a new DebugMapObject. This function resets the state of the
|
/// Create a new DebugMapObject. This function resets the state of the
|
||||||
/// parser that was referring to the last object file and sets
|
/// parser that was referring to the last object file and sets
|
||||||
/// everything up to add symbols to the new one.
|
/// everything up to add symbols to the new one.
|
||||||
void MachODebugMapParser::switchToNewDebugMapObject(StringRef Filename,
|
void MachODebugMapParser::switchToNewDebugMapObject(
|
||||||
sys::TimeValue Timestamp) {
|
StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
|
||||||
resetParserState();
|
resetParserState();
|
||||||
|
|
||||||
SmallString<80> Path(PathPrefix);
|
SmallString<80> Path(PathPrefix);
|
||||||
@ -343,11 +345,8 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
|
|||||||
const char *Name = &MainBinaryStrings.data()[StringIndex];
|
const char *Name = &MainBinaryStrings.data()[StringIndex];
|
||||||
|
|
||||||
// An N_OSO entry represents the start of a new object file description.
|
// An N_OSO entry represents the start of a new object file description.
|
||||||
if (Type == MachO::N_OSO) {
|
if (Type == MachO::N_OSO)
|
||||||
sys::TimeValue Timestamp;
|
return switchToNewDebugMapObject(Name, sys::toTimePoint(Value));
|
||||||
Timestamp.fromEpochTime(Value);
|
|
||||||
return switchToNewDebugMapObject(Name, Timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the last N_OSO object file wasn't found,
|
// If the last N_OSO object file wasn't found,
|
||||||
// CurrentDebugMapObject will be null. Do not update anything
|
// CurrentDebugMapObject will be null. Do not update anything
|
||||||
|
Loading…
Reference in New Issue
Block a user