input-linux: fix Coverity warning
[qemu/ar7.git] / include / exec / gdbstub.h
blobd9e8cf7715c5c613ac4b87fadeaddf43e1bbbacf
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 typedef void (*gdb_syscall_complete_cb)(CPUState *cpu,
15 target_ulong ret, target_ulong err);
17 /**
18 * gdb_do_syscall:
19 * @cb: function to call when the system call has completed
20 * @fmt: gdb syscall format string
21 * ...: list of arguments to interpolate into @fmt
23 * Send a GDB syscall request. This function will return immediately;
24 * the callback function will be called later when the remote system
25 * call has completed.
27 * @fmt should be in the 'call-id,parameter,parameter...' format documented
28 * for the F request packet in the GDB remote protocol. A limited set of
29 * printf-style format specifiers is supported:
30 * %x - target_ulong argument printed in hex
31 * %lx - 64-bit argument printed in hex
32 * %s - string pointer (target_ulong) and length (int) pair
34 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
35 /**
36 * gdb_do_syscallv:
37 * @cb: function to call when the system call has completed
38 * @fmt: gdb syscall format string
39 * @va: arguments to interpolate into @fmt
41 * As gdb_do_syscall, but taking a va_list rather than a variable
42 * argument list.
44 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
45 int use_gdb_syscalls(void);
46 void gdb_set_stop_cpu(CPUState *cpu);
47 void gdb_exit(CPUArchState *, int);
48 #ifdef CONFIG_USER_ONLY
49 int gdb_queuesig (void);
50 int gdb_handlesig(CPUState *, int);
51 void gdb_signalled(CPUArchState *, int);
52 void gdbserver_fork(CPUState *);
53 #endif
54 /* Get or set a register. Returns the size of the register. */
55 typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
56 void 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);
60 static inline int cpu_index(CPUState *cpu)
62 #if defined(CONFIG_USER_ONLY)
63 return cpu->host_tid;
64 #else
65 return cpu->cpu_index + 1;
66 #endif
69 /* The GDB remote protocol transfers values in target byte order. This means
70 * we can use the raw memory access routines to access the value buffer.
71 * Conveniently, these also handle the case where the buffer is mis-aligned.
74 static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val)
76 stb_p(mem_buf, val);
77 return 1;
80 static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val)
82 stw_p(mem_buf, val);
83 return 2;
86 static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val)
88 stl_p(mem_buf, val);
89 return 4;
92 static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)
94 stq_p(mem_buf, val);
95 return 8;
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
106 #endif
108 #ifdef CONFIG_USER_ONLY
109 int gdbserver_start(int);
110 #else
111 int gdbserver_start(const char *port);
112 #endif
115 * gdb_has_xml:
116 * This is an ugly hack to cope with both new and old gdb.
117 * If gdb sends qXfer:features:read then assume we're talking to a newish
118 * gdb that understands target descriptions.
120 extern bool gdb_has_xml;
122 /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
123 extern const char *const xml_builtin[][2];
125 #endif