summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch')
-rw-r--r--meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch305
1 files changed, 0 insertions, 305 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch
deleted file mode 100644
index 18a1da90..00000000
--- a/meta-microblaze/recipes-devtools/binutils/binutils/0034-Initial-port-of-core-reading-support-Added-support-f.patch
+++ /dev/null
@@ -1,305 +0,0 @@
1From 98f1df0f21b6c44eb8b5bac070a748c4a16d3f66 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Jan 2017 14:55:56 +0530
4Subject: [PATCH 34/38] Initial port of core reading support Added support for
5 reading notes in linux core dumps Support for reading of PRSTATUS and PSINFO
6 information for rebuilding ".reg" sections of core dumps at run time.
7
8Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
9Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
10
11Conflicts:
12 gdb/microblaze-linux-tdep.c
13 gdb/microblaze-tdep.c
14Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
15---
16 bfd/elf32-microblaze.c | 84 +++++++++++++++++++++++++++++++++++++
17 gdb/configure.tgt | 2 +-
18 gdb/microblaze-linux-tdep.c | 17 +++++++-
19 gdb/microblaze-tdep.c | 48 +++++++++++++++++++++
20 gdb/microblaze-tdep.h | 27 ++++++++++++
21 5 files changed, 176 insertions(+), 2 deletions(-)
22
23diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
24index f41b503cbb5..9c6d0411420 100644
25--- a/bfd/elf32-microblaze.c
26+++ b/bfd/elf32-microblaze.c
27@@ -806,6 +806,87 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
28 return _bfd_elf_is_local_label_name (abfd, name);
29 }
30
31+/* Support for core dump NOTE sections. */
32+static bool
33+microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
34+{
35+ int offset;
36+ unsigned int size;
37+
38+ switch (note->descsz)
39+ {
40+ default:
41+ return false;
42+
43+ case 228: /* Linux/MicroBlaze */
44+ /* pr_cursig */
45+ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
46+
47+ /* pr_pid */
48+ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
49+
50+ /* pr_reg */
51+ offset = 72;
52+ size = 50 * 4;
53+
54+ break;
55+ }
56+
57+ /* Make a ".reg/999" section. */
58+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
59+ size, note->descpos + offset);
60+}
61+
62+static bool
63+microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
64+{
65+ switch (note->descsz)
66+ {
67+ default:
68+ return false;
69+
70+ case 128: /* Linux/MicroBlaze elf_prpsinfo */
71+ elf_tdata (abfd)->core->program
72+ = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
73+ elf_tdata (abfd)->core->command
74+ = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
75+ }
76+
77+ /* Note that for some reason, a spurious space is tacked
78+ onto the end of the args in some (at least one anyway)
79+ implementations, so strip it off if it exists. */
80+
81+ {
82+ char *command = elf_tdata (abfd)->core->command;
83+ int n = strlen (command);
84+
85+ if (0 < n && command[n - 1] == ' ')
86+ command[n - 1] = '\0';
87+ }
88+
89+ return true;
90+}
91+
92+/* The microblaze linker (like many others) needs to keep track of
93+ the number of relocs that it decides to copy as dynamic relocs in
94+ check_relocs for each symbol. This is so that it can later discard
95+ them if they are found to be unnecessary. We store the information
96+ in a field extending the regular ELF linker hash table. */
97+
98+struct elf32_mb_dyn_relocs
99+{
100+ struct elf32_mb_dyn_relocs *next;
101+
102+ /* The input section of the reloc. */
103+ asection *sec;
104+
105+ /* Total number of relocs copied for the input section. */
106+ bfd_size_type count;
107+
108+ /* Number of pc-relative relocs copied for the input section. */
109+ bfd_size_type pc_count;
110+};
111+
112 /* ELF linker hash entry. */
113
114 struct elf32_mb_link_hash_entry
115@@ -3604,4 +3685,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
116 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
117 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
118
119+#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
120+#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
121+
122 #include "elf32-target.h"
123diff --git a/gdb/configure.tgt b/gdb/configure.tgt
124index 0705ccf32b8..7ea186481f3 100644
125--- a/gdb/configure.tgt
126+++ b/gdb/configure.tgt
127@@ -400,7 +400,7 @@ mep-*-*)
128
129 microblaze*-linux-*|microblaze*-*-linux*)
130 # Target: Xilinx MicroBlaze running Linux
131- gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o \
132+ gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o glibc-tdep.o \
133 symfile-mem.o linux-tdep.o"
134 ;;
135 microblaze*-*-*)
136diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
137index 5748556a556..1e1f03fc154 100644
138--- a/gdb/microblaze-linux-tdep.c
139+++ b/gdb/microblaze-linux-tdep.c
140@@ -36,6 +36,7 @@
141 #include "frame-unwind.h"
142 #include "tramp-frame.h"
143 #include "linux-tdep.h"
144+#include "glibc-tdep.h"
145
146 static int microblaze_debug_flag = 0;
147
148@@ -135,13 +136,16 @@ static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
149 microblaze_linux_sighandler_cache_init
150 };
151
152-
153 static void
154 microblaze_linux_init_abi (struct gdbarch_info info,
155 struct gdbarch *gdbarch)
156 {
157+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
158+
159+ tdep->sizeof_gregset = 200;
160 linux_init_abi (info, gdbarch, 0);
161
162+
163 set_gdbarch_memory_remove_breakpoint (gdbarch,
164 microblaze_linux_memory_remove_breakpoint);
165
166@@ -153,6 +157,17 @@ microblaze_linux_init_abi (struct gdbarch_info info,
167 tramp_frame_prepend_unwinder (gdbarch,
168 &microblaze_linux_sighandler_tramp_frame);
169
170+ /* BFD target for core files. */
171+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
172+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
173+ else
174+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
175+
176+
177+ /* Shared library handling. */
178+ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
179+ set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
180+
181 /* Enable TLS support. */
182 set_gdbarch_fetch_tls_load_module_address (gdbarch,
183 svr4_fetch_objfile_link_map);
184diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
185index 3e8e8fe35b9..31005332104 100644
186--- a/gdb/microblaze-tdep.c
187+++ b/gdb/microblaze-tdep.c
188@@ -666,6 +666,43 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
189 tdesc_microblaze_with_stack_protect);
190 }
191
192+void
193+microblaze_supply_gregset (const struct regset *regset,
194+ struct regcache *regcache,
195+ int regnum, const void *gregs)
196+{
197+ const unsigned int *regs = (const unsigned int *)gregs;
198+ if (regnum >= 0)
199+ regcache->raw_supply (regnum, regs + regnum);
200+
201+ if (regnum == -1) {
202+ int i;
203+
204+ for (i = 0; i < 50; i++) {
205+ regcache->raw_supply (i, regs + i);
206+ }
207+ }
208+}
209+
210+
211+/* Return the appropriate register set for the core section identified
212+ by SECT_NAME and SECT_SIZE. */
213+
214+static void
215+microblaze_iterate_over_regset_sections (struct gdbarch *gdbarch,
216+ iterate_over_regset_sections_cb *cb,
217+ void *cb_data,
218+ const struct regcache *regcache)
219+{
220+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
221+
222+ cb(".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, tdep->gregset, NULL, cb_data);
223+
224+ cb(".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset, tdep->fpregset, NULL, cb_data);
225+}
226+
227+
228+
229 static struct gdbarch *
230 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
231 {
232@@ -718,6 +755,10 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
233 microblaze_gdbarch_tdep *tdep = new microblaze_gdbarch_tdep;
234 gdbarch = gdbarch_alloc (&info, tdep);
235
236+ tdep->gregset = NULL;
237+ tdep->sizeof_gregset = 0;
238+ tdep->fpregset = NULL;
239+ tdep->sizeof_fpregset = 0;
240 set_gdbarch_long_double_bit (gdbarch, 128);
241
242 set_gdbarch_num_regs (gdbarch, MICROBLAZE_NUM_REGS);
243@@ -766,6 +807,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
244 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
245 if (tdesc_data != NULL)
246 tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
247+ //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
248+
249+ /* If we have register sets, enable the generic core file support. */
250+ if (tdep->gregset) {
251+ set_gdbarch_iterate_over_regset_sections (gdbarch,
252+ microblaze_iterate_over_regset_sections);
253+ }
254
255 return gdbarch;
256 }
257diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
258index 53fcb2297e6..6f5bd5903a7 100644
259--- a/gdb/microblaze-tdep.h
260+++ b/gdb/microblaze-tdep.h
261@@ -23,8 +23,22 @@
262 #include "gdbarch.h"
263
264 /* Microblaze architecture-specific information. */
265+struct microblaze_gregset
266+{
267+ unsigned int gregs[32];
268+ unsigned int fpregs[32];
269+ unsigned int pregs[16];
270+};
271+
272 struct microblaze_gdbarch_tdep : gdbarch_tdep
273 {
274+ int dummy; // declare something.
275+
276+ /* Register sets. */
277+ struct regset *gregset;
278+ size_t sizeof_gregset;
279+ struct regset *fpregset;
280+ size_t sizeof_fpregset;
281 };
282
283 /* Register numbers. */
284@@ -121,5 +135,18 @@ struct microblaze_frame_cache
285 #define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
286 #define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
287
288+extern void microblaze_supply_gregset (const struct regset *regset,
289+ struct regcache *regcache,
290+ int regnum, const void *gregs);
291+extern void microblaze_collect_gregset (const struct regset *regset,
292+ const struct regcache *regcache,
293+ int regnum, void *gregs);
294+extern void microblaze_supply_fpregset (struct regcache *regcache,
295+ int regnum, const void *fpregs);
296+extern void microblaze_collect_fpregset (const struct regcache *regcache,
297+ int regnum, void *fpregs);
298+
299+extern const struct regset * microblaze_regset_from_core_section (struct gdbarch *gdbarch,
300+ const char *sect_name, size_t sect_size);
301
302 #endif /* microblaze-tdep.h */
303--
3042.25.1
305