1 //===- xray-extract.h - XRay Instrumentation Map Extraction ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Defines the interface for extracting the instrumentation map from an
11 // XRay-instrumented binary.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_XRAY_EXTRACT_H
16 #define LLVM_TOOLS_XRAY_EXTRACT_H
21 #include <unordered_map>
23 #include "xray-sleds.h"
24 #include "llvm/Support/Error.h"
25 #include "llvm/Support/raw_ostream.h"
30 class InstrumentationMapExtractor {
32 typedef std::unordered_map<int32_t, uint64_t> FunctionAddressMap;
33 typedef std::unordered_map<uint64_t, int32_t> FunctionAddressReverseMap;
35 enum class InputFormats { ELF, YAML };
38 std::deque<SledEntry> Sleds;
39 FunctionAddressMap FunctionAddresses;
40 FunctionAddressReverseMap FunctionIds;
43 /// Loads the instrumentation map from |Filename|. Updates |EC| in case there
44 /// were errors encountered opening the file. |Format| defines what the input
45 /// instrumentation map is in.
46 InstrumentationMapExtractor(std::string Filename, InputFormats Format,
49 const FunctionAddressMap &getFunctionAddresses() { return FunctionAddresses; }
51 /// Exports the loaded function address map as YAML through |OS|.
52 void exportAsYAML(raw_ostream &OS);
58 #endif // LLVM_TOOLS_XRAY_EXTRACT_H