Path: blob/main/contrib/llvm-project/llvm/tools/llvm-xray/func-id-helper.h
35230 views
//===- func-id-helper.h - XRay Function ID Conversion Helpers -------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Defines helper tools dealing with XRay-generated function ids.9//10//===----------------------------------------------------------------------===//11#ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H12#define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H1314#include "llvm/ADT/DenseMap.h"15#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"16#include "llvm/DebugInfo/Symbolize/Symbolize.h"17#include <unordered_map>1819namespace llvm {20namespace xray {2122// This class consolidates common operations related to Function IDs.23class FuncIdConversionHelper {24public:25using FunctionAddressMap = std::unordered_map<int32_t, uint64_t>;2627private:28std::string BinaryInstrMap;29symbolize::LLVMSymbolizer &Symbolizer;30const FunctionAddressMap &FunctionAddresses;31mutable llvm::DenseMap<int32_t, std::string> CachedNames;3233public:34FuncIdConversionHelper(std::string BinaryInstrMap,35symbolize::LLVMSymbolizer &Symbolizer,36const FunctionAddressMap &FunctionAddresses)37: BinaryInstrMap(std::move(BinaryInstrMap)), Symbolizer(Symbolizer),38FunctionAddresses(FunctionAddresses) {}3940// Returns the symbol or a string representation of the function id.41std::string SymbolOrNumber(int32_t FuncId) const;4243// Returns the file and column from debug info for the given function id.44std::string FileLineAndColumn(int32_t FuncId) const;45};4647} // namespace xray48} // namespace llvm4950#endif // LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H515253