Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/GSYM/LookupResult.cpp
35266 views
//===- LookupResult.cpp -------------------------------------------------*-===//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//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/GSYM/LookupResult.h"9#include "llvm/ADT/SmallString.h"10#include "llvm/DebugInfo/GSYM/ExtractRanges.h"11#include "llvm/Support/Format.h"12#include "llvm/Support/Path.h"13#include "llvm/Support/raw_ostream.h"14#include <ciso646>1516using namespace llvm;17using namespace gsym;1819std::string LookupResult::getSourceFile(uint32_t Index) const {20std::string Fullpath;21if (Index < Locations.size()) {22if (!Locations[Index].Dir.empty()) {23if (Locations[Index].Base.empty()) {24Fullpath = std::string(Locations[Index].Dir);25} else {26llvm::SmallString<64> Storage;27llvm::sys::path::append(Storage, Locations[Index].Dir,28Locations[Index].Base);29Fullpath.assign(Storage.begin(), Storage.end());30}31} else if (!Locations[Index].Base.empty())32Fullpath = std::string(Locations[Index].Base);33}34return Fullpath;35}3637raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const SourceLocation &SL) {38OS << SL.Name;39if (SL.Offset > 0)40OS << " + " << SL.Offset;41if (SL.Dir.size() || SL.Base.size()) {42OS << " @ ";43if (!SL.Dir.empty()) {44OS << SL.Dir;45if (SL.Dir.contains('\\') && !SL.Dir.contains('/'))46OS << '\\';47else48OS << '/';49}50if (SL.Base.empty())51OS << "<invalid-file>";52else53OS << SL.Base;54OS << ':' << SL.Line;55}56return OS;57}5859raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const LookupResult &LR) {60OS << HEX64(LR.LookupAddr) << ": ";61auto NumLocations = LR.Locations.size();62for (size_t I = 0; I < NumLocations; ++I) {63if (I > 0) {64OS << '\n';65OS.indent(20);66}67const bool IsInlined = I + 1 != NumLocations;68OS << LR.Locations[I];69if (IsInlined)70OS << " [inlined]";71}72OS << '\n';73return OS;74}757677