diff --git a/level_zero/tools/source/debug/debug_session_imp.cpp b/level_zero/tools/source/debug/debug_session_imp.cpp index 64973e22d4..2328f76f9b 100644 --- a/level_zero/tools/source/debug/debug_session_imp.cpp +++ b/level_zero/tools/source/debug/debug_session_imp.cpp @@ -1005,6 +1005,9 @@ ze_result_t DebugSessionImp::registersAccessHelper(const EuThread *thread, const } ze_result_t DebugSessionImp::readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) { + if (!isSingleThread(thread)) { + return ZE_RESULT_ERROR_NOT_AVAILABLE; + } auto threadId = convertToThreadId(thread); if (!allThreads[threadId]->isStopped()) { @@ -1033,6 +1036,9 @@ ze_result_t DebugSessionImp::readRegistersImp(EuThread::ThreadId threadId, uint3 } ze_result_t DebugSessionImp::writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) { + if (!isSingleThread(thread)) { + return ZE_RESULT_ERROR_NOT_AVAILABLE; + } auto threadId = convertToThreadId(thread); if (!allThreads[threadId]->isStopped()) { diff --git a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp index f12fc858bc..8c234202db 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp @@ -1754,13 +1754,22 @@ TEST_F(DebugSessionRegistersAccessTest, givenInvalidRegistersIndicesWhenReadRegi EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zetDebugReadRegisters(session->toHandle(), stoppedThread, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 127, 2, nullptr)); } -TEST_F(DebugSessionRegistersAccessTest, givenInvalidRegistersIndicesWheniWriteRegistersCalledThenErrorInvalidArgumentIsReturned) { +TEST_F(DebugSessionRegistersAccessTest, givenInvalidRegistersIndicesWhenWriteRegistersCalledThenErrorInvalidArgumentIsReturned) { session->areRequestedThreadsStoppedReturnValue = 1; session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2); EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zetDebugWriteRegisters(session->toHandle(), stoppedThread, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 128, 1, nullptr)); EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zetDebugWriteRegisters(session->toHandle(), stoppedThread, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 127, 2, nullptr)); } +TEST_F(DebugSessionRegistersAccessTest, givenThreadAllWhenReadWriteRegistersCalledThenErrorNotAvailableIsReturned) { + session->areRequestedThreadsStoppedReturnValue = 1; + session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2); + + ze_device_thread_t threadAll = {UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX}; + EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zetDebugReadRegisters(session->toHandle(), threadAll, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 0, 1, nullptr)); + EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zetDebugWriteRegisters(session->toHandle(), threadAll, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 0, 2, nullptr)); +} + TEST_F(DebugSessionRegistersAccessTest, givenNotReportedRegisterSetAndValidRegisterIndicesWhenReadRegistersCalledThenErrorInvalidArgumentIsReturned) { session->areRequestedThreadsStoppedReturnValue = 1; session->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);