feature(debugger): Create DebugSessionLinux class

DebugSessionLinux is common base class for all linux dbgUMD
implementations. This patch also moves DrmHelper to common debug folder

Related-to: NEO-8404

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates
2023-10-23 23:35:40 +00:00
committed by Compute-Runtime-Automation
parent 69f614a8c2
commit 157d7a327a
7 changed files with 44 additions and 26 deletions

View File

@@ -9,6 +9,7 @@ if(UNIX)
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debug_session.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_helper.cpp
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
@@ -16,7 +17,6 @@ if(UNIX)
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/prelim/debug_session.cpp
${CMAKE_CURRENT_SOURCE_DIR}/prelim/debug_session.h
${CMAKE_CURRENT_SOURCE_DIR}/prelim/drm_helper.cpp
)
endif()

View File

@@ -11,6 +11,7 @@
#include "shared/source/os_interface/linux/drm_neo.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/debug/linux/debug_session.h"
#include "level_zero/tools/source/debug/linux/debug_session_factory.h"
namespace L0 {
@@ -51,4 +52,22 @@ DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *dev
}
return debugSession;
}
ze_result_t DebugSessionLinux::translateDebuggerOpenErrno(int error) {
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
switch (error) {
case ENODEV:
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
break;
case EBUSY:
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
break;
case EACCES:
result = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
break;
}
return result;
}
} // namespace L0

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/debug/debug_session.h"
#include "level_zero/tools/source/debug/debug_session_imp.h"
namespace L0 {
struct DebugSessionLinux : DebugSessionImp {
DebugSessionLinux(const zet_debug_config_t &config, Device *device) : DebugSessionImp(config, device){};
static ze_result_t translateDebuggerOpenErrno(int error);
};
} // namespace L0

View File

@@ -5,7 +5,7 @@
*
*/
#include "level_zero/tools/source/debug/linux/prelim/drm_helper.h"
#include "level_zero/tools/source/debug/linux/drm_helper.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/engine_info.h"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -26,7 +26,7 @@
#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h"
#include "level_zero/include/zet_intel_gpu_debug.h"
#include "level_zero/tools/source/debug/linux/debug_session_factory.h"
#include "level_zero/tools/source/debug/linux/prelim/drm_helper.h"
#include "level_zero/tools/source/debug/linux/drm_helper.h"
#include <level_zero/ze_api.h>
#include "common/StateSaveAreaHeader.h"
@@ -41,7 +41,7 @@ static DebugSessionLinuxPopulateFactory<DEBUG_SESSION_LINUX_TYPE_I915, DebugSess
DebugSession *createDebugSessionHelper(const zet_debug_config_t &config, Device *device, int debugFd, void *params);
DebugSessionLinuxi915::DebugSessionLinuxi915(const zet_debug_config_t &config, Device *device, int debugFd, void *params) : DebugSessionImp(config, device), fd(debugFd) {
DebugSessionLinuxi915::DebugSessionLinuxi915(const zet_debug_config_t &config, Device *device, int debugFd, void *params) : DebugSessionLinux(config, device), fd(debugFd) {
ioctlHandler.reset(new IoctlHandler);
if (params) {
@@ -81,28 +81,11 @@ DebugSession *DebugSessionLinuxi915::createLinuxSession(const zet_debug_config_t
auto reason = DrmHelper::getErrno(device);
PRINT_DEBUGGER_ERROR_LOG("PRELIM_DRM_IOCTL_I915_DEBUGGER_OPEN failed: open.pid: %d, open.events: %d, retCode: %d, errno: %d\n",
open.pid, open.events, debugFd, reason);
result = DebugSessionLinuxi915::translateDebuggerOpenErrno(reason);
result = translateDebuggerOpenErrno(reason);
}
return nullptr;
}
ze_result_t DebugSessionLinuxi915::translateDebuggerOpenErrno(int error) {
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
switch (error) {
case ENODEV:
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
break;
case EBUSY:
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
break;
case EACCES:
result = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
break;
}
return result;
}
int DebugSessionLinuxi915::ioctl(unsigned long request, void *arg) {
return ioctlHandler->ioctl(fd, request, arg);
}

View File

@@ -16,6 +16,7 @@
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/tools/source/debug/debug_session.h"
#include "level_zero/tools/source/debug/debug_session_imp.h"
#include "level_zero/tools/source/debug/linux/debug_session.h"
#include <atomic>
#include <mutex>
@@ -30,7 +31,7 @@ struct EngineClassInstance;
namespace L0 {
struct TileDebugSessionLinuxi915;
struct DebugSessionLinuxi915 : DebugSessionImp {
struct DebugSessionLinuxi915 : DebugSessionLinux {
friend struct TileDebugSessionLinuxi915;
@@ -171,8 +172,6 @@ struct DebugSessionLinuxi915 : DebugSessionImp {
std::unordered_map<uint64_t, Module> uuidToModule;
};
static ze_result_t translateDebuggerOpenErrno(int error);
constexpr static uint64_t invalidClientHandle = std::numeric_limits<uint64_t>::max();
constexpr static uint64_t invalidHandle = std::numeric_limits<uint64_t>::max();