mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
L0Debug - close connection when releasing Device resources
- when debugDetach() is not called properly, close connection in debug session before Device is destroyed Related-To: NEO-7366 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9cd47ffeaf
commit
fddd1976c1
@@ -875,8 +875,8 @@ const SIP::regset_desc *DebugSessionImp::getSbaRegsetDesc() {
|
||||
const SIP::regset_desc *DebugSessionImp::typeToRegsetDesc(uint32_t type) {
|
||||
auto pStateSaveAreaHeader = getStateSaveAreaHeader();
|
||||
|
||||
DEBUG_BREAK_IF(pStateSaveAreaHeader == nullptr);
|
||||
if (pStateSaveAreaHeader == nullptr) {
|
||||
DEBUG_BREAK_IF(pStateSaveAreaHeader == nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -343,6 +343,22 @@ struct MockDebugSession : public L0::DebugSessionImp {
|
||||
|
||||
using DebugSessionTest = ::testing::Test;
|
||||
|
||||
TEST(DeviceWithDebugSessionTest, GivenDeviceWithDebugSessionWhenCallingReleaseResourcesThenCloseConnectionIsCalled) {
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
std::unique_ptr<DriverHandleImp> driverHandle(new DriverHandleImp);
|
||||
auto hwInfo = *NEO::defaultHwInfo;
|
||||
auto neoDevice = std::unique_ptr<NEO::Device>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
auto device = std::unique_ptr<L0::Device>(Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue));
|
||||
ASSERT_NE(nullptr, device);
|
||||
|
||||
zet_debug_config_t config = {};
|
||||
auto session = new DebugSessionMock(config, device.get());
|
||||
static_cast<DeviceImp *>(device.get())->setDebugSession(session);
|
||||
static_cast<DeviceImp *>(device.get())->releaseResources();
|
||||
|
||||
EXPECT_TRUE(session->closeConnectionCalled);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenNullDeviceWhenDebugSessionCreatedThenAllThreadsAreEmpty) {
|
||||
auto sessionMock = std::make_unique<MockDebugSession>(zet_debug_config_t{0x1234}, nullptr);
|
||||
EXPECT_TRUE(sessionMock->allThreads.empty());
|
||||
|
||||
@@ -36,7 +36,10 @@ struct DebugSessionMock : public L0::DebugSession {
|
||||
using L0::DebugSession::isBindlessSystemRoutine;
|
||||
|
||||
DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device), config(config){};
|
||||
bool closeConnection() override { return true; }
|
||||
bool closeConnection() override {
|
||||
closeConnectionCalled = true;
|
||||
return true;
|
||||
}
|
||||
ze_result_t initialize() override {
|
||||
if (config.pid == 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
@@ -90,6 +93,7 @@ struct DebugSessionMock : public L0::DebugSession {
|
||||
|
||||
zet_debug_config_t config;
|
||||
bool asyncThreadStarted = false;
|
||||
bool closeConnectionCalled = false;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
Reference in New Issue
Block a user