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/DebugInfo/GSYM/ExtractRanges.h"
12 #include "llvm/Support/Format.h"
13 #include "llvm/Support/Path.h"
14 #include "llvm/Support/raw_ostream.h"
20 std::string
LookupResult::getSourceFile(uint32_t Index
) const {
22 if (Index
< Locations
.size()) {
23 if (!Locations
[Index
].Dir
.empty()) {
24 if (Locations
[Index
].Base
.empty()) {
25 Fullpath
= std::string(Locations
[Index
].Dir
);
27 llvm::SmallString
<64> Storage
;
28 llvm::sys::path::append(Storage
, Locations
[Index
].Dir
,
29 Locations
[Index
].Base
);
30 Fullpath
.assign(Storage
.begin(), Storage
.end());
32 } else if (!Locations
[Index
].Base
.empty())
33 Fullpath
= std::string(Locations
[Index
].Base
);
38 raw_ostream
&llvm::gsym::operator<<(raw_ostream
&OS
, const SourceLocation
&SL
) {
41 OS
<< " + " << SL
.Offset
;
42 if (SL
.Dir
.size() || SL
.Base
.size()) {
44 if (!SL
.Dir
.empty()) {
46 if (SL
.Dir
.contains('\\') && !SL
.Dir
.contains('/'))
52 OS
<< "<invalid-file>";
60 raw_ostream
&llvm::gsym::operator<<(raw_ostream
&OS
, const LookupResult
&LR
) {
61 OS
<< HEX64(LR
.LookupAddr
) << ": ";
62 auto NumLocations
= LR
.Locations
.size();
63 for (size_t I
= 0; I
< NumLocations
; ++I
) {
68 const bool IsInlined
= I
+ 1 != NumLocations
;
69 OS
<< LR
.Locations
[I
];