]> git.proxmox.com Git - mirror_qemu.git/blame - include/exec/gdbstub.h
Merge remote-tracking branch 'bonzini/tags/for-upstream' into staging
[mirror_qemu.git] / include / exec / gdbstub.h
CommitLineData
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
33c11879
PB
14#include "cpu.h"
15
9e0c5422 16typedef void (*gdb_syscall_complete_cb)(CPUState *cpu,
a2d1ebaf
PB
17 target_ulong ret, target_ulong err);
18
19239b39
PM
19/**
20 * gdb_do_syscall:
21 * @cb: function to call when the system call has completed
22 * @fmt: gdb syscall format string
23 * ...: list of arguments to interpolate into @fmt
24 *
25 * Send a GDB syscall request. This function will return immediately;
26 * the callback function will be called later when the remote system
27 * call has completed.
28 *
29 * @fmt should be in the 'call-id,parameter,parameter...' format documented
30 * for the F request packet in the GDB remote protocol. A limited set of
31 * printf-style format specifiers is supported:
32 * %x - target_ulong argument printed in hex
33 * %lx - 64-bit argument printed in hex
34 * %s - string pointer (target_ulong) and length (int) pair
35 */
7ccfb2eb 36void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
19239b39
PM
37/**
38 * gdb_do_syscallv:
39 * @cb: function to call when the system call has completed
40 * @fmt: gdb syscall format string
41 * @va: arguments to interpolate into @fmt
42 *
43 * As gdb_do_syscall, but taking a va_list rather than a variable
44 * argument list.
45 */
46void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
a2d1ebaf 47int use_gdb_syscalls(void);
64f6b346 48void gdb_set_stop_cpu(CPUState *cpu);
9349b4f9 49void gdb_exit(CPUArchState *, int);
1fddef4b 50#ifdef CONFIG_USER_ONLY
db6b81d4 51int gdb_handlesig(CPUState *, int);
9349b4f9 52void gdb_signalled(CPUArchState *, int);
f7ec7f7b 53void gdbserver_fork(CPUState *);
4046d913 54#endif
56aebc89 55/* Get or set a register. Returns the size of the register. */
9349b4f9 56typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
22169d41 57void gdb_register_coprocessor(CPUState *cpu,
56aebc89
PB
58 gdb_reg_cb get_reg, gdb_reg_cb set_reg,
59 int num_regs, const char *xml, int g_pos);
1fddef4b 60
0d34282f 61static inline int cpu_index(CPUState *cpu)
68f4730c 62{
24cb36a6 63#if defined(CONFIG_USER_ONLY)
0d34282f 64 return cpu->host_tid;
68f4730c 65#else
55e5c285 66 return cpu->cpu_index + 1;
68f4730c
WC
67#endif
68}
69
986a2998
AF
70/* The GDB remote protocol transfers values in target byte order. This means
71 * we can use the raw memory access routines to access the value buffer.
72 * Conveniently, these also handle the case where the buffer is mis-aligned.
73 */
74
75static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val)
76{
77 stb_p(mem_buf, val);
78 return 1;
79}
80
81static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val)
82{
83 stw_p(mem_buf, val);
84 return 2;
85}
86
87static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val)
88{
89 stl_p(mem_buf, val);
90 return 4;
91}
92
93static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)
94{
95 stq_p(mem_buf, val);
96 return 8;
97}
98
99#if TARGET_LONG_BITS == 64
100#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val)
101#define ldtul_p(addr) ldq_p(addr)
102#else
103#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val)
104#define ldtul_p(addr) ldl_p(addr)
105#endif
106
1fddef4b 107#endif
1c14f162
BS
108
109#ifdef CONFIG_USER_ONLY
110int gdbserver_start(int);
111#else
112int gdbserver_start(const char *port);
113#endif
114
5b50e790
AF
115/**
116 * gdb_has_xml:
117 * This is an ugly hack to cope with both new and old gdb.
118 * If gdb sends qXfer:features:read then assume we're talking to a newish
119 * gdb that understands target descriptions.
120 */
121extern bool gdb_has_xml;
122
4c3b5a48 123/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
0b65b9e1
BS
124extern const char *const xml_builtin[][2];
125
1c14f162 126#endif