diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index 63d6754efd..734a5c1964 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -196,7 +196,11 @@ ze_result_t DriverHandleImp::initialize(std::vector } if (enableProgramDebugging) { - UNRECOVERABLE_IF(neoDevice->getDebugger() != nullptr && enableProgramDebugging); + if (neoDevice->getDebugger() != nullptr) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, + "%s", "Source Level Debugger cannot be used with Environment Variable enabling program debugging.\n"); + UNRECOVERABLE_IF(neoDevice->getDebugger() != nullptr && enableProgramDebugging); + } neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->debugger = DebuggerL0::create(neoDevice.get()); } diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp index 31155df3a6..74598e71a0 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp @@ -271,5 +271,33 @@ TEST_F(TwoSubDevicesDebuggerEnabledTest, givenDebuggingEnabledWhenSubDevicesAreC EXPECT_EQ(deviceL0->getDebugSurface(), subDevice0->getDebugSurface()); } +TEST(Debugger, GivenLegacyDebuggerAndProgramDebuggingEnabledWhenInitializingDriverThenAbortIsCalledAfterPrintingError) { + DebugManagerStateRestore restorer; + NEO::DebugManager.flags.PrintDebugMessages.set(1); + + ::testing::internal::CaptureStderr(); + auto executionEnvironment = new NEO::ExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(1); + + executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockSourceLevelDebugger()); + auto hwInfo = *NEO::defaultHwInfo.get(); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo); + executionEnvironment->initializeMemoryManager(); + + executionEnvironment->setDebuggingEnabled(); + + auto neoDevice = NEO::MockDevice::create(executionEnvironment, 0u); + + NEO::DeviceVector devices; + devices.push_back(std::unique_ptr(neoDevice)); + auto driverHandle = std::make_unique>(); + driverHandle->enableProgramDebugging = true; + + EXPECT_THROW(driverHandle->initialize(std::move(devices)), std::exception); + std::string output = testing::internal::GetCapturedStderr(); + + EXPECT_EQ(std::string("Source Level Debugger cannot be used with Environment Variable enabling program debugging.\n"), output); +} + } // namespace ult } // namespace L0