]>
Commit | Line | Data |
---|---|---|
1fddef4b FB |
1 | #ifndef GDBSTUB_H |
2 | #define GDBSTUB_H | |
3 | ||
cfc3475a | 4 | #define DEFAULT_GDBSTUB_PORT "1234" |
1fddef4b | 5 | |
e22a25c9 AL |
6 | /* GDB breakpoint/watchpoint types */ |
7 | #define GDB_BREAKPOINT_SW 0 | |
8 | #define GDB_BREAKPOINT_HW 1 | |
9 | #define GDB_WATCHPOINT_WRITE 2 | |
10 | #define GDB_WATCHPOINT_READ 3 | |
11 | #define GDB_WATCHPOINT_ACCESS 4 | |
12 | ||
1c14f162 | 13 | #ifdef NEED_CPU_H |
9e0c5422 | 14 | typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, |
a2d1ebaf PB |
15 | target_ulong ret, target_ulong err); |
16 | ||
7ccfb2eb | 17 | void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); |
a2d1ebaf | 18 | int use_gdb_syscalls(void); |
64f6b346 | 19 | void gdb_set_stop_cpu(CPUState *cpu); |
9349b4f9 | 20 | void gdb_exit(CPUArchState *, int); |
1fddef4b | 21 | #ifdef CONFIG_USER_ONLY |
ca587a8e | 22 | int gdb_queuesig (void); |
db6b81d4 | 23 | int gdb_handlesig(CPUState *, int); |
9349b4f9 AF |
24 | void gdb_signalled(CPUArchState *, int); |
25 | void gdbserver_fork(CPUArchState *); | |
4046d913 | 26 | #endif |
56aebc89 | 27 | /* Get or set a register. Returns the size of the register. */ |
9349b4f9 | 28 | typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); |
22169d41 | 29 | void gdb_register_coprocessor(CPUState *cpu, |
56aebc89 PB |
30 | gdb_reg_cb get_reg, gdb_reg_cb set_reg, |
31 | int num_regs, const char *xml, int g_pos); | |
1fddef4b | 32 | |
0d34282f | 33 | static inline int cpu_index(CPUState *cpu) |
68f4730c | 34 | { |
24cb36a6 | 35 | #if defined(CONFIG_USER_ONLY) |
0d34282f | 36 | return cpu->host_tid; |
68f4730c | 37 | #else |
55e5c285 | 38 | return cpu->cpu_index + 1; |
68f4730c WC |
39 | #endif |
40 | } | |
41 | ||
986a2998 AF |
42 | /* The GDB remote protocol transfers values in target byte order. This means |
43 | * we can use the raw memory access routines to access the value buffer. | |
44 | * Conveniently, these also handle the case where the buffer is mis-aligned. | |
45 | */ | |
46 | ||
47 | static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val) | |
48 | { | |
49 | stb_p(mem_buf, val); | |
50 | return 1; | |
51 | } | |
52 | ||
53 | static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val) | |
54 | { | |
55 | stw_p(mem_buf, val); | |
56 | return 2; | |
57 | } | |
58 | ||
59 | static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val) | |
60 | { | |
61 | stl_p(mem_buf, val); | |
62 | return 4; | |
63 | } | |
64 | ||
65 | static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val) | |
66 | { | |
67 | stq_p(mem_buf, val); | |
68 | return 8; | |
69 | } | |
70 | ||
71 | #if TARGET_LONG_BITS == 64 | |
72 | #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) | |
73 | #define ldtul_p(addr) ldq_p(addr) | |
74 | #else | |
75 | #define gdb_get_regl(buf, val) gdb_get_reg32(buf, val) | |
76 | #define ldtul_p(addr) ldl_p(addr) | |
77 | #endif | |
78 | ||
1fddef4b | 79 | #endif |
1c14f162 BS |
80 | |
81 | #ifdef CONFIG_USER_ONLY | |
82 | int gdbserver_start(int); | |
83 | #else | |
84 | int gdbserver_start(const char *port); | |
85 | #endif | |
86 | ||
5b50e790 AF |
87 | /** |
88 | * gdb_has_xml: | |
89 | * This is an ugly hack to cope with both new and old gdb. | |
90 | * If gdb sends qXfer:features:read then assume we're talking to a newish | |
91 | * gdb that understands target descriptions. | |
92 | */ | |
93 | extern bool gdb_has_xml; | |
94 | ||
4c3b5a48 | 95 | /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ |
0b65b9e1 BS |
96 | extern const char *const xml_builtin[][2]; |
97 | ||
a38bb079 LI |
98 | /* Command line option defining whether semihosting should go via gdb or not */ |
99 | extern int semihosting_target; | |
100 | #define SEMIHOSTING_TARGET_AUTO 0 | |
101 | #define SEMIHOSTING_TARGET_NATIVE 1 | |
102 | #define SEMIHOSTING_TARGET_GDB 2 | |
103 | ||
1c14f162 | 104 | #endif |