1#ifndef GDBSTUB_H
2#define GDBSTUB_H
3
4#define DEFAULT_GDBSTUB_PORT "1234"
5
6
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
13#ifdef NEED_CPU_H
14#include "cpu.h"
15
16typedef void (*gdb_syscall_complete_cb)(CPUState *cpu,
17 target_ulong ret, target_ulong err);
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
37
38
39
40
41
42
43
44
45
46void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
47int use_gdb_syscalls(void);
48void gdb_set_stop_cpu(CPUState *cpu);
49void gdb_exit(CPUArchState *, int);
50#ifdef CONFIG_USER_ONLY
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66int gdb_handlesig(CPUState *, int);
67void gdb_signalled(CPUArchState *, int);
68void gdbserver_fork(CPUState *);
69#endif
70
71typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
72void gdb_register_coprocessor(CPUState *cpu,
73 gdb_reg_cb get_reg, gdb_reg_cb set_reg,
74 int num_regs, const char *xml, int g_pos);
75
76
77
78
79
80
81static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val)
82{
83 stb_p(mem_buf, val);
84 return 1;
85}
86
87static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val)
88{
89 stw_p(mem_buf, val);
90 return 2;
91}
92
93static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val)
94{
95 stl_p(mem_buf, val);
96 return 4;
97}
98
99static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)
100{
101 stq_p(mem_buf, val);
102 return 8;
103}
104
105#if TARGET_LONG_BITS == 64
106#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val)
107#define ldtul_p(addr) ldq_p(addr)
108#else
109#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val)
110#define ldtul_p(addr) ldl_p(addr)
111#endif
112
113#endif
114
115#ifdef CONFIG_USER_ONLY
116int gdbserver_start(int);
117#else
118int gdbserver_start(const char *port);
119#endif
120
121void gdbserver_cleanup(void);
122
123
124
125
126
127
128
129extern bool gdb_has_xml;
130
131
132extern const char *const xml_builtin[][2];
133
134#endif
135