[llvm] r341772 - [Xray] tooling allow MachO format support
David Carlier via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 9 22:00:44 PDT 2018
Author: devnexen
Date: Sun Sep 9 22:00:43 2018
New Revision: 341772
URL: http://llvm.org/viewvc/llvm-project?rev=341772&view=rev
Log:
[Xray] tooling allow MachO format support
Getting writable xray __DATA sections from MachO as well.
Reviewers: dberris
Reviewed By: dberris
Differential Revision: https://reviews.llvm.org/D51758
Added:
llvm/trunk/test/tools/llvm-xray/X86/Inputs/instr-map-mach.o (with props)
llvm/trunk/test/tools/llvm-xray/X86/extract-instrmap-macho.ll
Modified:
llvm/trunk/lib/XRay/InstrumentationMap.cpp
Modified: llvm/trunk/lib/XRay/InstrumentationMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/XRay/InstrumentationMap.cpp?rev=341772&r1=341771&r2=341772&view=diff
==============================================================================
--- llvm/trunk/lib/XRay/InstrumentationMap.cpp (original)
+++ llvm/trunk/lib/XRay/InstrumentationMap.cpp Sun Sep 9 22:00:43 2018
@@ -47,18 +47,18 @@ Optional<uint64_t> InstrumentationMap::g
}
static Error
-loadELF64(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
+loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
InstrumentationMap::SledContainer &Sleds,
InstrumentationMap::FunctionAddressMap &FunctionAddresses,
InstrumentationMap::FunctionAddressReverseMap &FunctionIds) {
InstrumentationMap Map;
// Find the section named "xray_instr_map".
- if (!ObjFile.getBinary()->isELF() ||
+ if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||
!(ObjFile.getBinary()->getArch() == Triple::x86_64 ||
ObjFile.getBinary()->getArch() == Triple::ppc64le))
return make_error<StringError>(
- "File format not supported (only does ELF little endian 64-bit).",
+ "File format not supported (only does ELF and Mach-O little endian 64-bit).",
std::make_error_code(std::errc::not_supported));
StringRef Contents = "";
@@ -191,7 +191,7 @@ llvm::xray::loadInstrumentationMap(Strin
if (auto E = loadYAML(Fd, FileSize, Filename, Map.Sleds,
Map.FunctionAddresses, Map.FunctionIds))
return std::move(E);
- } else if (auto E = loadELF64(Filename, *ObjectFileOrError, Map.Sleds,
+ } else if (auto E = loadObj(Filename, *ObjectFileOrError, Map.Sleds,
Map.FunctionAddresses, Map.FunctionIds)) {
return std::move(E);
}
Added: llvm/trunk/test/tools/llvm-xray/X86/Inputs/instr-map-mach.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-xray/X86/Inputs/instr-map-mach.o?rev=341772&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-xray/X86/Inputs/instr-map-mach.o
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/tools/llvm-xray/X86/extract-instrmap-macho.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-xray/X86/extract-instrmap-macho.ll?rev=341772&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-xray/X86/extract-instrmap-macho.ll (added)
+++ llvm/trunk/test/tools/llvm-xray/X86/extract-instrmap-macho.ll Sun Sep 9 22:00:43 2018
@@ -0,0 +1,9 @@
+; This test makes sure we can extract the instrumentation map from an
+; XRay-instrumented object file.
+;
+; RUN: llvm-xray extract %S/Inputs/instr-map-mach.o -s | FileCheck %s
+
+; CHECK: ---
+; CHECK-NEXT: - { id: 1, address: 0x0000000000000000, function: 0x0000000000000000, kind: function-enter, always-instrument: true, function-name: 'task(void*)' }
+; CHECK-NEXT: - { id: 1, address: 0x0000000000000162, function: 0x0000000000000000, kind: function-exit, always-instrument: true, function-name: 'task(void*)' }
+; CHECK-NEXT: ...
More information about the llvm-commits
mailing list