Skip to content

Commit 09e8bc4

Browse files
Return attach flag when state save area header available
Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 21ca54d commit 09e8bc4

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,13 @@ ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pD
600600

601601
ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) {
602602
bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable();
603+
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*this->getNEODevice()).getStateSaveAreaHeader();
604+
605+
if (stateSaveAreaHeader.size() == 0) {
606+
PRINT_DEBUGGER_INFO_LOG("Context state save area header missing", "");
607+
isDebugAttachAvailable = false;
608+
}
609+
603610
if (isDebugAttachAvailable && !isSubdevice) {
604611
pDebugProperties->flags = zet_device_debug_property_flag_t::ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH;
605612
} else {

level_zero/core/test/unit_tests/fixtures/device_fixture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ult {
1818

1919
void DeviceFixture::SetUp() { // NOLINT(readability-identifier-naming)
2020
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
21-
auto mockBuiltIns = new MockBuiltins();
21+
mockBuiltIns = new MockBuiltins();
2222
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
2323
NEO::DeviceVector devices;
2424
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));

level_zero/core/test/unit_tests/fixtures/device_fixture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct Context;
2828
struct Device;
2929

3030
namespace ult {
31+
class MockBuiltins;
3132

3233
struct DeviceFixture {
3334
NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true);
@@ -38,6 +39,7 @@ struct DeviceFixture {
3839
NEO::MockDevice *neoDevice = nullptr;
3940
L0::Device *device = nullptr;
4041
L0::ContextImp *context = nullptr;
42+
MockBuiltins *mockBuiltIns = nullptr;
4143
};
4244

4345
struct PageFaultDeviceFixture {

level_zero/tools/test/unit_tests/sources/debug/test_debug_api.inl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "test.h"
1111

1212
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
13+
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
1314
#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h"
1415

1516
namespace L0 {
@@ -75,6 +76,19 @@ TEST_F(DebugApiTest, givenDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesRetur
7576
EXPECT_EQ(ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH, debugProperties.flags);
7677
}
7778

79+
TEST_F(DebugApiTest, givenStateSaveAreaHeaderUnavailableWhenGettingDebugPropertiesThenAttachFlagIsNotReturned) {
80+
zet_device_debug_properties_t debugProperties = {};
81+
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;
82+
83+
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OsInterfaceWithDebugAttach);
84+
mockBuiltIns->stateSaveAreaHeader.clear();
85+
86+
auto result = zetDeviceGetDebugProperties(device->toHandle(), &debugProperties);
87+
88+
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
89+
EXPECT_EQ(0u, debugProperties.flags);
90+
}
91+
7892
TEST_F(DebugApiTest, givenSubDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesReturnsNoFlag) {
7993
zet_device_debug_properties_t debugProperties = {};
8094
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;

0 commit comments

Comments
 (0)