Add windows debugger feature check

Related-To: NEO-6717
Signed-off-by: Yates, Brandon <brandon.yates@intel.com>
This commit is contained in:
Yates, Brandon 2022-05-11 22:36:36 +00:00 committed by Compute-Runtime-Automation
parent 3f04769f07
commit 65214e2e4c
10 changed files with 154 additions and 4 deletions

View File

@ -8,12 +8,21 @@
#include "shared/source/device/device.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/kernel/debug_data.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "level_zero/core/source/debugger/debugger_l0.h"
namespace L0 {
bool DebuggerL0::initDebuggingInOs(NEO::OSInterface *osInterface) {
return false;
if (osInterface == nullptr) {
return false;
}
if (osInterface->isDebugAttachAvailable() == false) {
return false;
}
return true;
}
void DebuggerL0::registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -9,6 +9,15 @@
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::unique_ptr<NEO::Debugger>(nullptr);
auto &hwInfo = device->getHardwareInfo();
if (!hwInfo.capabilityTable.l0DebuggerSupported) {
return std::unique_ptr<DebuggerL0>(nullptr);
}
auto success = initDebuggingInOs(device->getRootDeviceEnvironment().osInterface.get());
if (success) {
auto debugger = debuggerL0Factory[device->getHardwareInfo().platform.eRenderCoreFamily](device);
return std::unique_ptr<DebuggerL0>(debugger);
}
return std::unique_ptr<DebuggerL0>(nullptr);
}
} // namespace L0

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@ -0,0 +1,12 @@
#
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_l0_debugger_windows.cpp
)
endif()

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/gdi_interface.h"
#include "shared/source/os_interface/windows/os_context_win.h"
#include "shared/source/os_interface/windows/os_environment_win.h"
#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/test_macros/test.h"
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
#include <algorithm>
#include <memory>
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();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->setDebuggingEnabled();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
auto osEnvironment = new OsEnvironmentWin();
gdi = new MockGdi();
osEnvironment->gdi.reset(gdi);
executionEnvironment->osEnvironment.reset(osEnvironment);
wddm = new WddmEuDebugInterfaceMock(*rootDeviceEnvironment);
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
wddm->init();
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, 0u);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->enableProgramDebugging = true;
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
void TearDown() {
}
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
WddmEuDebugInterfaceMock *wddm = nullptr;
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
MockGdi *gdi = nullptr;
};
using L0DebuggerWindowsTest = Test<L0DebuggerWindowsFixture>;
TEST_F(L0DebuggerWindowsTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreatedThenItAllocatesL0Debugger) {
EXPECT_NE(nullptr, neoDevice->getDebugger());
EXPECT_FALSE(neoDevice->getDebugger()->isLegacy());
EXPECT_EQ(nullptr, neoDevice->getSourceLevelDebugger());
}
} // namespace ult
} // namespace L0

View File

@ -112,6 +112,7 @@ set(NEO_CORE_OS_INTERFACE_WDDM
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm${BRANCH_DIR_SUFFIX}/init_context_private_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm${BRANCH_DIR_SUFFIX}/wddm_debug_interface.cpp
)
if(NOT WIN32 AND NOT DISABLE_WDDM_LINUX)

View File

@ -6,6 +6,7 @@
*/
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
@ -15,6 +16,9 @@ bool OSInterface::gpuIdleImplicitFlush = false;
bool OSInterface::requiresSupportForWddmTrimNotification = true;
bool OSInterface::isDebugAttachAvailable() const {
if (driverModel) {
return driverModel->as<NEO::Wddm>()->isDebugAttachAvailable();
}
return false;
}

View File

@ -111,6 +111,7 @@ class Wddm : public DriverModel {
MOCKABLE_VIRTUAL void virtualFree(void *ptr, size_t size);
MOCKABLE_VIRTUAL bool isShutdownInProgress();
MOCKABLE_VIRTUAL bool isDebugAttachAvailable();
bool isGpuHangDetected(OsContext &osContext) override;

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
bool Wddm::isDebugAttachAvailable() {
return false;
}
} // namespace NEO

View File

@ -83,6 +83,11 @@ TEST_F(WddmTests, whenCreatingContextWithPowerHintSuccessIsReturned) {
EXPECT_TRUE(wddm->createContext(*newContext));
}
TEST_F(WddmTests, whenftrEuDebugIsFalseThenDebuggingEnabledReturnsFalse) {
init();
EXPECT_FALSE(wddm->isDebugAttachAvailable());
}
TEST(WddmPciSpeedInfoTest, WhenGetPciSpeedInfoIsCalledThenUnknownIsReturned) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);