Statistics
| Branch: | Revision:

root / include / exec / gdbstub.h @ 5b50e790

History | View | Annotate | Download (2.5 kB)

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