Commit | Line | Data |
---|---|---|
3aee8918 | 1 | /* Target description definitions for remote server for GDB. |
61baf725 | 2 | Copyright (C) 2012-2017 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 | ||
f49ff000 YQ |
22 | #include "arch/tdesc.h" |
23 | ||
0a188386 | 24 | #include "regdef.h" |
3aee8918 | 25 | |
f7000548 YQ |
26 | typedef struct reg *tdesc_reg_p; |
27 | DEF_VEC_P(tdesc_reg_p); | |
28 | ||
f49ff000 YQ |
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. */ | |
3aee8918 | 34 | |
f49ff000 | 35 | struct target_desc : tdesc_feature |
3aee8918 | 36 | { |
f7000548 | 37 | /* A vector of elements of register definitions that |
3aee8918 | 38 | describe the inferior's register set. */ |
f7000548 | 39 | VEC(tdesc_reg_p) *reg_defs; |
3aee8918 PA |
40 | |
41 | /* The register cache size, in bytes. */ | |
42 | int registers_size; | |
43 | ||
adc764e7 | 44 | #ifndef IN_PROCESS_AGENT |
3aee8918 PA |
45 | /* An array of register names. These are the "expedite" registers: |
46 | registers whose values are sent along with stop replies. */ | |
f49ff000 | 47 | const char **expedite_regs = NULL; |
3aee8918 PA |
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". */ | |
f49ff000 YQ |
53 | const char *xmltarget = NULL; |
54 | ||
55 | public: | |
56 | target_desc () | |
57 | : reg_defs (NULL), registers_size (0) | |
58 | {} | |
59 | ||
60 | ~target_desc () | |
61 | { | |
62 | int i; | |
63 | struct reg *reg; | |
64 | ||
65 | for (i = 0; VEC_iterate (tdesc_reg_p, reg_defs, i, reg); i++) | |
66 | xfree (reg); | |
67 | VEC_free (tdesc_reg_p, reg_defs); | |
68 | } | |
0a188386 YQ |
69 | |
70 | bool operator== (const target_desc &other) const | |
71 | { | |
72 | if (VEC_length (tdesc_reg_p, reg_defs) | |
73 | != VEC_length (tdesc_reg_p, other.reg_defs)) | |
74 | return false; | |
75 | ||
76 | struct reg *reg; | |
77 | ||
78 | for (int ix = 0; | |
79 | VEC_iterate (tdesc_reg_p, reg_defs, ix, reg); | |
80 | ix++) | |
81 | { | |
82 | struct reg *reg2 | |
83 | = VEC_index (tdesc_reg_p, other.reg_defs, ix); | |
84 | ||
85 | if (reg != reg2 && *reg != *reg2) | |
86 | return false; | |
87 | } | |
88 | ||
89 | /* Compare expedite_regs. */ | |
90 | int i = 0; | |
91 | for (; expedite_regs[i] != NULL; i++) | |
92 | { | |
93 | if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0) | |
94 | return false; | |
95 | } | |
96 | if (other.expedite_regs[i] != NULL) | |
97 | return false; | |
98 | ||
99 | if (strcmp (xmltarget, other.xmltarget) != 0) | |
100 | return false; | |
101 | ||
102 | return true; | |
103 | } | |
104 | ||
105 | bool operator!= (const target_desc &other) const | |
106 | { | |
107 | return !(*this == other); | |
108 | } | |
adc764e7 | 109 | #endif |
3aee8918 PA |
110 | }; |
111 | ||
112 | /* Copy target description SRC to DEST. */ | |
113 | ||
114 | void copy_target_description (struct target_desc *dest, | |
115 | const struct target_desc *src); | |
116 | ||
117 | /* Initialize TDESC. */ | |
118 | ||
119 | void init_target_desc (struct target_desc *tdesc); | |
120 | ||
121 | /* Return the current inferior's target description. Never returns | |
122 | NULL. */ | |
123 | ||
124 | const struct target_desc *current_target_desc (void); | |
125 | ||
126 | #endif /* TDESC_H */ |