mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
75aaaf95b6
Summary: This patch creates the llvm-gsymutil binary that can convert object files to GSYM using the --convert <path> option. It can also dump and lookup addresses within GSYM files that have been saved to disk. To dump a file: llvm-gsymutil /path/to/a.gsym To perform address lookups, like with atos, on GSYM files: llvm-gsymutil --address 0x1000 --address 0x1100 /path/to/a.gsym To convert a mach-o or ELF file, including any DWARF debug info contained within the object files: llvm-gsymutil --convert /path/to/a.out --out-file /path/to/a.out.gsym Conversion highlights: - convert DWARF debug info in mach-o or ELF files to GSYM - convert symbols in symbol table to GSYM and don't convert symbols that overlap with DWARF debug info - extract UUID from object files - extract .text (read + execute) section address ranges and filter out any DWARF or symbols that don't fall in those ranges. - if .text sections are extracted, and if the last gsym::FunctionInfo object has no size, cap the size to the end of the section the function was contained in Dumping GSYM files will dump all sections of the GSYM file in textual format. Reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace, aprantl, JDevlieghere, jdoerfert Subscribers: mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74883
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
//===- LookupResult.cpp -------------------------------------------------*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/DebugInfo/GSYM/LookupResult.h"
|
|
#include "llvm/ADT/SmallString.h"
|
|
#include "llvm/Support/Format.h"
|
|
#include "llvm/Support/Path.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
#include <ciso646>
|
|
|
|
using namespace llvm;
|
|
using namespace gsym;
|
|
|
|
std::string LookupResult::getSourceFile(uint32_t Index) const {
|
|
std::string Fullpath;
|
|
if (Index < Locations.size()) {
|
|
if (!Locations[Index].Dir.empty()) {
|
|
if (Locations[Index].Base.empty()) {
|
|
Fullpath = std::string(Locations[Index].Dir);
|
|
} else {
|
|
llvm::SmallString<64> Storage;
|
|
llvm::sys::path::append(Storage, Locations[Index].Dir,
|
|
Locations[Index].Base);
|
|
Fullpath.assign(Storage.begin(), Storage.end());
|
|
}
|
|
} else if (!Locations[Index].Base.empty())
|
|
Fullpath = std::string(Locations[Index].Base);
|
|
}
|
|
return Fullpath;
|
|
}
|
|
|
|
raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const SourceLocation &SL) {
|
|
OS << SL.Name;
|
|
if (SL.Offset > 0)
|
|
OS << " + " << SL.Offset;
|
|
if (SL.Dir.size() || SL.Base.size()) {
|
|
OS << " @ ";
|
|
if (!SL.Dir.empty()) {
|
|
OS << SL.Dir;
|
|
if (SL.Dir.contains('\\') and not SL.Dir.contains('/'))
|
|
OS << '\\';
|
|
else
|
|
OS << '/';
|
|
}
|
|
if (SL.Base.empty())
|
|
OS << "<invalid-file>";
|
|
else
|
|
OS << SL.Base;
|
|
OS << ':' << SL.Line;
|
|
}
|
|
return OS;
|
|
}
|
|
|
|
raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const LookupResult &LR) {
|
|
OS << HEX64(LR.LookupAddr) << ": ";
|
|
auto NumLocations = LR.Locations.size();
|
|
for (size_t I = 0; I < NumLocations; ++I) {
|
|
if (I > 0) {
|
|
OS << '\n';
|
|
OS.indent(20);
|
|
}
|
|
const bool IsInlined = I + 1 != NumLocations;
|
|
OS << LR.Locations[I];
|
|
if (IsInlined)
|
|
OS << " [inlined]";
|
|
}
|
|
OS << '\n';
|
|
return OS;
|
|
}
|