@@ -416,7 +416,7 @@ TEST_F(KernelInitializeTest, givenDebuggingEnabledWhenKernelsAreInitializedThenA
416416 EXPECT_THAT (isa, testing::Not (MemCompare (&kernelHeap, sizeof (kernelHeap))));
417417};
418418
419- HWTEST_F (ModuleWithDebuggerL0Test, GivenDebugDataWhenInitializingModuleThenRegisterElf ) {
419+ HWTEST_F (ModuleWithDebuggerL0Test, GivenDebugDataWithRelocationsWhenInitializingModuleThenRegisterElfWithRelocatedElf ) {
420420 NEO::MockCompilerEnableGuard mock (true );
421421 auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions ();
422422 neoDevice->getExecutionEnvironment ()->rootDeviceEnvironments [device->getRootDeviceIndex ()]->compilerInterface .reset (cip);
@@ -455,6 +455,59 @@ HWTEST_F(ModuleWithDebuggerL0Test, GivenDebugDataWhenInitializingModuleThenRegis
455455 EXPECT_EQ (0u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
456456 EXPECT_TRUE (moduleMock->initialize (&moduleDesc, neoDevice));
457457 EXPECT_EQ (1u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
458+
459+ EXPECT_NE (nullptr , kernelInfo->kernelDescriptor .external .relocatedDebugData .get ());
460+ EXPECT_EQ (reinterpret_cast <char *>(kernelInfo->kernelDescriptor .external .relocatedDebugData .get ()), getMockDebuggerL0Hw<FamilyType>()->lastReceivedElf );
461+ }
462+
463+ HWTEST_F (ModuleWithDebuggerL0Test, GivenDebugDataWithoutRelocationsWhenInitializingModuleThenRegisterElfWithUnrelocatedElf) {
464+ NEO::MockCompilerEnableGuard mock (true );
465+ auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions ();
466+ neoDevice->getExecutionEnvironment ()->rootDeviceEnvironments [device->getRootDeviceIndex ()]->compilerInterface .reset (cip);
467+
468+ uint8_t binary[10 ];
469+ ze_module_desc_t moduleDesc = {};
470+ moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
471+ moduleDesc.pInputModule = binary;
472+ moduleDesc.inputSize = 10 ;
473+ ModuleBuildLog *moduleBuildLog = nullptr ;
474+
475+ std::unique_ptr<MockModule> moduleMock = std::make_unique<MockModule>(device, moduleBuildLog, ModuleType::User);
476+ moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(device);
477+
478+ uint32_t kernelHeap = 0 ;
479+ auto kernelInfo = new KernelInfo ();
480+ kernelInfo->heapInfo .KernelHeapSize = 1 ;
481+ kernelInfo->heapInfo .pKernelHeap = &kernelHeap;
482+
483+ Mock<::L0::Kernel> kernelMock;
484+ kernelMock.module = moduleMock.get ();
485+ kernelMock.immutableData .kernelInfo = kernelInfo;
486+ kernelInfo->kernelDescriptor .payloadMappings .implicitArgs .systemThreadSurfaceAddress .bindful = 0 ;
487+
488+ moduleMock->kernelImmData = &kernelMock.immutableData ;
489+ moduleMock->translationUnit ->programInfo .kernelInfos .push_back (kernelInfo);
490+
491+ kernelInfo->kernelDescriptor .external .debugData = std::make_unique<NEO::DebugData>();
492+
493+ std::vector<uint8_t > data;
494+ data.resize (4 );
495+ NEO::Elf::ElfEncoder<> elfEncoder;
496+ elfEncoder.getElfFileHeader ().type = NEO::Elf::SHT_PROGBITS;
497+ elfEncoder.appendSection (NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix, data);
498+ auto elfBinary = elfEncoder.encode ();
499+
500+ kernelInfo->kernelDescriptor .external .debugData ->vIsaSize = static_cast <uint32_t >(elfBinary.size ());
501+ kernelInfo->kernelDescriptor .external .debugData ->vIsa = reinterpret_cast <char *>(elfBinary.data ());
502+ kernelInfo->kernelDescriptor .external .debugData ->genIsa = nullptr ;
503+ kernelInfo->kernelDescriptor .external .debugData ->genIsaSize = 0 ;
504+
505+ EXPECT_EQ (0u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
506+ EXPECT_TRUE (moduleMock->initialize (&moduleDesc, neoDevice));
507+ EXPECT_EQ (1u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
508+
509+ EXPECT_EQ (nullptr , kernelInfo->kernelDescriptor .external .relocatedDebugData .get ());
510+ EXPECT_EQ (kernelInfo->kernelDescriptor .external .debugData ->vIsa , getMockDebuggerL0Hw<FamilyType>()->lastReceivedElf );
458511}
459512
460513HWTEST_F (ModuleWithDebuggerL0Test, GivenNoDebugDataWhenInitializingModuleThenDoNotRegisterElf) {
@@ -513,6 +566,10 @@ HWTEST_F(ModuleWithZebinAndL0DebuggerTest, GivenZebinDebugDataWhenInitializingMo
513566 moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(device);
514567 moduleMock->kernelImmDatas .push_back (std::move (kernelImmutableData));
515568
569+ kernelImmutableData = ::std::make_unique<KernelImmutableData>(device);
570+ kernelImmutableData->initialize (kernelInfo.get (), device, 0 , nullptr , nullptr , false );
571+ moduleMock->kernelImmDatas .push_back (std::move (kernelImmutableData));
572+
516573 auto zebin = ZebinTestData::ValidEmptyProgram ();
517574 moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(device);
518575 moduleMock->translationUnit ->unpackedDeviceBinarySize = zebin.storage .size ();
@@ -521,7 +578,7 @@ HWTEST_F(ModuleWithZebinAndL0DebuggerTest, GivenZebinDebugDataWhenInitializingMo
521578 zebin.storage .data (), zebin.storage .size ());
522579 EXPECT_EQ (0u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
523580 EXPECT_TRUE (moduleMock->initialize (&moduleDesc, neoDevice));
524- EXPECT_EQ (1u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
581+ EXPECT_EQ (2u , getMockDebuggerL0Hw<FamilyType>()->registerElfCount );
525582}
526583
527584HWTEST_F (ModuleWithZebinAndL0DebuggerTest, GivenZebinNoDebugDataWhenInitializingModuleThenDoNotRegisterElf) {
0 commit comments