Return attach flag when state save area header available

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-09-08 15:45:35 +00:00
committed by Compute-Runtime-Automation
parent 21ca54d314
commit 09e8bc4eda
4 changed files with 24 additions and 1 deletions

View File

@@ -600,6 +600,13 @@ ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pD
ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) {
bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable();
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*this->getNEODevice()).getStateSaveAreaHeader();
if (stateSaveAreaHeader.size() == 0) {
PRINT_DEBUGGER_INFO_LOG("Context state save area header missing", "");
isDebugAttachAvailable = false;
}
if (isDebugAttachAvailable && !isSubdevice) {
pDebugProperties->flags = zet_device_debug_property_flag_t::ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH;
} else {

View File

@@ -18,7 +18,7 @@ namespace ult {
void DeviceFixture::SetUp() { // NOLINT(readability-identifier-naming)
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
auto mockBuiltIns = new MockBuiltins();
mockBuiltIns = new MockBuiltins();
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));

View File

@@ -28,6 +28,7 @@ struct Context;
struct Device;
namespace ult {
class MockBuiltins;
struct DeviceFixture {
NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true);
@@ -38,6 +39,7 @@ struct DeviceFixture {
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
L0::ContextImp *context = nullptr;
MockBuiltins *mockBuiltIns = nullptr;
};
struct PageFaultDeviceFixture {

View File

@@ -10,6 +10,7 @@
#include "test.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h"
namespace L0 {
@@ -75,6 +76,19 @@ TEST_F(DebugApiTest, givenDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesRetur
EXPECT_EQ(ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH, debugProperties.flags);
}
TEST_F(DebugApiTest, givenStateSaveAreaHeaderUnavailableWhenGettingDebugPropertiesThenAttachFlagIsNotReturned) {
zet_device_debug_properties_t debugProperties = {};
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OsInterfaceWithDebugAttach);
mockBuiltIns->stateSaveAreaHeader.clear();
auto result = zetDeviceGetDebugProperties(device->toHandle(), &debugProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(0u, debugProperties.flags);
}
TEST_F(DebugApiTest, givenSubDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesReturnsNoFlag) {
zet_device_debug_properties_t debugProperties = {};
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;