LLVM  13.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 
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/Path.h"
14 #include <ciso646>
15 
16 using namespace llvm;
17 using namespace gsym;
18 
20  std::string Fullpath;
21  if (Index < Locations.size()) {
22  if (!Locations[Index].Dir.empty()) {
23  if (Locations[Index].Base.empty()) {
24  Fullpath = std::string(Locations[Index].Dir);
25  } else {
26  llvm::SmallString<64> Storage;
28  Locations[Index].Base);
29  Fullpath.assign(Storage.begin(), Storage.end());
30  }
31  } else if (!Locations[Index].Base.empty())
32  Fullpath = std::string(Locations[Index].Base);
33  }
34  return Fullpath;
35 }
36 
38  OS << SL.Name;
39  if (SL.Offset > 0)
40  OS << " + " << SL.Offset;
41  if (SL.Dir.size() || SL.Base.size()) {
42  OS << " @ ";
43  if (!SL.Dir.empty()) {
44  OS << SL.Dir;
45  if (SL.Dir.contains('\\') and not SL.Dir.contains('/'))
46  OS << '\\';
47  else
48  OS << '/';
49  }
50  if (SL.Base.empty())
51  OS << "<invalid-file>";
52  else
53  OS << SL.Base;
54  OS << ':' << SL.Line;
55  }
56  return OS;
57 }
58 
60  OS << HEX64(LR.LookupAddr) << ": ";
61  auto NumLocations = LR.Locations.size();
62  for (size_t I = 0; I < NumLocations; ++I) {
63  if (I > 0) {
64  OS << '\n';
65  OS.indent(20);
66  }
67  const bool IsInlined = I + 1 != NumLocations;
68  OS << LR.Locations[I];
69  if (IsInlined)
70  OS << " [inlined]";
71  }
72  OS << '\n';
73  return OS;
74 }
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:156
llvm::gsym::LookupResult::getSourceFile
std::string getSourceFile(uint32_t Index) const
Definition: LookupResult.cpp:19
Path.h
llvm::gsym::LookupResult
Definition: LookupResult.h:41
llvm::gsym::LookupResult::Locations
SourceLocations Locations
The source locations that match this address.
Definition: LookupResult.h:54
llvm::gsym::SourceLocation::Name
StringRef Name
Function or symbol name.
Definition: LookupResult.h:23
Format.h
and
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 and
Definition: README.txt:1271
llvm::gsym::SourceLocation::Dir
StringRef Dir
Line entry source file directory path.
Definition: LookupResult.h:24
llvm::gsym::SourceLocation::Offset
uint32_t Offset
Byte size offset within the named function.
Definition: LookupResult.h:27
llvm::sys::path::append
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:454
llvm::gsym::operator<<
raw_ostream & operator<<(raw_ostream &OS, const FunctionInfo &R)
Definition: FunctionInfo.cpp:27
SmallString.h
llvm::StringRef::contains
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:465
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::SmallString< 64 >
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
LookupResult.h
llvm::gsym::LookupResult::LookupAddr
uint64_t LookupAddr
The address that this lookup pertains to.
Definition: LookupResult.h:42
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::gsym::SourceLocation::Base
StringRef Base
Line entry source file basename.
Definition: LookupResult.h:25
uint32_t
not
Should compile r2 movcc movcs str strb mov lr r1 movcs movcc mov lr not
Definition: README.txt:465
llvm::raw_ostream::indent
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
Definition: raw_ostream.cpp:497
llvm::gsym::SourceLocation
Definition: LookupResult.h:22
raw_ostream.h
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:160
HEX64
#define HEX64(v)
Definition: Range.h:21
llvm::gsym::SourceLocation::Line
uint32_t Line
Source file line number.
Definition: LookupResult.h:26