L0Debug: Fix for possible crash while passing set of threads

- zetDebugRead/WriteRegisters() only accept single thread

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-07-14 17:50:12 +00:00
committed by Compute-Runtime-Automation
parent 4147f40970
commit b89ebb3dd2
2 changed files with 16 additions and 1 deletions

View File

@ -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()) {

View File

@ -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);