L0Debugger - add DEBUG_BREAK when readGpuMemory fails

- break in checkThreadIsResumed() when memory read fails
unexpectedly

Related-To: NEO-6763

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-05-17 17:38:50 +00:00
committed by Compute-Runtime-Automation
parent fb336d1b57
commit 771298c6e2
2 changed files with 26 additions and 2 deletions

View File

@@ -388,9 +388,11 @@ bool DebugSessionImp::checkThreadIsResumed(const EuThread::ThreadId &threadID) {
auto srMagicOffset = threadSlotOffset + getStateSaveAreaHeader()->regHeader.sr_magic_offset;
SIP::sr_ident srMagic;
memset(srMagic.magic, 0, sizeof(SIP::sr_ident::magic));
readGpuMemory(thread->getMemoryHandle(), reinterpret_cast<char *>(&srMagic), sizeof(srMagic), gpuVa + srMagicOffset);
if (0 != strcmp(srMagic.magic, "srmagic")) {
auto status = readGpuMemory(thread->getMemoryHandle(), reinterpret_cast<char *>(&srMagic), sizeof(srMagic), gpuVa + srMagicOffset);
DEBUG_BREAK_IF(status != ZE_RESULT_SUCCESS);
if (status != ZE_RESULT_SUCCESS || 0 != strcmp(srMagic.magic, "srmagic")) {
PRINT_DEBUGGER_ERROR_LOG("checkThreadIsResumed - Failed to read srMagic for thread %s\n", EuThread::toString(threadID).c_str());
return resumed;
}

View File

@@ -898,6 +898,28 @@ TEST(DebugSessionTest, whenCallingCheckThreadIsResumedWithoutSrMagicThenThreadIs
EXPECT_EQ(1u, sessionMock->checkThreadIsResumedCalled);
}
TEST(DebugSessionTest, givenErrorFromReadGpuMemoryWhenCallingCheckThreadIsResumedThenThreadIsAssumedRunning) {
zet_debug_config_t config = {};
config.pid = 0x1234;
auto hwInfo = *NEO::defaultHwInfo.get();
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
auto sessionMock = std::make_unique<MockDebugSession>(config, &deviceImp);
ASSERT_NE(nullptr, sessionMock);
sessionMock->skipCheckThreadIsResumed = false;
sessionMock->readMemoryResult = ZE_RESULT_ERROR_UNKNOWN;
sessionMock->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
ze_device_thread_t thread = {0, 0, 0, 0};
EuThread::ThreadId threadId(0, thread);
bool resumed = sessionMock->checkThreadIsResumed(threadId);
EXPECT_TRUE(resumed);
EXPECT_EQ(1u, sessionMock->checkThreadIsResumedCalled);
}
TEST(DebugSessionTest, givenSrMagicWithCounterLessThanlLastThreadCounterThenThreadHasBeenResumed) {
class InternalMockDebugSession : public MockDebugSession {
public: