L0Debug - close debug fd when DebugSession is destroyed

- after last tile DebugSession is detached, root DebugSession
must close fd

Related-To: NEO-5784

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-08-24 12:03:47 +00:00
committed by Compute-Runtime-Automation
parent ca0686b404
commit aa59ee94b2
5 changed files with 73 additions and 12 deletions

View File

@@ -47,6 +47,7 @@ DebugSessionLinux::~DebugSessionLinux() {
delete session.first;
}
tileSessions.resize(0);
closeFd();
}
DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *device, ze_result_t &result) {
@@ -341,6 +342,21 @@ void DebugSessionLinux::closeAsyncThread() {
internalEventThread.close();
}
bool DebugSessionLinux::closeFd() {
if (fd == 0) {
return false;
}
auto res = NEO::SysCalls::close(fd);
if (res != 0) {
PRINT_DEBUGGER_ERROR_LOG("Debug connection close() on fd: %d failed: retCode: %d\n", fd, res);
return false;
}
fd = 0;
return true;
}
std::unique_ptr<uint64_t[]> DebugSessionLinux::getInternalEvent() {
std::unique_ptr<uint64_t[]> eventMemory;
@@ -427,18 +443,8 @@ void DebugSessionLinux::readInternalEventsAsync() {
bool DebugSessionLinux::closeConnection() {
closeAsyncThread();
internalEventThread.close();
if (fd == 0) {
return false;
}
auto res = NEO::SysCalls::close(fd);
if (res != 0) {
PRINT_DEBUGGER_ERROR_LOG("Debug connection close() on fd: %d failed: retCode: %d\n", fd, res);
return false;
}
return true;
closeInternalEventsThread();
return closeFd();
}
void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {