2021-02-24 01:57:27 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-06-02 23:24:43 +08:00
|
|
|
#include "level_zero/core/source/debugger/debugger_l0.h"
|
2021-02-24 01:57:27 +08:00
|
|
|
#include <level_zero/zet_api.h>
|
|
|
|
|
|
|
|
struct _zet_debug_session_handle_t {};
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
|
|
|
struct Device;
|
|
|
|
|
|
|
|
struct DebugSession : _zet_debug_session_handle_t {
|
|
|
|
virtual ~DebugSession() = default;
|
|
|
|
DebugSession() = delete;
|
|
|
|
|
2021-03-19 02:18:25 +08:00
|
|
|
static DebugSession *create(const zet_debug_config_t &config, Device *device, ze_result_t &result);
|
2021-02-24 01:57:27 +08:00
|
|
|
|
|
|
|
static DebugSession *fromHandle(zet_debug_session_handle_t handle) { return static_cast<DebugSession *>(handle); }
|
|
|
|
inline zet_debug_session_handle_t toHandle() { return this; }
|
|
|
|
|
2021-03-03 20:09:39 +08:00
|
|
|
virtual bool closeConnection() = 0;
|
2021-03-24 01:08:18 +08:00
|
|
|
virtual ze_result_t initialize() = 0;
|
2021-03-03 20:09:39 +08:00
|
|
|
|
2021-04-08 01:58:26 +08:00
|
|
|
virtual ze_result_t readEvent(uint64_t timeout, zet_debug_event_t *event) = 0;
|
2021-04-21 00:02:43 +08:00
|
|
|
virtual ze_result_t interrupt(ze_device_thread_t thread) = 0;
|
|
|
|
virtual ze_result_t resume(ze_device_thread_t thread) = 0;
|
|
|
|
virtual ze_result_t readMemory(ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer) = 0;
|
|
|
|
virtual ze_result_t writeMemory(ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, const void *buffer) = 0;
|
|
|
|
virtual ze_result_t acknowledgeEvent(const zet_debug_event_t *event) = 0;
|
|
|
|
virtual ze_result_t readRegisters(ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
|
|
|
virtual ze_result_t writeRegisters(ze_device_thread_t thread, zet_debug_regset_type_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
2021-04-08 01:58:26 +08:00
|
|
|
|
2021-03-03 20:09:39 +08:00
|
|
|
Device *getConnectedDevice() { return connectedDevice; }
|
|
|
|
|
2021-02-24 01:57:27 +08:00
|
|
|
protected:
|
2021-03-03 20:09:39 +08:00
|
|
|
DebugSession(const zet_debug_config_t &config, Device *device) : connectedDevice(device){};
|
2021-05-07 23:27:56 +08:00
|
|
|
virtual void startAsyncThread() = 0;
|
|
|
|
|
2021-03-03 20:09:39 +08:00
|
|
|
Device *connectedDevice = nullptr;
|
2021-02-24 01:57:27 +08:00
|
|
|
};
|
|
|
|
|
2021-05-07 23:27:56 +08:00
|
|
|
struct RootDebugSession : DebugSession {
|
|
|
|
virtual ~RootDebugSession() = default;
|
|
|
|
RootDebugSession() = delete;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RootDebugSession(const zet_debug_config_t &config, Device *device) : DebugSession(config, device){};
|
2021-06-02 23:24:43 +08:00
|
|
|
|
|
|
|
virtual bool readModuleDebugArea() = 0;
|
|
|
|
DebugAreaHeader debugArea;
|
2021-05-07 23:27:56 +08:00
|
|
|
};
|
|
|
|
|
2021-02-24 01:57:27 +08:00
|
|
|
} // namespace L0
|