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
146 lines
4.6 KiB
C++
146 lines
4.6 KiB
C++
//===- GsymReaderV1.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/GsymReaderV1.h"
|
|
|
|
#include <assert.h>
|
|
#include <inttypes.h>
|
|
|
|
#include "llvm/DebugInfo/GSYM/GsymDataExtractor.h"
|
|
#include "llvm/DebugInfo/GSYM/Header.h"
|
|
#include "llvm/Support/FormatVariadic.h"
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
using namespace llvm;
|
|
using namespace gsym;
|
|
|
|
GsymReaderV1::GsymReaderV1(std::unique_ptr<MemoryBuffer> Buffer,
|
|
llvm::endianness Endian)
|
|
: GsymReader(std::move(Buffer), Endian) {}
|
|
|
|
llvm::Error GsymReaderV1::parseHeaderAndGlobalDataEntries() {
|
|
if (auto Err = parseHeader(Hdr, SwappedHdr))
|
|
return Err;
|
|
|
|
// Compute section offsets from the fixed V1 layout and populate the
|
|
// GlobalDataSections map. V1 sections are laid out sequentially:
|
|
// [Header] [AddrOffsets] [AddrInfoOffsets] [FileTable] ... [StringTable]
|
|
const StringRef Buf = MemBuffer->getBuffer();
|
|
const uint64_t NumAddrs = Hdr->NumAddresses;
|
|
const uint8_t AddrOffSize = Hdr->AddrOffSize;
|
|
|
|
// AddrOffsets
|
|
uint64_t Offset = alignTo(sizeof(Header), AddrOffSize);
|
|
uint64_t AddrOffsetsSize = NumAddrs * AddrOffSize;
|
|
GlobalDataSections[GlobalInfoType::AddrOffsets] = {
|
|
GlobalInfoType::AddrOffsets, Offset, AddrOffsetsSize};
|
|
Offset += AddrOffsetsSize;
|
|
|
|
// AddrInfoOffsets
|
|
Offset = alignTo(Offset, 4);
|
|
uint64_t AddrInfoOffsetsSize = NumAddrs * Header::getAddressInfoOffsetSize();
|
|
GlobalDataSections[GlobalInfoType::AddrInfoOffsets] = {
|
|
GlobalInfoType::AddrInfoOffsets, Offset, AddrInfoOffsetsSize};
|
|
Offset += AddrInfoOffsetsSize;
|
|
|
|
// FileTable: read NumFiles to compute the size.
|
|
GsymDataExtractor Data(Buf, isLittleEndian());
|
|
uint64_t FTOffset = Offset;
|
|
uint32_t NumFiles = Data.getU32(&FTOffset);
|
|
uint64_t FileTableSize =
|
|
4 + static_cast<uint64_t>(NumFiles) *
|
|
FileEntry::getEncodedSize(Header::getStringOffsetSize());
|
|
GlobalDataSections[GlobalInfoType::FileTable] = {GlobalInfoType::FileTable,
|
|
Offset, FileTableSize};
|
|
|
|
// StringTable: offset and size are in the header.
|
|
GlobalDataSections[GlobalInfoType::StringTable] = {
|
|
GlobalInfoType::StringTable, Hdr->StrtabOffset, Hdr->StrtabSize};
|
|
|
|
// FunctionInfo: starts after the string table and extends to end of file.
|
|
const uint64_t FIOffset = Hdr->StrtabOffset + Hdr->StrtabSize;
|
|
GlobalDataSections[GlobalInfoType::FunctionInfo] = {
|
|
GlobalInfoType::FunctionInfo, FIOffset, Buf.size() - FIOffset};
|
|
|
|
return Error::success();
|
|
}
|
|
|
|
void GsymReaderV1::dump(raw_ostream &OS) {
|
|
OS << *Hdr << "\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)\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\n";
|
|
OS << "====== ==========\n";
|
|
for (uint32_t I = 0; I < getNumAddresses(); ++I)
|
|
OS << formatv("[{0,4}] ", I) << HEX32(*getAddressInfoOffset(I)) << "\n";
|
|
OS << "\nFiles:\n";
|
|
OS << "INDEX DIRECTORY BASENAME PATH\n";
|
|
OS << "====== ========== ========== ==============================\n";
|
|
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, 4);
|
|
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:");
|
|
}
|
|
}
|