diff --git a/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp b/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp index 8cee87156c..aae512e9fa 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp @@ -16,9 +16,9 @@ #include "shared/source/os_interface/windows/wddm_memory_operations_handler.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" -#include "shared/test/common/mocks/mock_wddm.h" #include "shared/test/common/mocks/windows/mock_gdi_interface.h" #include "shared/test/common/mocks/windows/mock_gmm_memory_base.h" +#include "shared/test/common/mocks/windows/mock_wddm_eudebug.h" #include "shared/test/common/test_macros/test.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" @@ -32,14 +32,6 @@ using namespace NEO; namespace L0 { namespace ult { -struct WddmEuDebugInterfaceMock : public WddmMock { - WddmEuDebugInterfaceMock(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {} - - bool isDebugAttachAvailable() override { - return true; - } -}; - struct L0DebuggerWindowsFixture { void SetUp() { auto executionEnvironment = new NEO::ExecutionEnvironment(); diff --git a/shared/source/os_interface/windows/os_context_win.cpp b/shared/source/os_interface/windows/os_context_win.cpp index 377fd4c4b0..0454dcca86 100644 --- a/shared/source/os_interface/windows/os_context_win.cpp +++ b/shared/source/os_interface/windows/os_context_win.cpp @@ -7,6 +7,8 @@ #include "shared/source/os_interface/windows/os_context_win.h" +#include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/os_interface/os_interface.h" #include "shared/source/os_interface/windows/wddm/wddm.h" #include "shared/source/os_interface/windows/wddm/wddm_interface.h" @@ -26,6 +28,10 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, const EngineDescripto residencyController(wddm, contextId) {} void OsContextWin::initializeContext() { + + if (wddm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled()) { + debuggableContext = wddm.getRootDeviceEnvironment().osInterface->isDebugAttachAvailable() && !isInternalEngine(); + } auto wddmInterface = wddm.getWddmInterface(); UNRECOVERABLE_IF(!wddm.createContext(*this)); diff --git a/shared/source/os_interface/windows/os_context_win.h b/shared/source/os_interface/windows/os_context_win.h index 4cb256df4f..4fac6f0a94 100644 --- a/shared/source/os_interface/windows/os_context_win.h +++ b/shared/source/os_interface/windows/os_context_win.h @@ -35,6 +35,7 @@ class OsContextWin : public OsContext { MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; } static OsContext *create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor); void reInitializeContext() override; + MOCKABLE_VIRTUAL bool isDebuggableContext() { return debuggableContext; }; protected: void initializeContext() override; @@ -43,5 +44,6 @@ class OsContextWin : public OsContext { HardwareQueue hardwareQueue; Wddm &wddm; WddmResidencyController residencyController; + bool debuggableContext = false; }; } // namespace NEO diff --git a/shared/test/common/mocks/CMakeLists.txt b/shared/test/common/mocks/CMakeLists.txt index bc6c7d568d..531699c81b 100644 --- a/shared/test/common/mocks/CMakeLists.txt +++ b/shared/test/common/mocks/CMakeLists.txt @@ -100,6 +100,7 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_direct_submission.h + ${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_eudebug.h ) else() list(APPEND NEO_CORE_tests_mocks diff --git a/shared/test/common/mocks/windows/mock_wddm_eudebug.h b/shared/test/common/mocks/windows/mock_wddm_eudebug.h new file mode 100644 index 0000000000..f4cd6fa369 --- /dev/null +++ b/shared/test/common/mocks/windows/mock_wddm_eudebug.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mocks/mock_wddm.h" + +#pragma once + +namespace NEO { + +struct WddmEuDebugInterfaceMock : public WddmMock { + WddmEuDebugInterfaceMock(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {} + + bool isDebugAttachAvailable() override { + return true; + } +}; +} // namespace NEO \ No newline at end of file diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index 33bc67d07c..63f1cafff2 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -89,6 +89,14 @@ TEST_F(WddmTests, whenftrEuDebugIsFalseThenDebuggingEnabledReturnsFalse) { EXPECT_FALSE(wddm->isDebugAttachAvailable()); } +TEST_F(WddmTests, whenProgramDebugIsEnabledAndCreatingContextWithInternalEngineThenDebuggableContextReturnsFalse) { + executionEnvironment->setDebuggingEnabled(); + wddm->init(); + OsContextWin osContext(*wddm, 5u, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::Internal})); + osContext.ensureContextInitialized(); + EXPECT_FALSE(osContext.isDebuggableContext()); +} + TEST(WddmPciSpeedInfoTest, WhenGetPciSpeedInfoIsCalledThenUnknownIsReturned) { MockExecutionEnvironment executionEnvironment; RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);