Share i386-linux target description between GDB and GDBserver
[deliverable/binutils-gdb.git] / gdb / gdbserver / tdesc.h
1 /* Target description definitions for remote server for GDB.
2 Copyright (C) 2012-2017 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef TDESC_H
20 #define TDESC_H
21
22 #include "arch/tdesc.h"
23
24 #include "regdef.h"
25
26 typedef struct reg *tdesc_reg_p;
27 DEF_VEC_P(tdesc_reg_p);
28
29 struct tdesc_feature
30 {};
31
32 /* A target description. Inherit from tdesc_feature so that target_desc
33 can be used as tdesc_feature. */
34
35 struct target_desc : tdesc_feature
36 {
37 /* A vector of elements of register definitions that
38 describe the inferior's register set. */
39 VEC(tdesc_reg_p) *reg_defs;
40
41 /* The register cache size, in bytes. */
42 int registers_size;
43
44 #ifndef IN_PROCESS_AGENT
45 /* An array of register names. These are the "expedite" registers:
46 registers whose values are sent along with stop replies. */
47 const char **expedite_regs = NULL;
48
49 /* Defines what to return when looking for the "target.xml" file in
50 response to qXfer:features:read. Its contents can either be
51 verbatim XML code (prefixed with a '@') or else the name of the
52 actual XML file to be used in place of "target.xml".
53
54 It can be NULL, then, its content is got from the following three
55 fields features, arch, and osabi in tdesc_get_features_xml. */
56 const char *xmltarget = NULL;
57
58 /* XML features in this target description. */
59 VEC (char_ptr) *features = NULL;
60
61 /* The value of <architecture> element in the XML, replying GDB. */
62 const char *arch = NULL;
63
64 /* The value of <osabi> element in the XML, replying GDB. */
65 const char *osabi = NULL;
66
67 public:
68 target_desc ()
69 : reg_defs (NULL), registers_size (0)
70 {}
71
72 ~target_desc ()
73 {
74 int i;
75 struct reg *reg;
76
77 for (i = 0; VEC_iterate (tdesc_reg_p, reg_defs, i, reg); i++)
78 xfree (reg);
79 VEC_free (tdesc_reg_p, reg_defs);
80
81 xfree ((char *) arch);
82 xfree ((char *) osabi);
83
84 char *f;
85
86 for (i = 0; VEC_iterate (char_ptr, features, i, f); i++)
87 xfree (f);
88 VEC_free (char_ptr, features);
89 }
90
91 bool operator== (const target_desc &other) const
92 {
93 if (VEC_length (tdesc_reg_p, reg_defs)
94 != VEC_length (tdesc_reg_p, other.reg_defs))
95 return false;
96
97 struct reg *reg;
98
99 for (int ix = 0;
100 VEC_iterate (tdesc_reg_p, reg_defs, ix, reg);
101 ix++)
102 {
103 struct reg *reg2
104 = VEC_index (tdesc_reg_p, other.reg_defs, ix);
105
106 if (reg != reg2 && *reg != *reg2)
107 return false;
108 }
109
110 /* Compare expedite_regs. */
111 int i = 0;
112 for (; expedite_regs[i] != NULL; i++)
113 {
114 if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0)
115 return false;
116 }
117 if (other.expedite_regs[i] != NULL)
118 return false;
119
120 return true;
121 }
122
123 bool operator!= (const target_desc &other) const
124 {
125 return !(*this == other);
126 }
127 #endif
128 };
129
130 /* Copy target description SRC to DEST. */
131
132 void copy_target_description (struct target_desc *dest,
133 const struct target_desc *src);
134
135 /* Initialize TDESC. */
136
137 void init_target_desc (struct target_desc *tdesc);
138
139 /* Return the current inferior's target description. Never returns
140 NULL. */
141
142 const struct target_desc *current_target_desc (void);
143
144 #ifndef IN_PROCESS_AGENT
145 const char *tdesc_get_features_xml (struct target_desc *tdesc);
146 #endif
147
148 #endif /* TDESC_H */
This page took 0.041289 seconds and 4 git commands to generate.