Commit | Line | Data |
---|---|---|
3aee8918 | 1 | /* Target description definitions for remote server for GDB. |
e2882c85 | 2 | Copyright (C) 2012-2018 Free Software Foundation, Inc. |
3aee8918 PA |
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 | ||
f46cd62a | 22 | #include "common/tdesc.h" |
f49ff000 | 23 | |
0a188386 | 24 | #include "regdef.h" |
c4dfafab | 25 | #include <vector> |
f7000548 | 26 | |
f49ff000 YQ |
27 | struct tdesc_feature |
28 | {}; | |
29 | ||
30 | /* A target description. Inherit from tdesc_feature so that target_desc | |
31 | can be used as tdesc_feature. */ | |
3aee8918 | 32 | |
f49ff000 | 33 | struct target_desc : tdesc_feature |
3aee8918 | 34 | { |
f7000548 | 35 | /* A vector of elements of register definitions that |
3aee8918 | 36 | describe the inferior's register set. */ |
c4dfafab | 37 | std::vector<struct reg *> reg_defs; |
3aee8918 PA |
38 | |
39 | /* The register cache size, in bytes. */ | |
40 | int registers_size; | |
41 | ||
adc764e7 | 42 | #ifndef IN_PROCESS_AGENT |
3aee8918 PA |
43 | /* An array of register names. These are the "expedite" registers: |
44 | registers whose values are sent along with stop replies. */ | |
f49ff000 | 45 | const char **expedite_regs = NULL; |
3aee8918 PA |
46 | |
47 | /* Defines what to return when looking for the "target.xml" file in | |
48 | response to qXfer:features:read. Its contents can either be | |
49 | verbatim XML code (prefixed with a '@') or else the name of the | |
0abe8a89 YQ |
50 | actual XML file to be used in place of "target.xml". |
51 | ||
52 | It can be NULL, then, its content is got from the following three | |
53 | fields features, arch, and osabi in tdesc_get_features_xml. */ | |
f49ff000 YQ |
54 | const char *xmltarget = NULL; |
55 | ||
0abe8a89 YQ |
56 | /* XML features in this target description. */ |
57 | VEC (char_ptr) *features = NULL; | |
58 | ||
59 | /* The value of <architecture> element in the XML, replying GDB. */ | |
60 | const char *arch = NULL; | |
61 | ||
62 | /* The value of <osabi> element in the XML, replying GDB. */ | |
63 | const char *osabi = NULL; | |
64 | ||
f49ff000 YQ |
65 | public: |
66 | target_desc () | |
c4dfafab | 67 | : registers_size (0) |
f49ff000 YQ |
68 | {} |
69 | ||
70 | ~target_desc () | |
71 | { | |
72 | int i; | |
f49ff000 | 73 | |
c4dfafab | 74 | for (reg *reg : reg_defs) |
f49ff000 | 75 | xfree (reg); |
0abe8a89 YQ |
76 | |
77 | xfree ((char *) arch); | |
78 | xfree ((char *) osabi); | |
79 | ||
80 | char *f; | |
81 | ||
82 | for (i = 0; VEC_iterate (char_ptr, features, i, f); i++) | |
83 | xfree (f); | |
84 | VEC_free (char_ptr, features); | |
f49ff000 | 85 | } |
0a188386 YQ |
86 | |
87 | bool operator== (const target_desc &other) const | |
88 | { | |
c4dfafab | 89 | if (reg_defs.size () != other.reg_defs.size ()) |
0a188386 YQ |
90 | return false; |
91 | ||
c4dfafab | 92 | for (int i = 0; i < reg_defs.size (); ++i) |
0a188386 | 93 | { |
c4dfafab SDJ |
94 | struct reg *reg = reg_defs[i]; |
95 | struct reg *reg2 = other.reg_defs[i]; | |
0a188386 YQ |
96 | |
97 | if (reg != reg2 && *reg != *reg2) | |
98 | return false; | |
99 | } | |
100 | ||
101 | /* Compare expedite_regs. */ | |
102 | int i = 0; | |
103 | for (; expedite_regs[i] != NULL; i++) | |
104 | { | |
105 | if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0) | |
106 | return false; | |
107 | } | |
108 | if (other.expedite_regs[i] != NULL) | |
109 | return false; | |
110 | ||
0a188386 YQ |
111 | return true; |
112 | } | |
113 | ||
114 | bool operator!= (const target_desc &other) const | |
115 | { | |
116 | return !(*this == other); | |
117 | } | |
adc764e7 | 118 | #endif |
3aee8918 PA |
119 | }; |
120 | ||
121 | /* Copy target description SRC to DEST. */ | |
122 | ||
123 | void copy_target_description (struct target_desc *dest, | |
124 | const struct target_desc *src); | |
125 | ||
126 | /* Initialize TDESC. */ | |
127 | ||
128 | void init_target_desc (struct target_desc *tdesc); | |
129 | ||
130 | /* Return the current inferior's target description. Never returns | |
131 | NULL. */ | |
132 | ||
133 | const struct target_desc *current_target_desc (void); | |
134 | ||
0abe8a89 | 135 | #ifndef IN_PROCESS_AGENT |
0abe8a89 YQ |
136 | const char *tdesc_get_features_xml (struct target_desc *tdesc); |
137 | #endif | |
138 | ||
3aee8918 | 139 | #endif /* TDESC_H */ |