Skip to content

Commit 771298c

Browse files
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>
1 parent fb336d1 commit 771298c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

level_zero/tools/source/debug/debug_session_imp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,11 @@ bool DebugSessionImp::checkThreadIsResumed(const EuThread::ThreadId &threadID) {
388388
auto srMagicOffset = threadSlotOffset + getStateSaveAreaHeader()->regHeader.sr_magic_offset;
389389
SIP::sr_ident srMagic;
390390
memset(srMagic.magic, 0, sizeof(SIP::sr_ident::magic));
391-
readGpuMemory(thread->getMemoryHandle(), reinterpret_cast<char *>(&srMagic), sizeof(srMagic), gpuVa + srMagicOffset);
392391

393-
if (0 != strcmp(srMagic.magic, "srmagic")) {
392+
auto status = readGpuMemory(thread->getMemoryHandle(), reinterpret_cast<char *>(&srMagic), sizeof(srMagic), gpuVa + srMagicOffset);
393+
DEBUG_BREAK_IF(status != ZE_RESULT_SUCCESS);
394+
395+
if (status != ZE_RESULT_SUCCESS || 0 != strcmp(srMagic.magic, "srmagic")) {
394396
PRINT_DEBUGGER_ERROR_LOG("checkThreadIsResumed - Failed to read srMagic for thread %s\n", EuThread::toString(threadID).c_str());
395397
return resumed;
396398
}

level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,28 @@ TEST(DebugSessionTest, whenCallingCheckThreadIsResumedWithoutSrMagicThenThreadIs
898898
EXPECT_EQ(1u, sessionMock->checkThreadIsResumedCalled);
899899
}
900900

901+
TEST(DebugSessionTest, givenErrorFromReadGpuMemoryWhenCallingCheckThreadIsResumedThenThreadIsAssumedRunning) {
902+
zet_debug_config_t config = {};
903+
config.pid = 0x1234;
904+
auto hwInfo = *NEO::defaultHwInfo.get();
905+
906+
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
907+
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
908+
909+
auto sessionMock = std::make_unique<MockDebugSession>(config, &deviceImp);
910+
ASSERT_NE(nullptr, sessionMock);
911+
sessionMock->skipCheckThreadIsResumed = false;
912+
sessionMock->readMemoryResult = ZE_RESULT_ERROR_UNKNOWN;
913+
sessionMock->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
914+
915+
ze_device_thread_t thread = {0, 0, 0, 0};
916+
EuThread::ThreadId threadId(0, thread);
917+
bool resumed = sessionMock->checkThreadIsResumed(threadId);
918+
919+
EXPECT_TRUE(resumed);
920+
EXPECT_EQ(1u, sessionMock->checkThreadIsResumedCalled);
921+
}
922+
901923
TEST(DebugSessionTest, givenSrMagicWithCounterLessThanlLastThreadCounterThenThreadHasBeenResumed) {
902924
class InternalMockDebugSession : public MockDebugSession {
903925
public:

0 commit comments

Comments
 (0)