diff --git a/level_zero/tools/source/debug/linux/debug_session.h b/level_zero/tools/source/debug/linux/debug_session.h index b021f8fe84..6c239664f0 100644 --- a/level_zero/tools/source/debug/linux/debug_session.h +++ b/level_zero/tools/source/debug/linux/debug_session.h @@ -192,7 +192,7 @@ struct DebugSessionLinux : DebugSessionImp { return pushApiEvent(debugEvent, invalidHandle); } - void pushApiEvent(zet_debug_event_t &debugEvent, uint64_t moduleHandle) { + MOCKABLE_VIRTUAL void pushApiEvent(zet_debug_event_t &debugEvent, uint64_t moduleHandle) { std::unique_lock lock(asyncThreadMutex); if (moduleHandle != invalidHandle && (debugEvent.flags & ZET_DEBUG_EVENT_FLAG_NEED_ACK)) { diff --git a/level_zero/tools/source/debug/linux/xe/debug_session.cpp b/level_zero/tools/source/debug/linux/xe/debug_session.cpp index 285f47c9ca..71a601404d 100644 --- a/level_zero/tools/source/debug/linux/xe/debug_session.cpp +++ b/level_zero/tools/source/debug/linux/xe/debug_session.cpp @@ -484,7 +484,6 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) { debugEvent.info.module.moduleEnd = reinterpret_cast(elfMetadata.data.get()) + elfMetadata.metadata.len; debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK; - pushApiEvent(debugEvent, metaDataEntry.metadata.metadata_handle); { std::lock_guard lock(asyncThreadMutex); if (vmBindData.vmBind.flags & DRM_XE_EUDEBUG_EVENT_VM_BIND_FLAG_UFENCE) { @@ -495,6 +494,7 @@ void DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) { } } } + pushApiEvent(debugEvent, metaDataEntry.metadata.metadata_handle); } if (shouldAckEvent && (vmBindData.vmBindUfence.base.flags & DRM_XE_EUDEBUG_EVENT_NEED_ACK)) { diff --git a/level_zero/tools/test/unit_tests/sources/debug/linux/xe/debug_session_fixtures_linux_xe.h b/level_zero/tools/test/unit_tests/sources/debug/linux/xe/debug_session_fixtures_linux_xe.h index e91e8229ca..fc91aae220 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/linux/xe/debug_session_fixtures_linux_xe.h +++ b/level_zero/tools/test/unit_tests/sources/debug/linux/xe/debug_session_fixtures_linux_xe.h @@ -225,6 +225,21 @@ struct MockDebugSessionLinuxXe : public L0::DebugSessionLinuxXe { return DebugSessionLinuxXe::getInternalEvent(); } + bool pushApiEventValidateAckEvents = false; + bool pushApiEventAckEventsFound = false; + void pushApiEvent(zet_debug_event_t &debugEvent, uint64_t moduleHandle) override { + if (pushApiEventValidateAckEvents) { + auto connection = clientHandleToConnection[clientHandle].get(); + for (auto module : connection->metaDataToModule) { + if (module.second.ackEvents[0].size() > 0) { + pushApiEventAckEventsFound = true; + break; + } + } + } + return DebugSessionLinux::pushApiEvent(debugEvent, moduleHandle); + } + bool readSystemRoutineIdentFromMemory(EuThread *thread, const void *stateSaveArea, SIP::sr_ident &srIdent) override { readSystemRoutineIdentFromMemoryCallCount++; srIdent.count = 0; diff --git a/level_zero/tools/test/unit_tests/sources/debug/linux/xe/test_debug_api_linux_xe.cpp b/level_zero/tools/test/unit_tests/sources/debug/linux/xe/test_debug_api_linux_xe.cpp index 9e7064b978..35020c2e92 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/linux/xe/test_debug_api_linux_xe.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/linux/xe/test_debug_api_linux_xe.cpp @@ -1310,6 +1310,7 @@ TEST_F(DebugApiLinuxTestXe, GivenVmBindOpMetadataCreateEventAndUfenceForProgramM client1.base.type = DRM_XE_EUDEBUG_EVENT_OPEN; client1.base.flags = DRM_XE_EUDEBUG_EVENT_CREATE; client1.client_handle = MockDebugSessionLinuxXe::mockClientHandle; + session->pushApiEventValidateAckEvents = true; session->handleEvent(reinterpret_cast(&client1)); auto &connection = session->clientHandleToConnection[MockDebugSessionLinuxXe::mockClientHandle]; @@ -1381,6 +1382,8 @@ TEST_F(DebugApiLinuxTestXe, GivenVmBindOpMetadataCreateEventAndUfenceForProgramM EXPECT_EQ(vmBindOpData.pendingNumExtensions, 0ull); EXPECT_EQ(vmBindOpData.vmBindOpMetadataVec.size(), 2ull); + EXPECT_TRUE(session->pushApiEventAckEventsFound); + EXPECT_EQ(connection->metaDataToModule[10].ackEvents->size(), 1ull); EXPECT_EQ(connection->metaDataToModule[10].ackEvents[0][0].seqno, vmBindUfence.base.seqno); EXPECT_EQ(connection->metaDataToModule[10].ackEvents[0][0].type, vmBindUfence.base.type);