llvm.org GIT mirror llvm / f32491f
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341772 91177308-0d34-0410-b5e6-96231b3b80d8 David Carlier 1 year, 8 months ago
3 changed file(s) with 13 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4646 }
4747
4848 static Error
49 loadELF64(StringRef Filename, object::OwningBinary &ObjFile,
49 loadObj(StringRef Filename, object::OwningBinary &ObjFile,
5050 InstrumentationMap::SledContainer &Sleds,
5151 InstrumentationMap::FunctionAddressMap &FunctionAddresses,
5252 InstrumentationMap::FunctionAddressReverseMap &FunctionIds) {
5353 InstrumentationMap Map;
5454
5555 // Find the section named "xray_instr_map".
56 if (!ObjFile.getBinary()->isELF() ||
56 if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||
5757 !(ObjFile.getBinary()->getArch() == Triple::x86_64 ||
5858 ObjFile.getBinary()->getArch() == Triple::ppc64le))
5959 return make_error(
60 "File format not supported (only does ELF little endian 64-bit).",
60 "File format not supported (only does ELF and Mach-O little endian 64-bit).",
6161 std::make_error_code(std::errc::not_supported));
6262
6363 StringRef Contents = "";
190190 if (auto E = loadYAML(Fd, FileSize, Filename, Map.Sleds,
191191 Map.FunctionAddresses, Map.FunctionIds))
192192 return std::move(E);
193 } else if (auto E = loadELF64(Filename, *ObjectFileOrError, Map.Sleds,
193 } else if (auto E = loadObj(Filename, *ObjectFileOrError, Map.Sleds,
194194 Map.FunctionAddresses, Map.FunctionIds)) {
195195 return std::move(E);
196196 }
0 ; This test makes sure we can extract the instrumentation map from an
1 ; XRay-instrumented object file.
2 ;
3 ; RUN: llvm-xray extract %S/Inputs/instr-map-mach.o -s | FileCheck %s
4
5 ; CHECK: ---
6 ; CHECK-NEXT: - { id: 1, address: 0x0000000000000000, function: 0x0000000000000000, kind: function-enter, always-instrument: true, function-name: 'task(void*)' }
7 ; CHECK-NEXT: - { id: 1, address: 0x0000000000000162, function: 0x0000000000000000, kind: function-exit, always-instrument: true, function-name: 'task(void*)' }
8 ; CHECK-NEXT: ...