Print debug string with error when legacy debugger used with env

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-03-15 16:05:15 +01:00
committed by Compute-Runtime-Automation
parent 3f5b9df122
commit 3bbbe9facb
2 changed files with 33 additions and 1 deletions

View File

@@ -196,7 +196,11 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
}
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());
}

View File

@@ -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<NEO::MockDevice>(executionEnvironment, 0u);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
auto driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
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