-
Notifications
You must be signed in to change notification settings - Fork 6
/
gdbserver.h
67 lines (51 loc) · 1.36 KB
/
gdbserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef GDBSERVER_H
#define GDBSERVER_H
#include <stdexcept>
#include <set>
#include "common.h"
class Device;
/// Server implementing GDB remote protocol
class GdbServer
{
public:
GdbServer(Device& dev);
~GdbServer();
/** @brief Run the GDB server
*
* @note The device should be initialized (reset at least once) before
* running the server.
*/
void run(int port);
/// Continue execution
void execContinue();
/// Execute a single step
void execStep();
private:
/// Process a client packet data
void processPacket(const std::string& data);
/// Receive a packet, return its data
std::string recvPacket();
/// Send a packet (with ACK)
void sendPacket(const std::string& data);
/// Send a ACK or a NACK
void sendAck(bool ack);
/// Get memory data using GDB addressing
uint8_t getGdbMem(unsigned int addr);
/// Get memory data using GDB addressing
void setGdbMem(unsigned int addr, uint8_t v);
/// Build a 'T' stop reply
std::string buildStopReply() const;
Device& device_;
int sock_client_;
std::string rbuf_; ///< Reception buffer
/// Breakpoints, as a set of PC values
std::multiset<flashptr_t> breakpoints_;
};
class GdbServerError: public std::runtime_error
{
public:
GdbServerError(const std::string& msg):
std::runtime_error(msg) {}
GdbServerError(int errnum, const std::string& msg);
};
#endif