-
Notifications
You must be signed in to change notification settings - Fork 19
/
GdbStub.h
77 lines (62 loc) · 1.69 KB
/
GdbStub.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
68
69
70
71
72
73
74
75
76
77
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
// Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
// Integrated into Mephisto/CTUv2 by Cody Brocious
#pragma once
#include "Ctu.h"
#define GDB_BUFFER_SIZE 10000
struct BreakpointAddress {
gptr address;
BreakpointType type;
};
struct Breakpoint {
bool active;
gptr addr;
guint len;
hook_t hook;
};
class GdbStub {
public:
GdbStub(Ctu *_ctu);
void enable(uint16_t port);
void _break(bool is_memory_break = false);
bool isMemoryBreak();
void handlePacket();
auto getNextBreakpointFromAddress(gptr addr, BreakpointType type);
bool checkBreakpoint(gptr addr, BreakpointType type);
void sendSignal(uint32_t signal);
bool memoryBreak, haltLoop, stepLoop, remoteBreak, enabled;
private:
auto& getBreakpointList(BreakpointType type);
void removeBreakpoint(BreakpointType type, gptr addr);
uint8_t readByte();
void sendPacket(const char packet);
void sendReply(const char* reply);
void handleQuery();
void handleSetThread();
void readCommand();
bool isDataAvailable();
void readRegister();
void readRegisters();
void writeRegister();
void writeRegisters();
void readMemory();
void writeMemory();
void isThreadAlive();
void step();
void _continue();
bool commitBreakpoint(BreakpointType type, gptr addr, uint32_t len);
void addBreakpoint();
void removeBreakpoint();
guint reg(int x);
void reg(int x, guint v);
Ctu *ctu;
map<gptr, Breakpoint> breakpointsExecute;
map<gptr, Breakpoint> breakpointsRead;
map<gptr, Breakpoint> breakpointsWrite;
int client;
uint8_t commandBuffer[GDB_BUFFER_SIZE];
uint32_t commandLength;
uint32_t latestSignal;
};