fix: ignore ZET_ENABLE_PROGRAM_DEBUGGING when system misconfigured

- if debug not enabled in the system, ignore env var for enabling
debugging

Resolves: NEO-10370

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2024-02-16 13:33:15 +00:00
committed by Compute-Runtime-Automation
parent f56babb2a9
commit d9b662a735
3 changed files with 36 additions and 13 deletions

View File

@@ -231,6 +231,13 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
const auto rootDeviceIndex = neoDevice->getRootDeviceIndex();
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
if (osInterface && !osInterface->isDebugAttachAvailable() && enableProgramDebugging != NEO::DebuggingMode::disabled) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"Debug mode is not enabled in the system.\n");
enableProgramDebugging = NEO::DebuggingMode::disabled;
}
enableRootDeviceDebugger(neoDevice);
this->rootDeviceIndices.pushUnique(rootDeviceIndex);
@@ -242,13 +249,6 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
auto device = Device::create(this, pNeoDevice, false, &returnValue);
this->devices.push_back(device);
auto osInterface = device->getNEODevice()->getRootDeviceEnvironment().osInterface.get();
if (osInterface && !osInterface->isDebugAttachAvailable() && enableProgramDebugging != NEO::DebuggingMode::disabled) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"Debug mode is not enabled in the system.\n");
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
}
multiOsContextDriver |= device->isImplicitScalingCapable();
if (returnValue != ZE_RESULT_SUCCESS) {
return returnValue;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -42,6 +42,7 @@ struct L0DebuggerLinuxFixture {
executionEnvironment->initializeMemoryManager();
auto osInterface = new OSInterface();
drmMock = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock->allowDebugAttach = true;
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<Drm>(drmMock));
@@ -414,7 +415,10 @@ HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledAndDebugAttachAvailableWhenIn
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
}
HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledAndDebugAttachNotAvailableWhenInitializingDriverThenErrorIsReturned) {
HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledAndDebugAttachNotAvailableWhenInitializingDriverThenErrorIsPrintedButNotReturned) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.PrintDebugMessages.set(1);
auto executionEnvironment = new NEO::ExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
@@ -434,8 +438,15 @@ HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledAndDebugAttachNotAvailableWhe
drmMock->allowDebugAttach = false;
::testing::internal::CaptureStderr();
ze_result_t result = driverHandle->initialize(std::move(devices));
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
auto output = testing::internal::GetCapturedStderr();
EXPECT_EQ(std::string("Debug mode is not enabled in the system.\n"), output);
EXPECT_EQ(NEO::DebuggingMode::disabled, driverHandle->enableProgramDebugging);
EXPECT_EQ(nullptr, neoDevice->getL0Debugger());
}
HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledWhenImmCommandListsCreatedAndDestroyedThenDebuggerL0IsNotified) {
@@ -549,6 +560,7 @@ HWTEST_F(L0DebuggerLinuxMultitileTest, givenSubDeviceFilteredByAffinityMaskWhenC
executionEnvironment->initializeMemoryManager();
auto osInterface = new OSInterface();
auto drmMock = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock->allowDebugAttach = true;
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<Drm>(drmMock));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -225,7 +225,10 @@ TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledAndDebugAttachAvailabl
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
}
TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledAndDebugAttachNotAvailableWhenInitializingDriverThenErrorIsReturned) {
TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledAndDebugAttachNotAvailableWhenInitializingDriverThenErrorIsPrintedButNotReturned) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.PrintDebugMessages.set(1);
auto executionEnvironment = new NEO::ExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
@@ -251,8 +254,16 @@ TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledAndDebugAttachNotAvail
driverHandle->enableProgramDebugging = NEO::DebuggingMode::online;
wddm->debugAttachAvailable = false;
::testing::internal::CaptureStderr();
ze_result_t result = driverHandle->initialize(std::move(devices));
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
auto output = testing::internal::GetCapturedStderr();
EXPECT_EQ(std::string("Debug mode is not enabled in the system.\n"), output);
EXPECT_EQ(NEO::DebuggingMode::disabled, driverHandle->enableProgramDebugging);
EXPECT_EQ(nullptr, neoDevice->getL0Debugger());
}
} // namespace ult