blob: 9e279a2e62e8d7768a0a1b91434987c8d665ad93 (
plain)
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
|
/*
* Copyright (C) 2021 Ant Group. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _GDB_SERVER_H
#define _GDB_SERVER_H
#include "bh_platform.h"
#define PACKET_BUF_SIZE 0x8000
enum GDBStoppointType {
eStoppointInvalid = -1,
eBreakpointSoftware = 0,
eBreakpointHardware,
eWatchpointWrite,
eWatchpointRead,
eWatchpointReadWrite
};
typedef enum rsp_recv_phase_t {
Phase_Idle,
Phase_Payload,
Phase_Checksum
} rsp_recv_phase_t;
/* Remote Serial Protocol Receive Context */
typedef struct rsp_recv_context_t {
rsp_recv_phase_t phase;
uint16 receive_index;
uint16 size_in_phase;
uint8 check_sum;
/* RSP packet should not be too long */
char receive_buffer[1024];
} rsp_recv_context_t;
typedef struct WasmDebugPacket {
unsigned char buf[PACKET_BUF_SIZE];
uint32 size;
} WasmDebugPacket;
struct WASMDebugControlThread;
typedef struct WASMGDBServer {
bh_socket_t listen_fd;
bh_socket_t socket_fd;
WasmDebugPacket pkt;
bool noack;
struct WASMDebugControlThread *thread;
rsp_recv_context_t *receive_ctx;
} WASMGDBServer;
WASMGDBServer *
wasm_create_gdbserver(const char *host, int32 *port);
bool
wasm_gdbserver_listen(WASMGDBServer *server);
bool
wasm_gdbserver_accept(WASMGDBServer *server);
void
wasm_gdbserver_detach(WASMGDBServer *server);
void
wasm_close_gdbserver(WASMGDBServer *server);
bool
wasm_gdbserver_handle_packet(WASMGDBServer *server);
#endif
|