Skip to content

Commit adc51c1

Browse files
bmyatesCompute-Runtime-Automation
authored andcommitted
Set context debuggable when debugging is enabled
Related-to: NEO-6896 Signed-off-by: Yates, Brandon <brandon.yates@intel.com>
1 parent 5b297ba commit adc51c1

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

level_zero/core/test/unit_tests/sources/debugger/windows/test_l0_debugger_windows.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
1717
#include "shared/test/common/helpers/default_hw_info.h"
1818
#include "shared/test/common/helpers/engine_descriptor_helper.h"
19-
#include "shared/test/common/mocks/mock_wddm.h"
2019
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
2120
#include "shared/test/common/mocks/windows/mock_gmm_memory_base.h"
21+
#include "shared/test/common/mocks/windows/mock_wddm_eudebug.h"
2222
#include "shared/test/common/test_macros/test.h"
2323

2424
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
@@ -32,14 +32,6 @@ using namespace NEO;
3232
namespace L0 {
3333
namespace ult {
3434

35-
struct WddmEuDebugInterfaceMock : public WddmMock {
36-
WddmEuDebugInterfaceMock(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
37-
38-
bool isDebugAttachAvailable() override {
39-
return true;
40-
}
41-
};
42-
4335
struct L0DebuggerWindowsFixture {
4436
void SetUp() {
4537
auto executionEnvironment = new NEO::ExecutionEnvironment();

shared/source/os_interface/windows/os_context_win.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "shared/source/os_interface/windows/os_context_win.h"
99

10+
#include "shared/source/execution_environment/execution_environment.h"
11+
#include "shared/source/execution_environment/root_device_environment.h"
1012
#include "shared/source/os_interface/os_interface.h"
1113
#include "shared/source/os_interface/windows/wddm/wddm.h"
1214
#include "shared/source/os_interface/windows/wddm/wddm_interface.h"
@@ -26,6 +28,10 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, const EngineDescripto
2628
residencyController(wddm, contextId) {}
2729

2830
void OsContextWin::initializeContext() {
31+
32+
if (wddm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled()) {
33+
debuggableContext = wddm.getRootDeviceEnvironment().osInterface->isDebugAttachAvailable() && !isInternalEngine();
34+
}
2935
auto wddmInterface = wddm.getWddmInterface();
3036
UNRECOVERABLE_IF(!wddm.createContext(*this));
3137

shared/source/os_interface/windows/os_context_win.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class OsContextWin : public OsContext {
3535
MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; }
3636
static OsContext *create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor);
3737
void reInitializeContext() override;
38+
MOCKABLE_VIRTUAL bool isDebuggableContext() { return debuggableContext; };
3839

3940
protected:
4041
void initializeContext() override;
@@ -43,5 +44,6 @@ class OsContextWin : public OsContext {
4344
HardwareQueue hardwareQueue;
4445
Wddm &wddm;
4546
WddmResidencyController residencyController;
47+
bool debuggableContext = false;
4648
};
4749
} // namespace NEO

shared/test/common/mocks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ if(WIN32)
100100
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.cpp
101101
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.h
102102
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_direct_submission.h
103+
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_eudebug.h
103104
)
104105
else()
105106
list(APPEND NEO_CORE_tests_mocks
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/test/common/mocks/mock_wddm.h"
9+
10+
#pragma once
11+
12+
namespace NEO {
13+
14+
struct WddmEuDebugInterfaceMock : public WddmMock {
15+
WddmEuDebugInterfaceMock(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
16+
17+
bool isDebugAttachAvailable() override {
18+
return true;
19+
}
20+
};
21+
} // namespace NEO

shared/test/unit_test/os_interface/windows/wddm_tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ TEST_F(WddmTests, whenftrEuDebugIsFalseThenDebuggingEnabledReturnsFalse) {
8989
EXPECT_FALSE(wddm->isDebugAttachAvailable());
9090
}
9191

92+
TEST_F(WddmTests, whenProgramDebugIsEnabledAndCreatingContextWithInternalEngineThenDebuggableContextReturnsFalse) {
93+
executionEnvironment->setDebuggingEnabled();
94+
wddm->init();
95+
OsContextWin osContext(*wddm, 5u, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::Internal}));
96+
osContext.ensureContextInitialized();
97+
EXPECT_FALSE(osContext.isDebuggableContext());
98+
}
99+
92100
TEST(WddmPciSpeedInfoTest, WhenGetPciSpeedInfoIsCalledThenUnknownIsReturned) {
93101
MockExecutionEnvironment executionEnvironment;
94102
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);

0 commit comments

Comments
 (0)