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
133 lines
4.1 KiB
C++
133 lines
4.1 KiB
C++
//===- NativeSymbolReuseTest.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/PDB/PDB.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
|
|
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
|
|
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
|
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
|
#include "llvm/Support/Path.h"
|
|
|
|
#include "llvm/Testing/Support/Error.h"
|
|
#include "llvm/Testing/Support/SupportHelpers.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::pdb;
|
|
|
|
extern const char *TestMainArgv0;
|
|
|
|
TEST(NativeSymbolReuseTest, GlobalSymbolReuse) {
|
|
SmallString<128> InputsDir = unittest::getInputFileDirectory(TestMainArgv0);
|
|
llvm::sys::path::append(InputsDir, "empty.pdb");
|
|
|
|
std::unique_ptr<IPDBSession> S;
|
|
Error E = pdb::loadDataForPDB(PDB_ReaderType::Native, InputsDir, S);
|
|
|
|
ASSERT_THAT_ERROR(std::move(E), Succeeded());
|
|
|
|
SymIndexId GlobalId;
|
|
{
|
|
auto GS1 = S->getGlobalScope();
|
|
auto GS2 = S->getGlobalScope();
|
|
|
|
GlobalId = GS1->getSymIndexId();
|
|
SymIndexId Id2 = GS1->getSymIndexId();
|
|
EXPECT_EQ(GlobalId, Id2);
|
|
}
|
|
|
|
{
|
|
auto GS3 = S->getGlobalScope();
|
|
|
|
SymIndexId Id3 = GS3->getSymIndexId();
|
|
EXPECT_EQ(GlobalId, Id3);
|
|
}
|
|
}
|
|
|
|
TEST(NativeSymbolReuseTest, CompilandSymbolReuse) {
|
|
SmallString<128> InputsDir = unittest::getInputFileDirectory(TestMainArgv0);
|
|
llvm::sys::path::append(InputsDir, "empty.pdb");
|
|
|
|
std::unique_ptr<IPDBSession> S;
|
|
Error E = pdb::loadDataForPDB(PDB_ReaderType::Native, InputsDir, S);
|
|
|
|
ASSERT_THAT_ERROR(std::move(E), Succeeded());
|
|
|
|
auto GS = S->getGlobalScope();
|
|
|
|
std::vector<SymIndexId> CompilandIds;
|
|
{
|
|
auto Compilands = GS->findAllChildren<PDBSymbolCompiland>();
|
|
ASSERT_NE(nullptr, Compilands);
|
|
ASSERT_EQ(2U, Compilands->getChildCount());
|
|
std::vector<SymIndexId> Ids2;
|
|
|
|
// First try resetting the enumerator, then try destroying the enumerator
|
|
// and constructing another one.
|
|
while (auto Compiland = Compilands->getNext())
|
|
CompilandIds.push_back(Compiland->getSymIndexId());
|
|
Compilands->reset();
|
|
while (auto Compiland = Compilands->getNext())
|
|
Ids2.push_back(Compiland->getSymIndexId());
|
|
|
|
EXPECT_EQ(CompilandIds, Ids2);
|
|
}
|
|
|
|
{
|
|
auto Compilands = GS->findAllChildren<PDBSymbolCompiland>();
|
|
ASSERT_NE(nullptr, Compilands);
|
|
ASSERT_EQ(2U, Compilands->getChildCount());
|
|
|
|
std::vector<SymIndexId> Ids3;
|
|
while (auto Compiland = Compilands->getNext())
|
|
Ids3.push_back(Compiland->getSymIndexId());
|
|
|
|
EXPECT_EQ(CompilandIds, Ids3);
|
|
}
|
|
}
|
|
|
|
TEST(NativeSymbolReuseTest, CompilandSymbolReuseBackwards) {
|
|
SmallString<128> InputsDir = unittest::getInputFileDirectory(TestMainArgv0);
|
|
llvm::sys::path::append(InputsDir, "empty.pdb");
|
|
|
|
std::unique_ptr<IPDBSession> S;
|
|
Error E = pdb::loadDataForPDB(PDB_ReaderType::Native, InputsDir, S);
|
|
|
|
ASSERT_THAT_ERROR(std::move(E), Succeeded());
|
|
|
|
auto GS = S->getGlobalScope();
|
|
|
|
// This time do the first iteration backwards, and make sure that when you
|
|
// then iterate them forwards, the IDs come out in reverse.
|
|
std::vector<SymIndexId> CompilandIds;
|
|
{
|
|
auto Compilands = GS->findAllChildren<PDBSymbolCompiland>();
|
|
ASSERT_NE(nullptr, Compilands);
|
|
ASSERT_EQ(2U, Compilands->getChildCount());
|
|
|
|
std::vector<SymIndexId> Ids2;
|
|
|
|
for (int I = Compilands->getChildCount() - 1; I >= 0; --I) {
|
|
auto Compiland = Compilands->getChildAtIndex(I);
|
|
CompilandIds.push_back(Compiland->getSymIndexId());
|
|
}
|
|
|
|
while (auto Compiland = Compilands->getNext())
|
|
Ids2.push_back(Compiland->getSymIndexId());
|
|
|
|
auto ReversedIter = llvm::reverse(Ids2);
|
|
std::vector<SymIndexId> Reversed{ReversedIter.begin(), ReversedIter.end()};
|
|
EXPECT_EQ(CompilandIds, Reversed);
|
|
}
|
|
}
|