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