Files
TheRock/compiler/amd-llvm/llvm/lib/DebugInfo/GSYM/GsymReaderV2.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

147 lines
4.5 KiB
C++

//===- GsymReaderV2.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/GsymReaderV2.h"
#include <assert.h>
#include <inttypes.h>
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/GSYM/GlobalData.h"
#include "llvm/DebugInfo/GSYM/GsymDataExtractor.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace llvm;
using namespace gsym;
GsymReaderV2::GsymReaderV2(std::unique_ptr<MemoryBuffer> Buffer,
llvm::endianness Endian)
: GsymReader(std::move(Buffer), Endian) {}
/// For V2 file layout, see HeaderV2.h
llvm::Error GsymReaderV2::parseHeaderAndGlobalDataEntries() {
if (auto Err = parseHeader(Hdr, SwappedHdr))
return Err;
return parseGlobalDataEntries(HeaderV2::getEncodedSize());
}
void GsymReaderV2::dump(raw_ostream &OS) {
OS << *Hdr << "\n";
// Print GlobalData entries.
OS << "Global Data Sections:\n";
OS << "TYPE FILE OFFSET FILE SIZE\n";
OS << "=============== ================== ==================\n";
/// Re-parse the GlobalData entries to ensure we show the GlobalData
/// in the exact order it appears in the GSYM data.
const StringRef Buf = MemBuffer->getBuffer();
const uint64_t BufSize = Buf.size();
GsymDataExtractor Data(Buf, isLittleEndian());
uint64_t Offset = HeaderV2::getEncodedSize();
while (Offset + sizeof(GlobalData) <= BufSize) {
auto GDOrErr = GlobalData::decode(Data, Offset);
assert(GDOrErr && "GlobalData::decode() should not fail");
const GlobalData &GD = *GDOrErr;
OS << formatv("{0,-15} ", getNameForGlobalInfoType(GD.Type).data())
<< HEX64(GD.FileOffset) << " " << HEX64(GD.FileSize) << "\n";
// Stop printing after the end of list entry.
if (GD.Type == GlobalInfoType::EndOfList)
break;
}
OS << "\n";
// Print UUID if present.
if (auto UUIDBytes = getOptionalGlobalDataBytes(GlobalInfoType::UUID)) {
OS << "UUID:\n";
for (uint8_t Byte : *UUIDBytes)
OS << format_hex_no_prefix(Byte, 2);
OS << "\n\n";
}
OS << "Address Table:\n";
OS << "INDEX OFFSET ";
switch (getAddressOffsetSize()) {
case 1:
OS << "8 ";
break;
case 2:
OS << "16";
break;
case 4:
OS << "32";
break;
case 8:
OS << "64";
break;
default:
OS << "??";
break;
}
OS << " (ADDRESS 64)\n";
OS << "====== ========================================\n";
for (uint32_t I = 0; I < getNumAddresses(); ++I) {
OS << formatv("[{0,4}] ", I);
switch (getAddressOffsetSize()) {
case 1:
OS << HEX8(getAddrOffsets<uint8_t>()[I]);
break;
case 2:
OS << HEX16(getAddrOffsets<uint16_t>()[I]);
break;
case 4:
OS << HEX32(getAddrOffsets<uint32_t>()[I]);
break;
case 8:
OS << HEX32(getAddrOffsets<uint64_t>()[I]);
break;
default:
break;
}
OS << " (" << HEX64(*getAddress(I)) << ")\n";
}
OS << "\nAddress Info Offsets:\n";
OS << "INDEX OFFSET 64 (FILE OFFSET 64)\n";
OS << "====== ========================================\n";
for (uint32_t I = 0; I < getNumAddresses(); ++I) {
uint64_t RelOffset = I * getAddressInfoOffsetSize();
uint64_t RelValue =
AddrInfoOffsetsData.getUnsigned(&RelOffset, getAddressInfoOffsetSize());
OS << formatv("[{0,4}] ", I) << HEX64(RelValue) << " ("
<< HEX64(*getAddressInfoOffset(I)) << ")\n";
}
OS << "\nFiles:\n";
OS << "INDEX DIRECTORY BASENAME PATH\n";
OS << "====== ========== ========== "
"========================================\n";
// Since we don't store the total number of files in the file table, loop
// until we get a null entry which means the index is out of range.
for (uint32_t I = 0;; ++I) {
auto FE = getFile(I);
if (!FE)
break;
OS << formatv("[{0,4}] ", I) << HEX32(FE->Dir) << ' ' << HEX32(FE->Base)
<< ' ';
dump(OS, FE);
OS << "\n";
}
OS << "\n";
gsym::dump(OS, StrTab, 8);
OS << "\n";
for (uint32_t I = 0; I < getNumAddresses(); ++I) {
OS << "FunctionInfo @ " << HEX32(*getAddressInfoOffset(I)) << ": ";
if (auto FI = getFunctionInfoAtIndex(I))
dump(OS, *FI);
else
logAllUnhandledErrors(FI.takeError(), OS, "FunctionInfo:");
}
}