xref: /openbmc/qemu/include/exec/gdbstub.h (revision 735e354a)
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 typedef struct GDBFeature {
14     const char *xmlname;
15     const char *xml;
16     int num_regs;
17 } GDBFeature;
18 
19 typedef struct GDBFeatureBuilder {
20     GDBFeature *feature;
21     GPtrArray *xml;
22     int base_reg;
23 } GDBFeatureBuilder;
24 
25 
26 /* Get or set a register.  Returns the size of the register.  */
27 typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg);
28 typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
29 
30 /**
31  * gdb_register_coprocessor() - register a supplemental set of registers
32  * @cpu - the CPU associated with registers
33  * @get_reg - get function (gdb reading)
34  * @set_reg - set function (gdb modifying)
35  * @num_regs - number of registers in set
36  * @xml - xml name of set
37  * @gpos - non-zero to append to "general" register set at @gpos
38  */
39 void gdb_register_coprocessor(CPUState *cpu,
40                               gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
41                               int num_regs, const char *xml, int g_pos);
42 
43 /**
44  * gdbserver_start: start the gdb server
45  * @port_or_device: connection spec for gdb
46  *
47  * For CONFIG_USER this is either a tcp port or a path to a fifo. For
48  * system emulation you can use a full chardev spec for your gdbserver
49  * port.
50  */
51 int gdbserver_start(const char *port_or_device);
52 
53 /**
54  * gdb_feature_builder_init() - Initialize GDBFeatureBuilder.
55  * @builder: The builder to be initialized.
56  * @feature: The feature to be filled.
57  * @name: The name of the feature.
58  * @xmlname: The name of the XML.
59  * @base_reg: The base number of the register ID.
60  */
61 void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
62                               const char *name, const char *xmlname,
63                               int base_reg);
64 
65 /**
66  * gdb_feature_builder_append_tag() - Append a tag.
67  * @builder: The builder.
68  * @format: The format of the tag.
69  * @...: The values to be formatted.
70  */
71 void G_GNUC_PRINTF(2, 3)
72 gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder,
73                                const char *format, ...);
74 
75 /**
76  * gdb_feature_builder_append_reg() - Append a register.
77  * @builder: The builder.
78  * @name: The register's name; it must be unique within a CPU.
79  * @bitsize: The register's size, in bits.
80  * @regnum: The offset of the register's number in the feature.
81  * @type: The type of the register.
82  * @group: The register group to which this register belongs; it can be NULL.
83  */
84 void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder,
85                                     const char *name,
86                                     int bitsize,
87                                     int regnum,
88                                     const char *type,
89                                     const char *group);
90 
91 /**
92  * gdb_feature_builder_end() - End building GDBFeature.
93  * @builder: The builder.
94  */
95 void gdb_feature_builder_end(const GDBFeatureBuilder *builder);
96 
97 /**
98  * gdb_find_static_feature() - Find a static feature.
99  * @xmlname: The name of the XML.
100  *
101  * Return: The static feature.
102  */
103 const GDBFeature *gdb_find_static_feature(const char *xmlname);
104 
105 void gdb_set_stop_cpu(CPUState *cpu);
106 
107 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */
108 extern const GDBFeature gdb_static_features[];
109 
110 #endif
111