Alex Bennée | ae7467b | 2022-09-29 12:42:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * gdbstub internals |
| 3 | * |
| 4 | * Copyright (c) 2022 Linaro Ltd |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
Alex Bennée | 9774855 | 2023-03-02 18:57:37 -0800 | [diff] [blame] | 9 | #ifndef GDBSTUB_INTERNALS_H |
| 10 | #define GDBSTUB_INTERNALS_H |
Alex Bennée | ae7467b | 2022-09-29 12:42:24 +0100 | [diff] [blame] | 11 | |
Philippe Mathieu-Daudé | 55b5b8e | 2022-12-06 16:20:27 +0100 | [diff] [blame] | 12 | #include "exec/cpu-common.h" |
| 13 | |
Alex Bennée | 9f56787 | 2023-03-02 18:57:42 -0800 | [diff] [blame^] | 14 | #define MAX_PACKET_LENGTH 4096 |
| 15 | |
| 16 | /* |
| 17 | * Shared structures and definitions |
| 18 | */ |
| 19 | |
| 20 | typedef struct GDBProcess { |
| 21 | uint32_t pid; |
| 22 | bool attached; |
| 23 | |
| 24 | char target_xml[1024]; |
| 25 | } GDBProcess; |
| 26 | |
| 27 | enum RSState { |
| 28 | RS_INACTIVE, |
| 29 | RS_IDLE, |
| 30 | RS_GETLINE, |
| 31 | RS_GETLINE_ESC, |
| 32 | RS_GETLINE_RLE, |
| 33 | RS_CHKSUM1, |
| 34 | RS_CHKSUM2, |
| 35 | }; |
| 36 | |
| 37 | typedef struct GDBState { |
| 38 | bool init; /* have we been initialised? */ |
| 39 | CPUState *c_cpu; /* current CPU for step/continue ops */ |
| 40 | CPUState *g_cpu; /* current CPU for other ops */ |
| 41 | CPUState *query_cpu; /* for q{f|s}ThreadInfo */ |
| 42 | enum RSState state; /* parsing state */ |
| 43 | char line_buf[MAX_PACKET_LENGTH]; |
| 44 | int line_buf_index; |
| 45 | int line_sum; /* running checksum */ |
| 46 | int line_csum; /* checksum at the end of the packet */ |
| 47 | GByteArray *last_packet; |
| 48 | int signal; |
| 49 | bool multiprocess; |
| 50 | GDBProcess *processes; |
| 51 | int process_num; |
| 52 | char syscall_buf[256]; |
| 53 | gdb_syscall_complete_cb current_syscall_cb; |
| 54 | GString *str_buf; |
| 55 | GByteArray *mem_buf; |
| 56 | int sstep_flags; |
| 57 | int supported_sstep_flags; |
| 58 | } GDBState; |
| 59 | |
| 60 | /* |
| 61 | * Break/Watch point support - there is an implementation for softmmu |
| 62 | * and user mode. |
| 63 | */ |
Alex Bennée | a48e7d9 | 2022-09-29 12:42:25 +0100 | [diff] [blame] | 64 | bool gdb_supports_guest_debug(void); |
Philippe Mathieu-Daudé | 55b5b8e | 2022-12-06 16:20:27 +0100 | [diff] [blame] | 65 | int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len); |
| 66 | int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); |
Alex Bennée | ae7467b | 2022-09-29 12:42:24 +0100 | [diff] [blame] | 67 | void gdb_breakpoint_remove_all(CPUState *cs); |
| 68 | |
Alex Bennée | 9774855 | 2023-03-02 18:57:37 -0800 | [diff] [blame] | 69 | #endif /* GDBSTUB_INTERNALS_H */ |