1 //===- xray-fc-account.cpp: XRay Function Call Accounting Tool ------------===//
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 // Implementation of the helper tools dealing with XRay-generated function ids.
12 //===----------------------------------------------------------------------===//
14 #include "func-id-helper.h"
15 #include "llvm/Support/Path.h"
21 std::string
FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId
) const {
22 auto CacheIt
= CachedNames
.find(FuncId
);
23 if (CacheIt
!= CachedNames
.end())
24 return CacheIt
->second
;
27 auto It
= FunctionAddresses
.find(FuncId
);
28 if (It
== FunctionAddresses
.end()) {
33 if (auto ResOrErr
= Symbolizer
.symbolizeCode(BinaryInstrMap
, It
->second
)) {
35 if (DI
.FunctionName
== "<invalid>")
36 F
<< "@(" << std::hex
<< It
->second
<< ")";
40 handleAllErrors(ResOrErr
.takeError(), [&](const ErrorInfoBase
&) {
41 F
<< "@(" << std::hex
<< It
->second
<< ")";
45 CachedNames
[FuncId
] = S
;
49 std::string
FuncIdConversionHelper::FileLineAndColumn(int32_t FuncId
) const {
50 auto It
= FunctionAddresses
.find(FuncId
);
51 if (It
== FunctionAddresses
.end())
55 auto ResOrErr
= Symbolizer
.symbolizeCode(BinaryInstrMap
, It
->second
);
57 consumeError(ResOrErr
.takeError());
62 F
<< sys::path::filename(DI
.FileName
).str() << ":" << DI
.Line
<< ":"