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
95 lines
3.3 KiB
C++
95 lines
3.3 KiB
C++
//===- DebugCrossImpSubsection.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/CodeView/DebugCrossImpSubsection.h"
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
|
|
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
|
|
#include "llvm/Support/BinaryStreamReader.h"
|
|
#include "llvm/Support/BinaryStreamWriter.h"
|
|
#include "llvm/Support/Endian.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::codeview;
|
|
|
|
Error VarStreamArrayExtractor<CrossModuleImportItem>::
|
|
operator()(BinaryStreamRef Stream, uint32_t &Len,
|
|
codeview::CrossModuleImportItem &Item) {
|
|
BinaryStreamReader Reader(Stream);
|
|
if (Reader.bytesRemaining() < sizeof(CrossModuleImport))
|
|
return make_error<CodeViewError>(
|
|
cv_error_code::insufficient_buffer,
|
|
"Not enough bytes for a Cross Module Import Header!");
|
|
if (auto EC = Reader.readObject(Item.Header))
|
|
return EC;
|
|
if (Reader.bytesRemaining() < Item.Header->Count * sizeof(uint32_t))
|
|
return make_error<CodeViewError>(
|
|
cv_error_code::insufficient_buffer,
|
|
"Not enough to read specified number of Cross Module References!");
|
|
if (auto EC = Reader.readArray(Item.Imports, Item.Header->Count))
|
|
return EC;
|
|
return Error::success();
|
|
}
|
|
|
|
Error DebugCrossModuleImportsSubsectionRef::initialize(
|
|
BinaryStreamReader Reader) {
|
|
return Reader.readArray(References, Reader.bytesRemaining());
|
|
}
|
|
|
|
Error DebugCrossModuleImportsSubsectionRef::initialize(BinaryStreamRef Stream) {
|
|
BinaryStreamReader Reader(Stream);
|
|
return initialize(Reader);
|
|
}
|
|
|
|
void DebugCrossModuleImportsSubsection::addImport(StringRef Module,
|
|
uint32_t ImportId) {
|
|
Strings.insert(Module);
|
|
std::vector<support::ulittle32_t> Targets = {support::ulittle32_t(ImportId)};
|
|
auto Result = Mappings.insert(std::make_pair(Module, Targets));
|
|
if (!Result.second)
|
|
Result.first->getValue().push_back(Targets[0]);
|
|
}
|
|
|
|
uint32_t DebugCrossModuleImportsSubsection::calculateSerializedSize() const {
|
|
uint32_t Size = 0;
|
|
for (const auto &Item : Mappings) {
|
|
Size += sizeof(CrossModuleImport);
|
|
Size += sizeof(support::ulittle32_t) * Item.second.size();
|
|
}
|
|
return Size;
|
|
}
|
|
|
|
Error DebugCrossModuleImportsSubsection::commit(
|
|
BinaryStreamWriter &Writer) const {
|
|
using T = decltype(&*Mappings.begin());
|
|
std::vector<T> Ids;
|
|
Ids.reserve(Mappings.size());
|
|
|
|
for (const auto &M : Mappings)
|
|
Ids.push_back(&M);
|
|
|
|
llvm::sort(Ids, [this](const T &L1, const T &L2) {
|
|
return Strings.getIdForString(L1->getKey()) <
|
|
Strings.getIdForString(L2->getKey());
|
|
});
|
|
|
|
for (const auto &Item : Ids) {
|
|
CrossModuleImport Imp;
|
|
Imp.ModuleNameOffset = Strings.getIdForString(Item->getKey());
|
|
Imp.Count = Item->getValue().size();
|
|
if (auto EC = Writer.writeObject(Imp))
|
|
return EC;
|
|
if (auto EC = Writer.writeArray(ArrayRef(Item->getValue())))
|
|
return EC;
|
|
}
|
|
return Error::success();
|
|
}
|