diff options
| author | Mark Hatle <mark.hatle@kernel.crashing.org> | 2020-12-07 14:22:05 -0600 |
|---|---|---|
| committer | Mark Hatle <mark.hatle@kernel.crashing.org> | 2020-12-07 14:22:05 -0600 |
| commit | b3e37df5d909a977c14144cdc2e5b8691fbfd82b (patch) | |
| tree | 9845f654dc9b99501a74c9717e46db5bf771a7d3 /meta-microblaze/recipes-devtools/binutils | |
| parent | ed3fc52e54a4412a410170377f3e72e2364b5a5d (diff) | |
| download | meta-xilinx-b3e37df5d909a977c14144cdc2e5b8691fbfd82b.tar.gz | |
gdb: Fix on-target GDB compilation
Target gdb/gdbserver failed to compile due to out of date
microblaze-linux-nat.c, correct this and ancillary files. Note, this only
corrects compilation the code may not function properly.
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils')
| -rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils-microblaze.inc | 1 | ||||
| -rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils/0053-gdb-Fix-microblaze-target-compilation.patch | 288 |
2 files changed, 289 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils-microblaze.inc b/meta-microblaze/recipes-devtools/binutils/binutils-microblaze.inc index 27ed147d..c1a7bb4c 100644 --- a/meta-microblaze/recipes-devtools/binutils/binutils-microblaze.inc +++ b/meta-microblaze/recipes-devtools/binutils/binutils-microblaze.inc | |||
| @@ -53,6 +53,7 @@ SRC_URI_append = " \ | |||
| 53 | file://0050-opcodes-microblaze-dis.c-Fix-compile-warnings.patch \ | 53 | file://0050-opcodes-microblaze-dis.c-Fix-compile-warnings.patch \ |
| 54 | file://0051-gdb-microblaze-tdep.c-Remove-unused-functions.patch \ | 54 | file://0051-gdb-microblaze-tdep.c-Remove-unused-functions.patch \ |
| 55 | file://0052-sim-Allow-microblaze-architecture.patch \ | 55 | file://0052-sim-Allow-microblaze-architecture.patch \ |
| 56 | file://0053-gdb-Fix-microblaze-target-compilation.patch \ | ||
| 56 | " | 57 | " |
| 57 | 58 | ||
| 58 | # | 59 | # |
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0053-gdb-Fix-microblaze-target-compilation.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0053-gdb-Fix-microblaze-target-compilation.patch new file mode 100644 index 00000000..af0e3268 --- /dev/null +++ b/meta-microblaze/recipes-devtools/binutils/binutils/0053-gdb-Fix-microblaze-target-compilation.patch | |||
| @@ -0,0 +1,288 @@ | |||
| 1 | From efa3750ffda1ae16caf071b8b8ea31f752a3324a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Hatle <mark.hatle@kernel.crashing.org> | ||
| 3 | Date: Mon, 7 Dec 2020 12:03:25 -0600 | ||
| 4 | Subject: [PATCH] gdb: Fix microblaze target compilation | ||
| 5 | |||
| 6 | Add microblaze-linux-nat.c to configure.nat | ||
| 7 | |||
| 8 | Transition microblaze-linux-nat.c to use the new gdb C++ style functions. | ||
| 9 | |||
| 10 | Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> | ||
| 11 | --- | ||
| 12 | gdb/configure.nat | 5 ++ | ||
| 13 | gdb/microblaze-linux-nat.c | 96 ++++++++++++++------------------------ | ||
| 14 | gdb/microblaze-tdep.h | 3 ++ | ||
| 15 | 3 files changed, 43 insertions(+), 61 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/gdb/configure.nat b/gdb/configure.nat | ||
| 18 | index 6ea2583495..1fba80f6c9 100644 | ||
| 19 | --- a/gdb/configure.nat | ||
| 20 | +++ b/gdb/configure.nat | ||
| 21 | @@ -261,6 +261,11 @@ case ${gdb_host} in | ||
| 22 | # Host: Motorola m68k running GNU/Linux. | ||
| 23 | NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o" | ||
| 24 | ;; | ||
| 25 | + microblaze) | ||
| 26 | + # Host: Microblaze running GNU/Linux. | ||
| 27 | + NATDEPFILES="${NATDEPFILES} microblaze-linux-nat.o" | ||
| 28 | + NAT_CDEPS= | ||
| 29 | + ;; | ||
| 30 | mips) | ||
| 31 | # Host: Linux/MIPS | ||
| 32 | NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \ | ||
| 33 | diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c | ||
| 34 | index e9b8c9c522..bac4697e1e 100644 | ||
| 35 | --- a/gdb/microblaze-linux-nat.c | ||
| 36 | +++ b/gdb/microblaze-linux-nat.c | ||
| 37 | @@ -36,13 +36,14 @@ | ||
| 38 | #include "dwarf2-frame.h" | ||
| 39 | #include "osabi.h" | ||
| 40 | |||
| 41 | -#include "gdb_assert.h" | ||
| 42 | -#include "gdb_string.h" | ||
| 43 | +#include "gdbsupport/gdb_assert.h" | ||
| 44 | +#include <string.h> | ||
| 45 | #include "target-descriptions.h" | ||
| 46 | #include "opcodes/microblaze-opcm.h" | ||
| 47 | #include "opcodes/microblaze-dis.h" | ||
| 48 | |||
| 49 | #include "linux-nat.h" | ||
| 50 | +#include "linux-tdep.h" | ||
| 51 | #include "target-descriptions.h" | ||
| 52 | |||
| 53 | #include <sys/user.h> | ||
| 54 | @@ -61,22 +62,17 @@ | ||
| 55 | /* Defines ps_err_e, struct ps_prochandle. */ | ||
| 56 | #include "gdb_proc_service.h" | ||
| 57 | |||
| 58 | -/* On GNU/Linux, threads are implemented as pseudo-processes, in which | ||
| 59 | - case we may be tracing more than one process at a time. In that | ||
| 60 | - case, inferior_ptid will contain the main process ID and the | ||
| 61 | - individual thread (process) ID. get_thread_id () is used to get | ||
| 62 | - the thread id if it's available, and the process id otherwise. */ | ||
| 63 | - | ||
| 64 | -int | ||
| 65 | -get_thread_id (ptid_t ptid) | ||
| 66 | +class microblaze_linux_nat_target final : public linux_nat_target | ||
| 67 | { | ||
| 68 | - int tid = TIDGET (ptid); | ||
| 69 | - if (0 == tid) | ||
| 70 | - tid = PIDGET (ptid); | ||
| 71 | - return tid; | ||
| 72 | -} | ||
| 73 | +public: | ||
| 74 | + /* Add our register access methods. */ | ||
| 75 | + void fetch_registers (struct regcache *, int) override; | ||
| 76 | + void store_registers (struct regcache *, int) override; | ||
| 77 | + | ||
| 78 | + const struct target_desc *read_description () override; | ||
| 79 | +}; | ||
| 80 | |||
| 81 | -#define GET_THREAD_ID(PTID) get_thread_id (PTID) | ||
| 82 | +static microblaze_linux_nat_target the_microblaze_linux_nat_target; | ||
| 83 | |||
| 84 | /* Non-zero if our kernel may support the PTRACE_GETREGS and | ||
| 85 | PTRACE_SETREGS requests, for reading and writing the | ||
| 86 | @@ -88,7 +84,6 @@ static int | ||
| 87 | microblaze_register_u_addr (struct gdbarch *gdbarch, int regno) | ||
| 88 | { | ||
| 89 | int u_addr = -1; | ||
| 90 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 91 | /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace | ||
| 92 | interface, and not the wordsize of the program's ABI. */ | ||
| 93 | int wordsize = sizeof (long); | ||
| 94 | @@ -105,18 +100,16 @@ microblaze_register_u_addr (struct gdbarch *gdbarch, int regno) | ||
| 95 | static void | ||
| 96 | fetch_register (struct regcache *regcache, int tid, int regno) | ||
| 97 | { | ||
| 98 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 99 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 100 | + struct gdbarch *gdbarch = regcache->arch (); | ||
| 101 | /* This isn't really an address. But ptrace thinks of it as one. */ | ||
| 102 | CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno); | ||
| 103 | int bytes_transferred; | ||
| 104 | - unsigned int offset; /* Offset of registers within the u area. */ | ||
| 105 | - char buf[MAX_REGISTER_SIZE]; | ||
| 106 | + char buf[MICROBLAZE_MAX_REGISTER_SIZE]; | ||
| 107 | |||
| 108 | if (regaddr == -1) | ||
| 109 | { | ||
| 110 | memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */ | ||
| 111 | - regcache_raw_supply (regcache, regno, buf); | ||
| 112 | + regcache->raw_supply (regno, buf); | ||
| 113 | return; | ||
| 114 | } | ||
| 115 | |||
| 116 | @@ -149,14 +142,14 @@ fetch_register (struct regcache *regcache, int tid, int regno) | ||
| 117 | { | ||
| 118 | /* Little-endian values are always found at the left end of the | ||
| 119 | bytes transferred. */ | ||
| 120 | - regcache_raw_supply (regcache, regno, buf); | ||
| 121 | + regcache->raw_supply (regno, buf); | ||
| 122 | } | ||
| 123 | else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) | ||
| 124 | { | ||
| 125 | /* Big-endian values are found at the right end of the bytes | ||
| 126 | transferred. */ | ||
| 127 | size_t padding = (bytes_transferred - register_size (gdbarch, regno)); | ||
| 128 | - regcache_raw_supply (regcache, regno, buf + padding); | ||
| 129 | + regcache->raw_supply (regno, buf + padding); | ||
| 130 | } | ||
| 131 | else | ||
| 132 | internal_error (__FILE__, __LINE__, | ||
| 133 | @@ -175,8 +168,6 @@ fetch_register (struct regcache *regcache, int tid, int regno) | ||
| 134 | static int | ||
| 135 | fetch_all_gp_regs (struct regcache *regcache, int tid) | ||
| 136 | { | ||
| 137 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 138 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 139 | gdb_gregset_t gregset; | ||
| 140 | |||
| 141 | if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0) | ||
| 142 | @@ -204,8 +195,6 @@ fetch_all_gp_regs (struct regcache *regcache, int tid) | ||
| 143 | static void | ||
| 144 | fetch_gp_regs (struct regcache *regcache, int tid) | ||
| 145 | { | ||
| 146 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 147 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 148 | int i; | ||
| 149 | |||
| 150 | if (have_ptrace_getsetregs) | ||
| 151 | @@ -223,13 +212,12 @@ fetch_gp_regs (struct regcache *regcache, int tid) | ||
| 152 | static void | ||
| 153 | store_register (const struct regcache *regcache, int tid, int regno) | ||
| 154 | { | ||
| 155 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 156 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 157 | + struct gdbarch *gdbarch = regcache->arch (); | ||
| 158 | /* This isn't really an address. But ptrace thinks of it as one. */ | ||
| 159 | CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno); | ||
| 160 | int i; | ||
| 161 | size_t bytes_to_transfer; | ||
| 162 | - char buf[MAX_REGISTER_SIZE]; | ||
| 163 | + char buf[MICROBLAZE_MAX_REGISTER_SIZE]; | ||
| 164 | |||
| 165 | if (regaddr == -1) | ||
| 166 | return; | ||
| 167 | @@ -242,13 +230,13 @@ store_register (const struct regcache *regcache, int tid, int regno) | ||
| 168 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) | ||
| 169 | { | ||
| 170 | /* Little-endian values always sit at the left end of the buffer. */ | ||
| 171 | - regcache_raw_collect (regcache, regno, buf); | ||
| 172 | + regcache->raw_collect (regno, buf); | ||
| 173 | } | ||
| 174 | else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) | ||
| 175 | { | ||
| 176 | /* Big-endian values sit at the right end of the buffer. */ | ||
| 177 | size_t padding = (bytes_to_transfer - register_size (gdbarch, regno)); | ||
| 178 | - regcache_raw_collect (regcache, regno, buf + padding); | ||
| 179 | + regcache->raw_collect (regno, buf + padding); | ||
| 180 | } | ||
| 181 | |||
| 182 | for (i = 0; i < bytes_to_transfer; i += sizeof (long)) | ||
| 183 | @@ -281,8 +269,6 @@ store_register (const struct regcache *regcache, int tid, int regno) | ||
| 184 | static int | ||
| 185 | store_all_gp_regs (const struct regcache *regcache, int tid, int regno) | ||
| 186 | { | ||
| 187 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 188 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 189 | gdb_gregset_t gregset; | ||
| 190 | |||
| 191 | if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0) | ||
| 192 | @@ -319,8 +305,6 @@ store_all_gp_regs (const struct regcache *regcache, int tid, int regno) | ||
| 193 | static void | ||
| 194 | store_gp_regs (const struct regcache *regcache, int tid, int regno) | ||
| 195 | { | ||
| 196 | - struct gdbarch *gdbarch = get_regcache_arch (regcache); | ||
| 197 | - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | ||
| 198 | int i; | ||
| 199 | |||
| 200 | if (have_ptrace_getsetregs) | ||
| 201 | @@ -339,12 +323,12 @@ store_gp_regs (const struct regcache *regcache, int tid, int regno) | ||
| 202 | regno == -1, otherwise fetch all general registers or all floating | ||
| 203 | point registers depending upon the value of regno. */ | ||
| 204 | |||
| 205 | -static void | ||
| 206 | -microblaze_linux_fetch_inferior_registers (struct target_ops *ops, | ||
| 207 | - struct regcache *regcache, int regno) | ||
| 208 | +void | ||
| 209 | +microblaze_linux_nat_target::fetch_registers (struct regcache * regcache, | ||
| 210 | + int regno) | ||
| 211 | { | ||
| 212 | /* Get the thread id for the ptrace call. */ | ||
| 213 | - int tid = GET_THREAD_ID (inferior_ptid); | ||
| 214 | + int tid = regcache->ptid ().lwp (); | ||
| 215 | |||
| 216 | if (regno == -1) | ||
| 217 | fetch_gp_regs (regcache, tid); | ||
| 218 | @@ -356,12 +340,12 @@ microblaze_linux_fetch_inferior_registers (struct target_ops *ops, | ||
| 219 | regno == -1, otherwise store all general registers or all floating | ||
| 220 | point registers depending upon the value of regno. */ | ||
| 221 | |||
| 222 | -static void | ||
| 223 | -microblaze_linux_store_inferior_registers (struct target_ops *ops, | ||
| 224 | - struct regcache *regcache, int regno) | ||
| 225 | +void | ||
| 226 | +microblaze_linux_nat_target::store_registers (struct regcache *regcache, | ||
| 227 | + int regno) | ||
| 228 | { | ||
| 229 | /* Get the thread id for the ptrace call. */ | ||
| 230 | - int tid = GET_THREAD_ID (inferior_ptid); | ||
| 231 | + int tid = regcache->ptid ().lwp (); | ||
| 232 | |||
| 233 | if (regno >= 0) | ||
| 234 | store_register (regcache, tid, regno); | ||
| 235 | @@ -398,12 +382,12 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) | ||
| 236 | /* FIXME. */ | ||
| 237 | } | ||
| 238 | |||
| 239 | -static const struct target_desc * | ||
| 240 | -microblaze_linux_read_description (struct target_ops *ops) | ||
| 241 | +const struct target_desc * | ||
| 242 | +microblaze_linux_nat_target::read_description () | ||
| 243 | { | ||
| 244 | - CORE_ADDR microblaze_hwcap = 0; | ||
| 245 | + CORE_ADDR microblaze_hwcap = linux_get_hwcap (this); | ||
| 246 | |||
| 247 | - if (target_auxv_search (ops, AT_HWCAP, µblaze_hwcap) != 1) | ||
| 248 | + if (microblaze_hwcap != 1) | ||
| 249 | return NULL; | ||
| 250 | |||
| 251 | return NULL; | ||
| 252 | @@ -415,17 +399,7 @@ void _initialize_microblaze_linux_nat (void); | ||
| 253 | void | ||
| 254 | _initialize_microblaze_linux_nat (void) | ||
| 255 | { | ||
| 256 | - struct target_ops *t; | ||
| 257 | - | ||
| 258 | - /* Fill in the generic GNU/Linux methods. */ | ||
| 259 | - t = linux_target (); | ||
| 260 | - | ||
| 261 | - /* Add our register access methods. */ | ||
| 262 | - t->to_fetch_registers = microblaze_linux_fetch_inferior_registers; | ||
| 263 | - t->to_store_registers = microblaze_linux_store_inferior_registers; | ||
| 264 | - | ||
| 265 | - t->to_read_description = microblaze_linux_read_description; | ||
| 266 | - | ||
| 267 | /* Register the target. */ | ||
| 268 | - linux_nat_add_target (t); | ||
| 269 | + linux_target = &the_microblaze_linux_nat_target; | ||
| 270 | + add_inf_child_target (&the_microblaze_linux_nat_target); | ||
| 271 | } | ||
| 272 | diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h | ||
| 273 | index c0fc900733..c777d93a95 100644 | ||
| 274 | --- a/gdb/microblaze-tdep.h | ||
| 275 | +++ b/gdb/microblaze-tdep.h | ||
| 276 | @@ -106,6 +106,9 @@ enum microblaze_regnum | ||
| 277 | MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS | ||
| 278 | }; | ||
| 279 | |||
| 280 | +/* Big enough to hold the size of the largest register in bytes. */ | ||
| 281 | +#define MICROBLAZE_MAX_REGISTER_SIZE 64 | ||
| 282 | + | ||
| 283 | struct microblaze_frame_cache | ||
| 284 | { | ||
| 285 | /* Base address. */ | ||
| 286 | -- | ||
| 287 | 2.17.1 | ||
| 288 | |||
