Skip to content

Commit 3bbbe9f

Browse files
Print debug string with error when legacy debugger used with env
Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 3f5b9df commit 3bbbe9f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

level_zero/core/source/driver/driver_handle_imp.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
196196
}
197197

198198
if (enableProgramDebugging) {
199-
UNRECOVERABLE_IF(neoDevice->getDebugger() != nullptr && enableProgramDebugging);
199+
if (neoDevice->getDebugger() != nullptr) {
200+
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
201+
"%s", "Source Level Debugger cannot be used with Environment Variable enabling program debugging.\n");
202+
UNRECOVERABLE_IF(neoDevice->getDebugger() != nullptr && enableProgramDebugging);
203+
}
200204
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->debugger = DebuggerL0::create(neoDevice.get());
201205
}
202206

level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,33 @@ TEST_F(TwoSubDevicesDebuggerEnabledTest, givenDebuggingEnabledWhenSubDevicesAreC
271271
EXPECT_EQ(deviceL0->getDebugSurface(), subDevice0->getDebugSurface());
272272
}
273273

274+
TEST(Debugger, GivenLegacyDebuggerAndProgramDebuggingEnabledWhenInitializingDriverThenAbortIsCalledAfterPrintingError) {
275+
DebugManagerStateRestore restorer;
276+
NEO::DebugManager.flags.PrintDebugMessages.set(1);
277+
278+
::testing::internal::CaptureStderr();
279+
auto executionEnvironment = new NEO::ExecutionEnvironment();
280+
executionEnvironment->prepareRootDeviceEnvironments(1);
281+
282+
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockSourceLevelDebugger());
283+
auto hwInfo = *NEO::defaultHwInfo.get();
284+
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo);
285+
executionEnvironment->initializeMemoryManager();
286+
287+
executionEnvironment->setDebuggingEnabled();
288+
289+
auto neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, 0u);
290+
291+
NEO::DeviceVector devices;
292+
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
293+
auto driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
294+
driverHandle->enableProgramDebugging = true;
295+
296+
EXPECT_THROW(driverHandle->initialize(std::move(devices)), std::exception);
297+
std::string output = testing::internal::GetCapturedStderr();
298+
299+
EXPECT_EQ(std::string("Source Level Debugger cannot be used with Environment Variable enabling program debugging.\n"), output);
300+
}
301+
274302
} // namespace ult
275303
} // namespace L0

0 commit comments

Comments
 (0)