From 3d14409964a92753c3176b6af84ba4c80011237f Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nmekala@xilix.com>
Date: Fri, 17 Feb 2017 14:09:40 +0530
Subject: [PATCH 37/38] Fixing the issues related to GDB-7.12

added all the required function which are new in 7.12 and removed
few deprecated functions from 7.6

Conflicts:
	gdb/config/microblaze/linux.mh
---
 gdb/config/microblaze/linux.mh       | 11 ++++
 gdb/gdbserver/configure.srv          |  3 +-
 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++----
 gdb/microblaze-tdep.h                |  1 +
 4 files changed, 97 insertions(+), 15 deletions(-)
 create mode 100644 gdb/config/microblaze/linux.mh

diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
new file mode 100644
index 00000000000..74a53b854a4
--- /dev/null
+++ b/gdb/config/microblaze/linux.mh
@@ -0,0 +1,11 @@
+# Host: Microblaze, running Linux
+
+#linux-nat.o linux-waitpid.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
+NAT_FILE= config/nm-linux.h
+NATDEPFILES= inf-ptrace.o fork-child.o \
+	microblaze-linux-nat.o proc-service.o linux-thread-db.o \
+	linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
+	linux-waitpid.o linux-personality.o linux-namespaces.o
+NAT_CDEPS = $(srcdir)/proc-service.list
+
+LOADLIBES = -ldl $(RDYNAMIC)
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index e0d2b2fe04a..26db2dd2461 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -185,8 +185,7 @@ case "${target}" in
 			srv_linux_thread_db=yes
 			;;
   microblaze*-*-linux*)	srv_regobj="microblaze-linux.o"
-			srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
-			srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
+			srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
 			srv_xmlfiles="microblaze-linux.xml"
 			srv_linux_regsets=yes
 			srv_linux_usrregs=yes
diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
index cba5d6fc585..a2733f3c21c 100644
--- a/gdb/gdbserver/linux-microblaze-low.c
+++ b/gdb/gdbserver/linux-microblaze-low.c
@@ -39,10 +39,11 @@ static int microblaze_regmap[] =
   PT_FSR
   };
 
-#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
+#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
 
 /* Defined in auto-generated file microblaze-linux.c.  */
 void init_registers_microblaze (void);
+extern const struct target_desc *tdesc_microblaze;
 
 static int
 microblaze_cannot_store_register (int regno)
@@ -81,6 +82,15 @@ microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
 static const unsigned long microblaze_breakpoint = 0xba0c0018;
 #define microblaze_breakpoint_len 4
 
+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+
+static const gdb_byte *
+microblaze_sw_breakpoint_from_kind (int kind, int *size)
+{
+  *size = microblaze_breakpoint_len;
+  return (const gdb_byte *) &microblaze_breakpoint;
+}
+
 static int
 microblaze_breakpoint_at (CORE_ADDR where)
 {
@@ -107,7 +117,7 @@ microblaze_reinsert_addr (struct regcache *regcache)
 static void
 microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
 {
-  int size = register_size (regno);
+  int size = register_size (regcache->tdesc, regno);
 
   memset (buf, 0, sizeof (long));
 
@@ -121,7 +131,7 @@ static void
 microblaze_supply_ptrace_register (struct regcache *regcache,
 			    int regno, const char *buf)
 {
-  int size = register_size (regno);
+  int size = register_size (regcache->tdesc, regno);
 
   if (regno == 0) {
     unsigned long regbuf_0 = 0;
@@ -157,33 +167,94 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
 
 #endif /* HAVE_PTRACE_GETREGS */
 
-struct regset_info target_regsets[] = {
+static struct regset_info microblaze_regsets[] = {
 #ifdef HAVE_PTRACE_GETREGS
   { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
-  { 0, 0, 0, -1, -1, NULL, NULL },
+  { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
 #endif /* HAVE_PTRACE_GETREGS */
-  { 0, 0, 0, -1, -1, NULL, NULL }
+  { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
+  NULL_REGSET
 };
 
+static struct usrregs_info microblaze_usrregs_info =
+  {
+    microblaze_num_regs,
+    microblaze_regmap,
+  };
+
+static struct regsets_info microblaze_regsets_info =
+  {
+    microblaze_regsets, /* regsets */
+    0, /* num_regsets */
+    NULL, /* disabled_regsets */
+  };
+
+static struct regs_info regs_info =
+  {
+    NULL, /* regset_bitmap */
+    &microblaze_usrregs_info,
+    &microblaze_regsets_info
+  };
+
+static const struct regs_info *
+microblaze_regs_info (void)
+{
+  return &regs_info;
+}
+
+/* Support for hardware single step.  */
+
+static int
+microblaze_supports_hardware_single_step (void)
+{
+  return 1;
+}
+
+
+static void
+microblaze_arch_setup (void)
+{
+  current_process ()->tdesc = tdesc_microblaze;
+}
+
 struct linux_target_ops the_low_target = {
-  init_registers_microblaze,
-  microblaze_num_regs,
-  microblaze_regmap,
-  NULL,
+  microblaze_arch_setup,
+  microblaze_regs_info,
   microblaze_cannot_fetch_register,
   microblaze_cannot_store_register,
   NULL, /* fetch_register */
   microblaze_get_pc,
   microblaze_set_pc,
-  (const unsigned char *) &microblaze_breakpoint,
-  microblaze_breakpoint_len,
-  microblaze_reinsert_addr,
+  NULL,
+  microblaze_sw_breakpoint_from_kind,
+  NULL,
   0,
   microblaze_breakpoint_at,
   NULL,
   NULL,
   NULL,
   NULL,
+  NULL,
   microblaze_collect_ptrace_register,
   microblaze_supply_ptrace_register,
+  NULL, /* siginfo_fixup */
+  NULL, /* new_process */
+  NULL, /* new_thread */
+  NULL, /* new_fork */
+  NULL, /* prepare_to_resume */
+  NULL, /* process_qsupported */
+  NULL, /* supports_tracepoints */
+  NULL, /* get_thread_area */
+  NULL, /* install_fast_tracepoint_jump_pad */
+  NULL, /* emit_ops */
+  NULL, /* get_min_fast_tracepoint_insn_len */
+  NULL, /* supports_range_stepping */
+  NULL, /* breakpoint_kind_from_current_state */
+  microblaze_supports_hardware_single_step,
 };
+
+void
+initialize_low_arch (void)
+{
+  init_registers_microblaze ();
+}
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index e91991b8dba..872a3931f20 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -24,6 +24,7 @@
 /* Microblaze architecture-specific information.  */
 struct microblaze_gregset
 {
+   microblaze_gregset() {}
    unsigned int gregs[32];
    unsigned int fpregs[32];
    unsigned int pregs[16];
-- 
2.17.1

