1 //===- LookupResult.cpp -------------------------------------------------*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/GSYM/LookupResult.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/Path.h"
13 #include "llvm/Support/raw_ostream.h"
19 std::string LookupResult::getSourceFile(uint32_t Index) const {
21 if (Index < Locations.size()) {
22 if (!Locations[Index].Dir.empty()) {
23 if (Locations[Index].Base.empty()) {
24 Fullpath = Locations[Index].Dir;
26 llvm::SmallString<64> Storage;
27 llvm::sys::path::append(Storage, Locations[Index].Dir,
28 Locations[Index].Base);
29 Fullpath.assign(Storage.begin(), Storage.end());
31 } else if (!Locations[Index].Base.empty())
32 Fullpath = Locations[Index].Base;
37 raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const SourceLocation &SL) {
38 OS << SL.Name << " @ ";
39 if (!SL.Dir.empty()) {
41 if (SL.Dir.contains('\\') and not SL.Dir.contains('/'))
47 OS << "<invalid-file>";
54 raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const LookupResult &LR) {
55 OS << HEX64(LR.LookupAddr) << ": ";
56 auto NumLocations = LR.Locations.size();
57 for (size_t I = 0; I < NumLocations; ++I) {
62 const bool IsInlined = I + 1 != NumLocations;
63 OS << LR.Locations[I];