LLVM 20.0.0git
LookupResult.cpp
Go to the documentation of this file.
1//===- LookupResult.cpp -------------------------------------------------*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12#include "llvm/Support/Path.h"
14
15using namespace llvm;
16using namespace gsym;
17
18std::string LookupResult::getSourceFile(uint32_t Index) const {
19 std::string Fullpath;
20 if (Index < Locations.size()) {
21 if (!Locations[Index].Dir.empty()) {
22 if (Locations[Index].Base.empty()) {
23 Fullpath = std::string(Locations[Index].Dir);
24 } else {
26 llvm::sys::path::append(Storage, Locations[Index].Dir,
27 Locations[Index].Base);
28 Fullpath.assign(Storage.begin(), Storage.end());
29 }
30 } else if (!Locations[Index].Base.empty())
31 Fullpath = std::string(Locations[Index].Base);
32 }
33 return Fullpath;
34}
35
37 OS << SL.Name;
38 if (SL.Offset > 0)
39 OS << " + " << SL.Offset;
40 if (SL.Dir.size() || SL.Base.size()) {
41 OS << " @ ";
42 if (!SL.Dir.empty()) {
43 OS << SL.Dir;
44 if (SL.Dir.contains('\\') && !SL.Dir.contains('/'))
45 OS << '\\';
46 else
47 OS << '/';
48 }
49 if (SL.Base.empty())
50 OS << "<invalid-file>";
51 else
52 OS << SL.Base;
53 OS << ':' << SL.Line;
54 }
55 return OS;
56}
57
59 OS << HEX64(LR.LookupAddr) << ": ";
60 auto NumLocations = LR.Locations.size();
61 for (size_t I = 0; I < NumLocations; ++I) {
62 if (I > 0) {
63 OS << '\n';
64 OS.indent(20);
65 }
66 const bool IsInlined = I + 1 != NumLocations;
67 OS << LR.Locations[I];
68 if (IsInlined)
69 OS << " [inlined]";
70 }
71 OS << '\n';
72 return OS;
73}
#define HEX64(v)
Definition: ExtractRanges.h:20
#define I(x, y, z)
Definition: MD5.cpp:58
raw_pwrite_stream & OS
This file defines the SmallString class.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:424
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:456
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t LookupAddr
The address that this lookup pertains to.
Definition: LookupResult.h:39
std::string getSourceFile(uint32_t Index) const
SourceLocations Locations
The source locations that match this address.
Definition: LookupResult.h:51
StringRef Base
Line entry source file basename.
Definition: LookupResult.h:24
uint32_t Line
Source file line number.
Definition: LookupResult.h:25
uint32_t Offset
Byte size offset within the named function.
Definition: LookupResult.h:26
StringRef Dir
Line entry source file directory path.
Definition: LookupResult.h:23
StringRef Name
Function or symbol name.
Definition: LookupResult.h:22