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