mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 06:32:09 +00:00
Use unique_ptr to manage ParsedBinariesAndObjects in LLVMSymbolizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206866 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
073440f3d4
commit
f749021c54
@ -207,7 +207,6 @@ std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
|
|||||||
|
|
||||||
void LLVMSymbolizer::flush() {
|
void LLVMSymbolizer::flush() {
|
||||||
DeleteContainerSeconds(Modules);
|
DeleteContainerSeconds(Modules);
|
||||||
DeleteContainerPointers(ParsedBinariesAndObjects);
|
|
||||||
BinaryForPath.clear();
|
BinaryForPath.clear();
|
||||||
ObjectFileForArch.clear();
|
ObjectFileForArch.clear();
|
||||||
}
|
}
|
||||||
@ -305,8 +304,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
|
|||||||
if (!error(BinaryOrErr.getError())) {
|
if (!error(BinaryOrErr.getError())) {
|
||||||
std::unique_ptr<Binary> ParsedBinary(BinaryOrErr.get());
|
std::unique_ptr<Binary> ParsedBinary(BinaryOrErr.get());
|
||||||
// Check if it's a universal binary.
|
// Check if it's a universal binary.
|
||||||
Bin = ParsedBinary.release();
|
Bin = ParsedBinary.get();
|
||||||
ParsedBinariesAndObjects.push_back(Bin);
|
ParsedBinariesAndObjects.push_back(std::move(ParsedBinary));
|
||||||
if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
|
if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
|
||||||
// On Darwin we may find DWARF in separate object file in
|
// On Darwin we may find DWARF in separate object file in
|
||||||
// resource directory.
|
// resource directory.
|
||||||
@ -316,7 +315,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
|
|||||||
error_code EC = BinaryOrErr.getError();
|
error_code EC = BinaryOrErr.getError();
|
||||||
if (EC != errc::no_such_file_or_directory && !error(EC)) {
|
if (EC != errc::no_such_file_or_directory && !error(EC)) {
|
||||||
DbgBin = BinaryOrErr.get();
|
DbgBin = BinaryOrErr.get();
|
||||||
ParsedBinariesAndObjects.push_back(DbgBin);
|
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Try to locate the debug binary using .gnu_debuglink section.
|
// Try to locate the debug binary using .gnu_debuglink section.
|
||||||
@ -329,7 +328,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
|
|||||||
BinaryOrErr = createBinary(DebugBinaryPath);
|
BinaryOrErr = createBinary(DebugBinaryPath);
|
||||||
if (!error(BinaryOrErr.getError())) {
|
if (!error(BinaryOrErr.getError())) {
|
||||||
DbgBin = BinaryOrErr.get();
|
DbgBin = BinaryOrErr.get();
|
||||||
ParsedBinariesAndObjects.push_back(DbgBin);
|
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,8 +352,8 @@ LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName
|
|||||||
return I->second;
|
return I->second;
|
||||||
std::unique_ptr<ObjectFile> ParsedObj;
|
std::unique_ptr<ObjectFile> ParsedObj;
|
||||||
if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
|
if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
|
||||||
Res = ParsedObj.release();
|
Res = ParsedObj.get();
|
||||||
ParsedBinariesAndObjects.push_back(Res);
|
ParsedBinariesAndObjects.push_back(std::move(ParsedObj));
|
||||||
}
|
}
|
||||||
ObjectFileForArch[std::make_pair(UB, ArchName)] = Res;
|
ObjectFileForArch[std::make_pair(UB, ArchName)] = Res;
|
||||||
} else if (Bin->isObject()) {
|
} else if (Bin->isObject()) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -72,7 +73,7 @@ private:
|
|||||||
std::string printDILineInfo(DILineInfo LineInfo) const;
|
std::string printDILineInfo(DILineInfo LineInfo) const;
|
||||||
|
|
||||||
// Owns all the parsed binaries and object files.
|
// Owns all the parsed binaries and object files.
|
||||||
SmallVector<Binary*, 4> ParsedBinariesAndObjects;
|
SmallVector<std::unique_ptr<Binary>, 4> ParsedBinariesAndObjects;
|
||||||
// Owns module info objects.
|
// Owns module info objects.
|
||||||
typedef std::map<std::string, ModuleInfo *> ModuleMapTy;
|
typedef std::map<std::string, ModuleInfo *> ModuleMapTy;
|
||||||
ModuleMapTy Modules;
|
ModuleMapTy Modules;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user