mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add debug api handlers 2
Related-To: NEO-4554 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a3c2a1eb44
commit
6356de6511
@@ -5,6 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_handlers.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -13,8 +15,39 @@ DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *dev
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace DebugApiHandlers {
|
||||
ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *config, zet_debug_session_handle_t *phDebug) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t debugDetach(zet_debug_session_handle_t hDebug) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t debugReadEvent(zet_debug_session_handle_t hDebug, uint64_t timeout, zet_debug_event_t *event) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t debugInterrupt(zet_debug_session_handle_t hDebug, ze_device_thread_t thread) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t debugResume(zet_debug_session_handle_t hDebug, ze_device_thread_t thread) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t debugReadMemory(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t debugWriteMemory(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, const void *buffer) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t debugAcknowledgeEvent(zet_debug_session_handle_t hDebug, const zet_debug_event_t *event) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t debugGetRegisterSetProperties(zet_device_handle_t hDevice, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t debugReadRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t debugWriteRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
} // namespace DebugApiHandlers
|
||||
} // namespace L0
|
||||
@@ -9,5 +9,17 @@
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
namespace L0 {
|
||||
namespace DebugApiHandlers {
|
||||
ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *config, zet_debug_session_handle_t *phDebug);
|
||||
}
|
||||
ze_result_t debugDetach(zet_debug_session_handle_t hDebug);
|
||||
ze_result_t debugReadEvent(zet_debug_session_handle_t hDebug, uint64_t timeout, zet_debug_event_t *event);
|
||||
ze_result_t debugInterrupt(zet_debug_session_handle_t hDebug, ze_device_thread_t thread);
|
||||
ze_result_t debugResume(zet_debug_session_handle_t hDebug, ze_device_thread_t thread);
|
||||
ze_result_t debugReadMemory(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer);
|
||||
ze_result_t debugWriteMemory(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, const void *buffer);
|
||||
ze_result_t debugAcknowledgeEvent(zet_debug_session_handle_t hDebug, const zet_debug_event_t *event);
|
||||
ze_result_t debugGetRegisterSetProperties(zet_device_handle_t hDevice, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||
ze_result_t debugReadRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues);
|
||||
ze_result_t debugWriteRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues);
|
||||
} // namespace DebugApiHandlers
|
||||
} // namespace L0
|
||||
@@ -23,8 +23,13 @@ struct DebugSession : _zet_debug_session_handle_t {
|
||||
static DebugSession *fromHandle(zet_debug_session_handle_t handle) { return static_cast<DebugSession *>(handle); }
|
||||
inline zet_debug_session_handle_t toHandle() { return this; }
|
||||
|
||||
virtual bool closeConnection() = 0;
|
||||
|
||||
Device *getConnectedDevice() { return connectedDevice; }
|
||||
|
||||
protected:
|
||||
DebugSession(const zet_debug_config_t &config, Device *device){};
|
||||
DebugSession(const zet_debug_config_t &config, Device *device) : connectedDevice(device){};
|
||||
Device *connectedDevice = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -22,6 +22,7 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface {
|
||||
|
||||
struct DebugSessionMock : public L0::DebugSession {
|
||||
DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device){};
|
||||
bool closeConnection() override { return true; }
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_handlers.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -61,5 +63,42 @@ TEST(DebugSessionTest, WhenDebugSessionCreateIsCalledThenNullptrReturned) {
|
||||
EXPECT_EQ(nullptr, session);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, WhenUnsupportedFunctionCalledThenErrorIsReturned) {
|
||||
zet_debug_session_handle_t session = {};
|
||||
|
||||
auto result = L0::DebugApiHandlers::debugDetach(session);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugReadEvent(session, 0, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
ze_device_thread_t thread = {};
|
||||
result = L0::DebugApiHandlers::debugInterrupt(session, thread);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugResume(session, thread);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugReadMemory(session, thread, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugWriteMemory(session, thread, nullptr, 0, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugAcknowledgeEvent(session, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
zet_device_handle_t hDevice = {};
|
||||
result = L0::DebugApiHandlers::debugGetRegisterSetProperties(hDevice, nullptr, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
zet_debug_regset_type_t type = {ZET_DEBUG_REGSET_TYPE_INVALID};
|
||||
result = L0::DebugApiHandlers::debugReadRegisters(session, thread, type, 0, 0, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
|
||||
result = L0::DebugApiHandlers::debugWriteRegisters(session, thread, type, 0, 0, nullptr);
|
||||
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -107,5 +107,33 @@ TEST(DebugSessionTest, givenDebugSessionWhenConvertingToAndFromHandleCorrectHand
|
||||
EXPECT_EQ(session, sessionFromHandle);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenDebugSessionWhenGettingConnectedDeviceThenCorrectDeviceIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), 0));
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto debugSession = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||
L0::DebugSession *session = debugSession.get();
|
||||
|
||||
auto device = session->getConnectedDevice();
|
||||
|
||||
EXPECT_EQ(&deviceImp, device);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenDeviceWithDebugSessionWhenRemoveCalledThenSessionIsNotDeleted) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), 0));
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto debugSession = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||
L0::DebugSession *session = debugSession.get();
|
||||
deviceImp.debugSession.reset(session);
|
||||
deviceImp.removeDebugSession();
|
||||
|
||||
EXPECT_EQ(nullptr, deviceImp.debugSession.get());
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user