[dsymutil] Handle the -oso-prepend-path option when the input is a YAML debug map

All the tests using a YAML debug map will need this.

llvm-svn: 239163
This commit is contained in:
Frederic Riss 2015-06-05 16:35:44 +00:00
parent 457dd6a66f
commit c3b514c568
4 changed files with 12 additions and 7 deletions

View File

@ -7,7 +7,7 @@ RUN: llvm-dwarfdump %t2 | FileCheck %s
RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC
RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE
RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dsymutil -y -o - - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC
RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dsymutil -o - -oso-prepend-path=%p/.. -y - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE
RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dsymutil -o - -y - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE
CHECK: file format Mach-O 64-bit x86-64

View File

@ -1,6 +1,6 @@
REQUIRES: shell
RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump - | FileCheck %s
RUN: llvm-dsymutil -oso-prepend-path=%p/.. -dump-debug-map %p/../Inputs/basic-lto.macho.x86_64 | llvm-dsymutil -o - -oso-prepend-path=%p/.. -y - | llvm-dwarfdump - | FileCheck %s
RUN: llvm-dsymutil -oso-prepend-path=%p/.. -dump-debug-map %p/../Inputs/basic-lto.macho.x86_64 | llvm-dsymutil -o - -y - | llvm-dwarfdump - | FileCheck %s
CHECK: file format Mach-O 64-bit x86-64

View File

@ -28,6 +28,7 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/YAMLTraits.h"
#include <vector>
@ -208,8 +209,12 @@ template <> struct MappingTraits<dsymutil::DebugMapObject> {
Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue()));
}
dsymutil::DebugMapObject denormalize(IO &) {
dsymutil::DebugMapObject Res(Filename);
dsymutil::DebugMapObject denormalize(IO &IO) {
void *Ctxt = IO.getContext();
StringRef PrependPath = *reinterpret_cast<StringRef*>(Ctxt);
SmallString<80> Path(PrependPath);
sys::path::append(Path, Filename);
dsymutil::DebugMapObject Res(Path);
for (auto &Entry : Entries) {
auto &Mapping = Entry.second;
Res.addSymbol(Entry.first, Mapping.ObjectAddress, Mapping.BinaryAddress,

View File

@ -243,13 +243,13 @@ void MachODebugMapParser::loadMainBinarySymbols() {
}
ErrorOr<std::unique_ptr<DebugMap>>
parseYAMLDebugMap(StringRef InputFile, bool Verbose) {
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());
yaml::Input yin((*ErrOrFile)->getBuffer(), &PrependPath);
yin >> Res;
if (auto EC = yin.error())
@ -266,7 +266,7 @@ parseDebugMap(StringRef InputFile, StringRef PrependPath, bool Verbose, bool Inp
MachODebugMapParser Parser(InputFile, PrependPath, Verbose);
return Parser.parse();
} else {
return parseYAMLDebugMap(InputFile, Verbose);
return parseYAMLDebugMap(InputFile, PrependPath, Verbose);
}
}
}