2022-03-24 19:07:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
2022-09-17 20:12:26 +01:00
|
|
|
#include <optional>
|
2022-03-24 19:07:28 +00:00
|
|
|
|
|
|
|
|
#include "TargetDescriptor.hpp"
|
2023-04-01 14:30:33 +01:00
|
|
|
#include "GdbDebugServerConfig.hpp"
|
2022-03-27 18:34:08 +01:00
|
|
|
#include "Connection.hpp"
|
2022-05-14 22:38:49 +01:00
|
|
|
#include "Feature.hpp"
|
2022-09-17 20:12:26 +01:00
|
|
|
#include "ProgrammingSession.hpp"
|
2022-03-24 19:07:28 +00:00
|
|
|
|
2023-04-01 14:30:33 +01:00
|
|
|
#include "src/Targets/TargetMemory.hpp"
|
|
|
|
|
|
2022-03-31 16:05:39 +01:00
|
|
|
namespace Bloom::DebugServer::Gdb
|
2022-03-24 19:07:28 +00:00
|
|
|
{
|
|
|
|
|
class DebugSession
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-05-14 22:38:49 +01:00
|
|
|
/**
|
|
|
|
|
* The connection serving this debug session.
|
|
|
|
|
*/
|
2022-03-24 19:07:28 +00:00
|
|
|
Connection connection;
|
|
|
|
|
|
2022-05-14 22:38:49 +01:00
|
|
|
/**
|
|
|
|
|
* A set of all GDB features supported for this debug session, along with any optional values (some GDB
|
|
|
|
|
* features can be specified with a value, such as Feature::PACKET_SIZE).
|
|
|
|
|
*/
|
|
|
|
|
std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The GDB target descriptor of the connected target.
|
|
|
|
|
*/
|
2022-05-04 19:49:18 +01:00
|
|
|
const TargetDescriptor& gdbTargetDescriptor;
|
2022-03-24 19:07:28 +00:00
|
|
|
|
2023-04-01 14:30:33 +01:00
|
|
|
/**
|
|
|
|
|
* The current server configuration.
|
|
|
|
|
*/
|
|
|
|
|
const GdbDebugServerConfig& serverConfig;
|
|
|
|
|
|
2022-03-24 19:07:28 +00:00
|
|
|
/**
|
|
|
|
|
* When the GDB client is waiting for the target to halt, this is set to true so we know when to notify the
|
|
|
|
|
* client.
|
|
|
|
|
*/
|
|
|
|
|
bool waitingForBreak = false;
|
|
|
|
|
|
2023-05-07 19:44:19 +01:00
|
|
|
bool pendingInterrupt = false;
|
|
|
|
|
|
2022-09-17 20:12:26 +01:00
|
|
|
/**
|
|
|
|
|
* When the user attempts to program the target via GDB's 'load' command, GDB will send a number of
|
|
|
|
|
* FlashWrite (vFlashWrite) packets to Bloom. We group the data in these packets and flush it all at once, upon
|
|
|
|
|
* receiving a FlashDone (vFlashDone) packet.
|
|
|
|
|
*
|
|
|
|
|
* The grouped data is held in a ProgrammingSession object, against the active debug session. Once the data has
|
|
|
|
|
* been flushed, the ProgrammingSession object is destroyed.
|
|
|
|
|
*
|
|
|
|
|
* See the ProgrammingSession struct and GDB RSP documentation for more.
|
|
|
|
|
*
|
|
|
|
|
* This member holds the current (if any) ProgrammingSession object. It should only be populated during
|
|
|
|
|
* programming.
|
|
|
|
|
*/
|
|
|
|
|
std::optional<ProgrammingSession> programmingSession = std::nullopt;
|
|
|
|
|
|
2022-05-14 22:38:49 +01:00
|
|
|
DebugSession(
|
|
|
|
|
Connection&& connection,
|
|
|
|
|
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures,
|
2023-04-01 14:30:33 +01:00
|
|
|
const TargetDescriptor& targetDescriptor,
|
|
|
|
|
const GdbDebugServerConfig& serverConfig
|
2022-05-14 22:38:49 +01:00
|
|
|
);
|
2022-03-24 19:07:28 +00:00
|
|
|
|
2022-08-13 03:06:30 +01:00
|
|
|
DebugSession(const DebugSession& other) = delete;
|
|
|
|
|
DebugSession(DebugSession&& other) = delete;
|
|
|
|
|
|
|
|
|
|
DebugSession& operator = (const DebugSession& other) = delete;
|
|
|
|
|
DebugSession& operator = (DebugSession&& other) = delete;
|
|
|
|
|
|
|
|
|
|
~DebugSession();
|
2022-03-24 19:07:28 +00:00
|
|
|
};
|
|
|
|
|
}
|