gdbstub.h (4ea5fe997db4c5d893b69072f488880c07857a54) gdbstub.h (c566080cd37fe328077a3c49d7fd248ce2a06bfe)
1#ifndef GDBSTUB_H
2#define GDBSTUB_H
3
4#define DEFAULT_GDBSTUB_PORT "1234"
5
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
1#ifndef GDBSTUB_H
2#define GDBSTUB_H
3
4#define DEFAULT_GDBSTUB_PORT "1234"
5
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
13/* For gdb file i/o remote protocol open flags. */
14#define GDB_O_RDONLY 0
15#define GDB_O_WRONLY 1
16#define GDB_O_RDWR 2
17#define GDB_O_APPEND 8
18#define GDB_O_CREAT 0x200
19#define GDB_O_TRUNC 0x400
20#define GDB_O_EXCL 0x800
21
13
22/* For gdb file i/o remote protocol errno values */
23#define GDB_EPERM 1
24#define GDB_ENOENT 2
25#define GDB_EINTR 4
26#define GDB_EBADF 9
27#define GDB_EACCES 13
28#define GDB_EFAULT 14
29#define GDB_EBUSY 16
30#define GDB_EEXIST 17
31#define GDB_ENODEV 19
32#define GDB_ENOTDIR 20
33#define GDB_EISDIR 21
34#define GDB_EINVAL 22
35#define GDB_ENFILE 23
36#define GDB_EMFILE 24
37#define GDB_EFBIG 27
38#define GDB_ENOSPC 28
39#define GDB_ESPIPE 29
40#define GDB_EROFS 30
41#define GDB_ENAMETOOLONG 91
42#define GDB_EUNKNOWN 9999
43
44/* For gdb file i/o remote protocol lseek whence. */
45#define GDB_SEEK_SET 0
46#define GDB_SEEK_CUR 1
47#define GDB_SEEK_END 2
48
49/* For gdb file i/o stat/fstat. */
50typedef uint32_t gdb_mode_t;
51typedef uint32_t gdb_time_t;
52
53struct gdb_stat {
54 uint32_t gdb_st_dev; /* device */
55 uint32_t gdb_st_ino; /* inode */
56 gdb_mode_t gdb_st_mode; /* protection */
57 uint32_t gdb_st_nlink; /* number of hard links */
58 uint32_t gdb_st_uid; /* user ID of owner */
59 uint32_t gdb_st_gid; /* group ID of owner */
60 uint32_t gdb_st_rdev; /* device type (if inode device) */
61 uint64_t gdb_st_size; /* total size, in bytes */
62 uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */
63 uint64_t gdb_st_blocks; /* number of blocks allocated */
64 gdb_time_t gdb_st_atime; /* time of last access */
65 gdb_time_t gdb_st_mtime; /* time of last modification */
66 gdb_time_t gdb_st_ctime; /* time of last change */
67} QEMU_PACKED;
68
69struct gdb_timeval {
70 gdb_time_t tv_sec; /* second */
71 uint64_t tv_usec; /* microsecond */
72} QEMU_PACKED;
73
74typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err);
75
76/**
77 * gdb_do_syscall:
78 * @cb: function to call when the system call has completed
79 * @fmt: gdb syscall format string
80 * ...: list of arguments to interpolate into @fmt
81 *
82 * Send a GDB syscall request. This function will return immediately;
83 * the callback function will be called later when the remote system
84 * call has completed.
85 *
86 * @fmt should be in the 'call-id,parameter,parameter...' format documented
87 * for the F request packet in the GDB remote protocol. A limited set of
88 * printf-style format specifiers is supported:
89 * %x - target_ulong argument printed in hex
90 * %lx - 64-bit argument printed in hex
91 * %s - string pointer (target_ulong) and length (int) pair
92 */
93void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
94/**
95 * gdb_do_syscallv:
96 * @cb: function to call when the system call has completed
97 * @fmt: gdb syscall format string
98 * @va: arguments to interpolate into @fmt
99 *
100 * As gdb_do_syscall, but taking a va_list rather than a variable
101 * argument list.
102 */
103void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
104int use_gdb_syscalls(void);
105
106/* Get or set a register. Returns the size of the register. */
107typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg);
108typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
109void gdb_register_coprocessor(CPUState *cpu,
110 gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
111 int num_regs, const char *xml, int g_pos);
112
113/**
114 * gdbserver_start: start the gdb server
115 * @port_or_device: connection spec for gdb
116 *
117 * For CONFIG_USER this is either a tcp port or a path to a fifo. For
118 * system emulation you can use a full chardev spec for your gdbserver
119 * port.
120 */
121int gdbserver_start(const char *port_or_device);
122
14/* Get or set a register. Returns the size of the register. */
15typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg);
16typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
17void gdb_register_coprocessor(CPUState *cpu,
18 gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
19 int num_regs, const char *xml, int g_pos);
20
21/**
22 * gdbserver_start: start the gdb server
23 * @port_or_device: connection spec for gdb
24 *
25 * For CONFIG_USER this is either a tcp port or a path to a fifo. For
26 * system emulation you can use a full chardev spec for your gdbserver
27 * port.
28 */
29int gdbserver_start(const char *port_or_device);
30
123/**
124 * gdb_exit: exit gdb session, reporting inferior status
125 * @code: exit code reported
126 *
127 * This closes the session and sends a final packet to GDB reporting
128 * the exit status of the program. It also cleans up any connections
129 * detritus before returning.
130 */
131void gdb_exit(int code);
132
133void gdb_set_stop_cpu(CPUState *cpu);
134
135/**
136 * gdb_has_xml:
137 * This is an ugly hack to cope with both new and old gdb.
138 * If gdb sends qXfer:features:read then assume we're talking to a newish
139 * gdb that understands target descriptions.
140 */
141extern bool gdb_has_xml;
142
143/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
144extern const char *const xml_builtin[][2];
145
146#endif
31void gdb_set_stop_cpu(CPUState *cpu);
32
33/**
34 * gdb_has_xml:
35 * This is an ugly hack to cope with both new and old gdb.
36 * If gdb sends qXfer:features:read then assume we're talking to a newish
37 * gdb that understands target descriptions.
38 */
39extern bool gdb_has_xml;
40
41/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
42extern const char *const xml_builtin[][2];
43
44#endif