fix: L0Debug - allow access only for reported stopped threads

- read/write registers/memory only allowed for threads reported as
stopped by events
- threads newly stopped, accidentally, that are resumed immediately
are not allowed register/memory access

Related-To: NEO-7776

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-03-02 14:11:02 +00:00
committed by Compute-Runtime-Automation
parent 93f32f96b1
commit 802848a43f
8 changed files with 95 additions and 5 deletions

View File

@@ -389,6 +389,7 @@ struct MockDebugSessionLinux : public L0::DebugSessionLinux {
allThreads[threadId] = std::make_unique<EuThread>(threadId);
}
allThreads[threadId]->stopThread(vmHandle);
allThreads[threadId]->reportAsStopped();
}
bool readSystemRoutineIdent(EuThread *thread, uint64_t vmHandle, SIP::sr_ident &srIdent) override {
@@ -536,6 +537,7 @@ struct MockTileDebugSessionLinux : TileDebugSessionLinux {
allThreads[threadId] = std::make_unique<EuThread>(threadId);
}
allThreads[threadId]->stopThread(vmHandle);
allThreads[threadId]->reportAsStopped();
}
bool writeResumeCommand(const std::vector<EuThread::ThreadId> &threadIds) override {

View File

@@ -285,11 +285,13 @@ TEST(DebugSessionLinuxTest, GivenDeviceWithSingleSliceWhenCallingAreRequestedThr
EuThread::ThreadId threadId(0, 0, 0, 0, 0);
sessionMock->allThreads[threadId]->stopThread(1u);
sessionMock->allThreads[threadId]->reportAsStopped();
uint32_t subDeviceCount = std::max(1u, neoDevice->getNumSubDevices());
for (uint32_t i = 0; i < subDeviceCount; i++) {
EuThread::ThreadId threadId(i, 0, 0, 0, 0);
sessionMock->allThreads[threadId]->stopThread(1u);
sessionMock->allThreads[threadId]->reportAsStopped();
}
stopped = sessionMock->areRequestedThreadsStopped(thread);
EXPECT_TRUE(stopped);
@@ -6541,6 +6543,7 @@ struct DebugApiRegistersAccessFixture : public DebugApiLinuxFixture {
session->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->vmToContextStateSaveAreaBindInfo[vmHandle] = {stateSaveAreaGpuVa, maxDbgSurfaceSize};
session->allThreadsStopped = true;
session->allThreads[stoppedThreadId]->stopThread(1u);
session->allThreads[stoppedThreadId]->reportAsStopped();
}
void tearDown() {