spapr_iommu: Introduce "enabled" state for TCE table
[qemu.git] / include / exec / gdbstub.h
blob8e3f8d8176d95ff503b6aecb10ada6b199992655
1 #ifndef GDBSTUB_H
2 #define GDBSTUB_H
4 #define DEFAULT_GDBSTUB_PORT "1234"
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
13 #ifdef NEED_CPU_H
14 #include "cpu.h"
16 typedef void (*gdb_syscall_complete_cb)(CPUState *cpu,
17 target_ulong ret, target_ulong err);
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
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.
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
36 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
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
43 * As gdb_do_syscall, but taking a va_list rather than a variable
44 * argument list.
46 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
47 int use_gdb_syscalls(void);
48 void gdb_set_stop_cpu(CPUState *cpu);
49 void gdb_exit(CPUArchState *, int);
50 #ifdef CONFIG_USER_ONLY
51 int gdb_queuesig (void);
52 int gdb_handlesig(CPUState *, int);
53 void gdb_signalled(CPUArchState *, int);
54 void gdbserver_fork(CPUState *);
55 #endif
56 /* Get or set a register. Returns the size of the register. */
57 typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
58 void gdb_register_coprocessor(CPUState *cpu,
59 gdb_reg_cb get_reg, gdb_reg_cb set_reg,
60 int num_regs, const char *xml, int g_pos);
62 static inline int cpu_index(CPUState *cpu)
64 #if defined(CONFIG_USER_ONLY)
65 return cpu->host_tid;
66 #else
67 return cpu->cpu_index + 1;
68 #endif
71 /* The GDB remote protocol transfers values in target byte order. This means
72 * we can use the raw memory access routines to access the value buffer.
73 * Conveniently, these also handle the case where the buffer is mis-aligned.
76 static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val)
78 stb_p(mem_buf, val);
79 return 1;
82 static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val)
84 stw_p(mem_buf, val);
85 return 2;
88 static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val)
90 stl_p(mem_buf, val);
91 return 4;
94 static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)
96 stq_p(mem_buf, val);
97 return 8;
100 #if TARGET_LONG_BITS == 64
101 #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val)
102 #define ldtul_p(addr) ldq_p(addr)
103 #else
104 #define gdb_get_regl(buf, val) gdb_get_reg32(buf, val)
105 #define ldtul_p(addr) ldl_p(addr)
106 #endif
108 #endif
110 #ifdef CONFIG_USER_ONLY
111 int gdbserver_start(int);
112 #else
113 int gdbserver_start(const char *port);
114 #endif
117 * gdb_has_xml:
118 * This is an ugly hack to cope with both new and old gdb.
119 * If gdb sends qXfer:features:read then assume we're talking to a newish
120 * gdb that understands target descriptions.
122 extern bool gdb_has_xml;
124 /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
125 extern const char *const xml_builtin[][2];
127 #endif