Revisión | adf36b54284ea70cfdb8224faacdf5c0f3e0ba89 (tree) |
---|---|
Tiempo | 2019-08-21 00:24:37 |
Autor | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
RX: Convert target-description
gdb/ChangeLog
2019-08-21 Yoshinori Sato <ysato@users.sourceforge.jp>
* gdb/rx-tdep.c (rx_register_names): New.
(rx_register_name): Use rx_register_names.
(rx_register_name): Add check range.
(rx_register_g_packet_guesses): New.
(rx_gdbarch_init): Convert target-descriptions.
(_initialize_rx_tdep): Add initialize_tdesc_rx.
* gdb/features/Makefile: Add rx.xml.
* gdb/features/rx.xml: New.
@@ -161,6 +161,7 @@ XMLTOC = \ | ||
161 | 161 | rs6000/powerpc-vsx64.xml \ |
162 | 162 | rs6000/powerpc-vsx64l.xml \ |
163 | 163 | rs6000/rs6000.xml \ |
164 | + rx.xml \ | |
164 | 165 | s390-linux32.xml \ |
165 | 166 | s390-linux32v1.xml \ |
166 | 167 | s390-linux32v2.xml \ |
@@ -238,6 +239,7 @@ FEATURE_XMLFILES = aarch64-core.xml \ | ||
238 | 239 | riscv/64bit-cpu.xml \ |
239 | 240 | riscv/64bit-csr.xml \ |
240 | 241 | riscv/64bit-fpu.xml \ |
242 | + rx.xml \ | |
241 | 243 | tic6x-c6xp.xml \ |
242 | 244 | tic6x-core.xml \ |
243 | 245 | tic6x-gp.xml |
@@ -0,0 +1,70 @@ | ||
1 | +<?xml version="1.0"?> | |
2 | +<!-- Copyright (C) 2019 Free Software Foundation, Inc. | |
3 | + | |
4 | + Copying and distribution of this file, with or without modification, | |
5 | + are permitted in any medium without royalty provided the copyright | |
6 | + notice and this notice are preserved. --> | |
7 | + | |
8 | +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> | |
9 | +<feature name="org.gnu.gdb.rx.core"> | |
10 | + <reg name="r0" bitsize="32" type="data_ptr"/> | |
11 | + <reg name="r1" bitsize="32" type="uint32"/> | |
12 | + <reg name="r2" bitsize="32" type="uint32"/> | |
13 | + <reg name="r3" bitsize="32" type="uint32"/> | |
14 | + <reg name="r4" bitsize="32" type="uint32"/> | |
15 | + <reg name="r5" bitsize="32" type="uint32"/> | |
16 | + <reg name="r6" bitsize="32" type="uint32"/> | |
17 | + <reg name="r7" bitsize="32" type="uint32"/> | |
18 | + <reg name="r8" bitsize="32" type="uint32"/> | |
19 | + <reg name="r9" bitsize="32" type="uint32"/> | |
20 | + <reg name="r10" bitsize="32" type="uint32"/> | |
21 | + <reg name="r11" bitsize="32" type="uint32"/> | |
22 | + <reg name="r12" bitsize="32" type="uint32"/> | |
23 | + <reg name="r13" bitsize="32" type="uint32"/> | |
24 | + <reg name="r14" bitsize="32" type="uint32"/> | |
25 | + <reg name="r15" bitsize="32" type="uint32"/> | |
26 | + | |
27 | + <flags id="psw_flags" size="4"> | |
28 | + <field name="C" start="0" end="0"/> | |
29 | + <field name="Z" start="1" end="1"/> | |
30 | + <field name="S" start="2" end="2"/> | |
31 | + <field name="O" start="3" end="3"/> | |
32 | + <field name="I" start="16" end="16"/> | |
33 | + <field name="U" start="17" end="17"/> | |
34 | + <field name="PM" start="20" end="20"/> | |
35 | + <field name="IPL" start="24" end="27"/> | |
36 | + </flags> | |
37 | + | |
38 | + <flags id="fpsw_flags" size="4"> | |
39 | + <field name="RM" start="0" end="1"/> | |
40 | + <field name="CV" start="2" end="2"/> | |
41 | + <field name="CO" start="3" end="3"/> | |
42 | + <field name="CZ" start="4" end="4"/> | |
43 | + <field name="CU" start="5" end="5"/> | |
44 | + <field name="CX" start="6" end="6"/> | |
45 | + <field name="CE" start="7" end="7"/> | |
46 | + <field name="DN" start="8" end="8"/> | |
47 | + <field name="EV" start="10" end="10"/> | |
48 | + <field name="EO" start="11" end="11"/> | |
49 | + <field name="EZ" start="12" end="12"/> | |
50 | + <field name="EU" start="13" end="13"/> | |
51 | + <field name="EX" start="14" end="14"/> | |
52 | + <field name="FV" start="26" end="26"/> | |
53 | + <field name="FO" start="27" end="27"/> | |
54 | + <field name="FZ" start="28" end="28"/> | |
55 | + <field name="FU" start="29" end="29"/> | |
56 | + <field name="FX" start="30" end="30"/> | |
57 | + <field name="FS" start="31" end="31"/> | |
58 | + </flags> | |
59 | + | |
60 | + <reg name="usp" bitsize="32" type="data_ptr"/> | |
61 | + <reg name="isp" bitsize="32" type="data_ptr"/> | |
62 | + <reg name="psw" bitsize="32" type="psw_flags"/> | |
63 | + <reg name="pc" bitsize="32" type="code_ptr"/> | |
64 | + <reg name="intb" bitsize="32" type="data_ptr"/> | |
65 | + <reg name="bpsw" bitsize="32" type="psw_flags"/> | |
66 | + <reg name="bpc" bitsize="32" type="code_ptr"/> | |
67 | + <reg name="fintv" bitsize="32" type="code_ptr"/> | |
68 | + <reg name="fpsw" bitsize="32" type="fpsw_flags"/> | |
69 | + <reg name="acc" bitsize="64" type="uint64"/> | |
70 | +</feature> |
@@ -33,11 +33,15 @@ | ||
33 | 33 | #include "value.h" |
34 | 34 | #include "gdbcore.h" |
35 | 35 | #include "dwarf2-frame.h" |
36 | +#include "remote.h" | |
37 | +#include "target-descriptions.h" | |
36 | 38 | |
37 | 39 | #include "elf/rx.h" |
38 | 40 | #include "elf-bfd.h" |
39 | 41 | #include <algorithm> |
40 | 42 | |
43 | +#include "features/rx.c" | |
44 | + | |
41 | 45 | /* Certain important register numbers. */ |
42 | 46 | enum |
43 | 47 | { |
@@ -114,40 +118,21 @@ struct rx_prologue | ||
114 | 118 | int reg_offset[RX_NUM_REGS]; |
115 | 119 | }; |
116 | 120 | |
121 | +static const char *const rx_register_names[] = { | |
122 | + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
123 | + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", | |
124 | + "usp", "isp", "psw", "pc", "intb", "bpsw","bpc","fintv", | |
125 | + "fpsw", "acc", | |
126 | +}; | |
127 | + | |
117 | 128 | /* Implement the "register_name" gdbarch method. */ |
118 | 129 | static const char * |
119 | 130 | rx_register_name (struct gdbarch *gdbarch, int regnr) |
120 | 131 | { |
121 | - static const char *const reg_names[] = { | |
122 | - "r0", | |
123 | - "r1", | |
124 | - "r2", | |
125 | - "r3", | |
126 | - "r4", | |
127 | - "r5", | |
128 | - "r6", | |
129 | - "r7", | |
130 | - "r8", | |
131 | - "r9", | |
132 | - "r10", | |
133 | - "r11", | |
134 | - "r12", | |
135 | - "r13", | |
136 | - "r14", | |
137 | - "r15", | |
138 | - "usp", | |
139 | - "isp", | |
140 | - "psw", | |
141 | - "pc", | |
142 | - "intb", | |
143 | - "bpsw", | |
144 | - "bpc", | |
145 | - "fintv", | |
146 | - "fpsw", | |
147 | - "acc" | |
148 | - }; | |
149 | - | |
150 | - return reg_names[regnr]; | |
132 | + if (regnr >= 0 && regnr < RX_NUM_REGS) | |
133 | + return rx_register_names[regnr]; | |
134 | + else | |
135 | + return NULL; | |
151 | 136 | } |
152 | 137 | |
153 | 138 | /* Construct the flags type for PSW and BPSW. */ |
@@ -1037,6 +1022,14 @@ rx_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) | ||
1037 | 1022 | return -1; |
1038 | 1023 | } |
1039 | 1024 | |
1025 | +static void | |
1026 | +rx_register_g_packet_guesses (struct gdbarch *gdbarch) | |
1027 | +{ | |
1028 | + register_remote_g_packet_guess (gdbarch, | |
1029 | + 4 * RX_NUM_REGS, | |
1030 | + tdesc_rx); | |
1031 | +} | |
1032 | + | |
1040 | 1033 | /* Allocate and initialize a gdbarch object. */ |
1041 | 1034 | static struct gdbarch * |
1042 | 1035 | rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) |
@@ -1044,6 +1037,8 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1044 | 1037 | struct gdbarch *gdbarch; |
1045 | 1038 | struct gdbarch_tdep *tdep; |
1046 | 1039 | int elf_flags; |
1040 | + struct tdesc_arch_data *tdesc_data = NULL; | |
1041 | + const struct target_desc *tdesc = info.target_desc; | |
1047 | 1042 | |
1048 | 1043 | /* Extract the elf_flags if available. */ |
1049 | 1044 | if (info.abfd != NULL |
@@ -1065,8 +1060,33 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1065 | 1060 | return arches->gdbarch; |
1066 | 1061 | } |
1067 | 1062 | |
1068 | - /* None found, create a new architecture from the information | |
1069 | - provided. */ | |
1063 | + if (tdesc == NULL) | |
1064 | + tdesc = tdesc_rx; | |
1065 | + | |
1066 | + /* Check any target description for validity. */ | |
1067 | + if (tdesc_has_registers (tdesc)) | |
1068 | + { | |
1069 | + const struct tdesc_feature *feature; | |
1070 | + int valid_p = 0; | |
1071 | + int i = 0; | |
1072 | + feature = tdesc_find_feature (tdesc, "org.gnu.gdb.rx.core"); | |
1073 | + | |
1074 | + if (feature != NULL) | |
1075 | + { | |
1076 | + tdesc_data = tdesc_data_alloc (); | |
1077 | + valid_p = 1; | |
1078 | + for (i = 0; i < RX_NUM_REGS; i++) | |
1079 | + valid_p &= tdesc_numbered_register (feature, tdesc_data, i, | |
1080 | + rx_register_names[i]); | |
1081 | + } | |
1082 | + | |
1083 | + if (!valid_p) | |
1084 | + { | |
1085 | + tdesc_data_cleanup (tdesc_data); | |
1086 | + return NULL; | |
1087 | + } | |
1088 | + } | |
1089 | + | |
1070 | 1090 | tdep = XCNEW (struct gdbarch_tdep); |
1071 | 1091 | gdbarch = gdbarch_alloc (&info, tdep); |
1072 | 1092 | tdep->elf_flags = elf_flags; |
@@ -1083,15 +1103,6 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1083 | 1103 | set_gdbarch_sw_breakpoint_from_kind (gdbarch, rx_breakpoint::bp_from_kind); |
1084 | 1104 | set_gdbarch_skip_prologue (gdbarch, rx_skip_prologue); |
1085 | 1105 | |
1086 | - /* Target builtin data types. */ | |
1087 | - set_gdbarch_char_signed (gdbarch, 0); | |
1088 | - set_gdbarch_short_bit (gdbarch, 16); | |
1089 | - set_gdbarch_int_bit (gdbarch, 32); | |
1090 | - set_gdbarch_long_bit (gdbarch, 32); | |
1091 | - set_gdbarch_long_long_bit (gdbarch, 64); | |
1092 | - set_gdbarch_ptr_bit (gdbarch, 32); | |
1093 | - set_gdbarch_float_bit (gdbarch, 32); | |
1094 | - set_gdbarch_float_format (gdbarch, floatformats_ieee_single); | |
1095 | 1106 | if (elf_flags & E_FLAG_RX_64BIT_DOUBLES) |
1096 | 1107 | { |
1097 | 1108 | set_gdbarch_double_bit (gdbarch, 64); |
@@ -1115,6 +1126,8 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1115 | 1126 | dwarf2_append_unwinders (gdbarch); |
1116 | 1127 | frame_unwind_append_unwinder (gdbarch, &rx_frame_unwind); |
1117 | 1128 | |
1129 | + rx_register_g_packet_guesses (gdbarch); | |
1130 | + | |
1118 | 1131 | /* Methods setting up a dummy call, and extracting the return value from |
1119 | 1132 | a call. */ |
1120 | 1133 | set_gdbarch_push_dummy_call (gdbarch, rx_push_dummy_call); |
@@ -1123,6 +1136,9 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1123 | 1136 | /* Virtual tables. */ |
1124 | 1137 | set_gdbarch_vbit_in_delta (gdbarch, 1); |
1125 | 1138 | |
1139 | + if (tdesc_data != NULL) | |
1140 | + tdesc_use_registers (gdbarch, tdesc, tdesc_data); | |
1141 | + | |
1126 | 1142 | return gdbarch; |
1127 | 1143 | } |
1128 | 1144 |
@@ -1132,4 +1148,5 @@ void | ||
1132 | 1148 | _initialize_rx_tdep (void) |
1133 | 1149 | { |
1134 | 1150 | register_gdbarch_init (bfd_arch_rx, rx_gdbarch_init); |
1151 | + initialize_tdesc_rx (); | |
1135 | 1152 | } |