comparison tools/llvm-xray/func-id-helper.h @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children c2174574ed3a
comparison
equal deleted inserted replaced
120:1172e4bd9c6f 121:803732b1fca8
1 //===- func-id-helper.h - XRay Function ID Conversion Helpers -------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Defines helper tools dealing with XRay-generated function ids.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
14 #define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
15
16 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
17 #include <unordered_map>
18
19 namespace llvm {
20 namespace xray {
21
22 // This class consolidates common operations related to Function IDs.
23 class FuncIdConversionHelper {
24 public:
25 using FunctionAddressMap = std::unordered_map<int32_t, uint64_t>;
26
27 private:
28 std::string BinaryInstrMap;
29 symbolize::LLVMSymbolizer &Symbolizer;
30 const FunctionAddressMap &FunctionAddresses;
31
32 public:
33 FuncIdConversionHelper(std::string BinaryInstrMap,
34 symbolize::LLVMSymbolizer &Symbolizer,
35 const FunctionAddressMap &FunctionAddresses)
36 : BinaryInstrMap(std::move(BinaryInstrMap)), Symbolizer(Symbolizer),
37 FunctionAddresses(FunctionAddresses) {}
38
39 // Returns the symbol or a string representation of the function id.
40 std::string SymbolOrNumber(int32_t FuncId) const;
41
42 // Returns the file and column from debug info for the given function id.
43 std::string FileLineAndColumn(int32_t FuncId) const;
44 };
45
46 } // namespace xray
47 } // namespace llvm
48
49 #endif // LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H