This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-micro-runtime/core/iwasm/libraries/debug-engine/gdbserver.h
TianlongLiang 3b4033aceb
Allow source debugger reconnection (#1667)
Allow to wait for a new debugger connection once the previous one
is disconnected:
- when receiving a detach command
- when the client socket is closed (for example, lldb process is killed)
2022-11-02 17:12:34 +08:00

71 lines
1.5 KiB
C

/*
* 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