Skip to contentSkip to conversation

Openrisc gdb patches after yao's comments

PATCH New Stafford Horne 1 participant 7 messages Dec 16, 2016

lore
Share & tools
lore
#0 lore raw

cover Openrisc gdb patches after yao's comments

Hi All,

I wanted to circulate these patches on the openrisc list first. These are in response to Yao's gdb patch review.

- The first patch is baiscally format and comment updates as per gnu style.
- The second removes the unimplemented pseudo register functions
- Next is the BIG one it removes the handling of target-description parsing and intercepting. But this is as per the recommended way. May what is questionable is how I hard code the reggroups.
- Next removes the special spr commands. I think or1ksim would need to be updated to work with the target-descriptor xml.
- Last is just a cleanup.

The plan would be to squash all of these into the previous patch set I sent.

Test results look ok. Also I tested against openocd and I can reed sprs with commands like info reg upr as expected.

                === gdb Summary ===
# of expected passes            19241
# of unexpected failures        406
# of expected failures          29
# of known failures             57
# of unresolved testcases       2
# of untested testcases         190
# of unsupported tests          264
/home/shorne/work/openrisc/build-gdb/gdb/gdb version  7.12.50.20161122-git 

-Stafford

Stafford Horne (5):
gdb: or1k: Updates suggested by yao in gdb review
gdb: or1k: Remove pseudo registers
or1k: gdb: Simplify handling of tdesc
or1k: gdb: Remove spr commands
gdb: or1k: Just have one number of registers

 gdb/configure.tgt         |   14 -
 gdb/or1k-tdep.c           | 2931 +++++++++------------------------------------
 gdb/or1k-tdep.h           |  389 +-----
 gdb/target-descriptions.c |   34 -
 gdb/target-descriptions.h |   12 -
 5 files changed, 549 insertions(+), 2831 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 gdb: or1k: Updates suggested by yao in gdb review

Fixes
configure.tgt
* remove linux builds

or1k-tdep.[ch]
* Fix copyrights, jullien embecosm, remove embecosm
* indentation to use gnu style (i.e. && and || on left)
* Fix comments to use gnu style
* Move some includes around
* Remove constant variables, replace with constants
* Remove doxygen on a few calls
* Have only 1 space between type and var name
* remove todo about 4 const
* do fix *buf checks (use buf != NULL)
* BP_MANIPULATION
* Use the builtin types for reg register functions
* or1k_iterate_over_regset_sections - remove no linux, no cores yes
* Add some of Yao's todo comments

in .h file
* remove a bunch of unused macros

---
 gdb/configure.tgt |   14 -
 gdb/or1k-tdep.c   | 2441 +++++++++++++++++++----------------------------------
 gdb/or1k-tdep.h   |  237 +-----
 3 files changed, 881 insertions(+), 1811 deletions(-)
gdb/configure.tgt +0 -14
index 3a3df97..6c7fe86 100644
@@ -421,26 +421,12 @@ nios2*-*-*)
 	gdb_target_obs="nios2-tdep.o"
 	;;
 
-or1k-*-linux*)
-	# Target: OpenCores OpenRISC 1000 32-bit implementation for Linux
-	gdb_target_obs="or1k-tdep.o"
-	gdb_sim=../sim/or1k/libsim.a
-	build_gdbserver=yes
-	;;
-
 or1k-*-*)
 	# Target: OpenCores OpenRISC 1000 32-bit implementation bare metal
 	gdb_target_obs="or1k-tdep.o"
 	gdb_sim=../sim/or1k/libsim.a
 	;;
 
-or1knd-*-linux*)
-	# Target: OpenCores OpenRISC 1000 32-bit implementation for Linux, without delay slot
-	gdb_target_obs="or1k-tdep.o"
-	gdb_sim=../sim/or1k/libsim.a
-	build_gdbserver=yes
-	;;
-
 or1knd-*-*)
 	# Target: OpenCores OpenRISC 1000 32-bit implementation bare metal, without delay slot
 	gdb_target_obs="or1k-tdep.o"
gdb/or1k-tdep.c +874 -1567

2,974 lines not on this page · raw message

gdb/or1k-tdep.h +7 -230

237 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/5 gdb: or1k: Remove pseudo registers

In reply to Stafford Horne

We do not have definitions for peudo registers yet. This could be added later. We do have vectors and floats that could be added here, but discussions need to be made on how they should be named and represented.

---
 gdb/or1k-tdep.c | 29 -----------------------------
 1 file changed, 29 deletions(-)
gdb/or1k-tdep.c +0 -29
index 2c5d679..be5f483 100644
@@ -395,33 +395,6 @@ or1k_single_step_through_delay (struct gdbarch *gdbarch,
 
 }
 
-/* Read a pseudo register.  */
-
-/*
-   TODO The floating point and vector registers ought to be done as
-         pseudo-registers.
-*/
-
-static enum register_status
-or1k_pseudo_register_read (struct gdbarch *gdbarch,
-			   struct regcache *regcache,
-			   int regnum, gdb_byte * buf)
-{
-  return REG_UNKNOWN;
-}
-
-
-/* Write a pseudo register.  */
-
-static void
-or1k_pseudo_register_write (struct gdbarch *gdbarch,
-			    struct regcache *regcache,
-			    int regnum, const gdb_byte * buf)
-{
-  return;
-
-}
-
 /* Name for or1k general registers.  */
 
 static const char *const or1k_reg_names[OR1K_NUM_REGS_CACHED] = {
@@ -1484,8 +1457,6 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_print_insn (gdbarch, print_insn_or1k);
 
   /* Register architecture */
-  set_gdbarch_pseudo_register_read (gdbarch, or1k_pseudo_register_read);
-  set_gdbarch_pseudo_register_write (gdbarch, or1k_pseudo_register_write);
   set_gdbarch_num_regs (gdbarch, OR1K_NUM_REGS);
   set_gdbarch_num_pseudo_regs (gdbarch, OR1K_NUM_PSEUDO_REGS);
   set_gdbarch_sp_regnum (gdbarch, OR1K_SP_REGNUM);
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/5 or1k: gdb: Simplify handling of tdesc

In reply to Stafford Horne

The previous code tried to intercept all access to registers provided by report target descriptor features. However, the target descriptor can support that access if setup properly.

There was also some code which dynamically created groups which I change to simply hard code the groups we support. I hope that is reasonable.

I did some basic testing and it seems to all work the same as before. Need to confirm with the real openocd target.

or1k-tdep.c
* remove parsing logic and info_reg overrides
as its handled by target descriptions actually

target-descriptions.[ch]
* remove unused functions

---
 gdb/or1k-tdep.c           | 262 +++++++---------------------------------------
 gdb/target-descriptions.c |  34 ------
 gdb/target-descriptions.h |  12 ---
 3 files changed, 39 insertions(+), 269 deletions(-)
gdb/or1k-tdep.c +39 -223
index be5f483..2ea3c24 100644
@@ -413,19 +413,12 @@ static const char *const or1k_reg_names[OR1K_NUM_REGS_CACHED] = {
 static const char *
 or1k_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  /* If we have a target description, use it */
-  if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
-    return tdesc_register_name (gdbarch, regnum);
-  else
+  if (0 <= regnum && regnum < OR1K_NUM_REGS_CACHED)
     {
-      if (0 <= regnum && regnum < OR1K_NUM_REGS_CACHED)
-	{
-	  return or1k_reg_names[regnum];
-	}
-      else
-	return NULL;
+      return or1k_reg_names[regnum];
     }
-
+  else
+      return NULL;
 }
 
 /* Implement the register_type gdbarch method.  */
@@ -456,60 +449,6 @@ or1k_register_type (struct gdbarch *gdbarch, int regnum)
 
 }
 
-/* Implement the registers_info gdbarch method.  */
-
-static void
-or1k_registers_info (struct gdbarch *gdbarch,
-		     struct ui_file *file,
-		     struct frame_info *frame, int regnum, int all)
-{
-  struct regcache *regcache = get_current_regcache ();
-
-/* TODO
-or1k_registers_info should print the registers contents from FRAME
-rather than current regcache.
-*/
-
-  if (-1 == regnum)
-    {
-      /* Do all (valid) registers */
-      unsigned int lim = all ? OR1K_NUM_REGS_CACHED : OR1K_MAX_GPR_REGS;
-
-      for (regnum = 0; regnum < lim; regnum++)
-	{
-	  if ('\0' != *(or1k_register_name (gdbarch, regnum)))
-	    {
-	      or1k_registers_info (gdbarch, file, frame, regnum, all);
-	    }
-	}
-    }
-  else
-    {
-      /* Do one specified register - if it is part of this architecture */
-      if ((regnum < OR1K_NUM_REGS_CACHED)
-	  && ('\0' == *(or1k_register_name (gdbarch, regnum))))
-	{
-	  error ("Not a valid register for the current processor type");
-	}
-      else
-	{
-	  /* If the register is not in the g/G packet, fetch it from the
-	   * target with a p/P packet.
-	   */
-	  if (regnum >= OR1K_NUM_REGS_CACHED)
-	    target_fetch_registers (regcache, regnum);
-
-/* TODO
-Why is a register not in the g/G packet?  Again, we shouldn't fetch
-registers now.
-*/
-
-	  default_print_registers_info (gdbarch, file, frame, regnum, all);
-	}
-    }
-}
-
-
 /* Implement the register_reggroup_p gdbarch method.  */
 
 static int
@@ -544,16 +483,8 @@ or1k_register_reggroup_p (struct gdbarch *gdbarch,
       return 0;	/* No vector regs.  */
     }
 
-  if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
-    {
-      if ((tdesc_register_in_reggroup_p (gdbarch, regnum, group)) != 1)
-	return 0;
-      else
-	return 1;
-    }
-  else
-    /* For any that are not handled above.  */
-    return default_register_reggroup_p (gdbarch, regnum, group);
+  /* For any that are not handled above.  */
+  return default_register_reggroup_p (gdbarch, regnum, group);
 
 }
 
@@ -1308,98 +1239,6 @@ static const struct frame_unwind or1k_frame_unwind = {
   .prev_arch = NULL
 };
 
-
-/* Create a register group based on a group name.  */
-
-static int
-create_register_group (struct gdbarch *gdbarch, const char *group_name)
-{
-  struct reggroup *group;
-  static int first = 1;
-  int group_exist = 0;
-
-  if (group_name == NULL)
-    return 0;
-
-  if (!first)
-    {
-      for (group = reggroup_next (gdbarch, NULL);
-	   group != NULL; group = reggroup_next (gdbarch, group))
-	{
-	  if (strcmp (group_name, reggroup_name (group)) == 0)
-	    group_exist = 1;
-	}
-
-      if (!group_exist)
-	{
-	  /* If the group doesn't exist, create it.  */
-	  reggroup_add (gdbarch, reggroup_new (group_name, USER_REGGROUP));
-	  return 1;
-	}
-    }
-  else
-    {
-      /* The function reggroup_next cannot be called during architecture init.
-         However, a first call to reggroup_add execute reggroups_init and then
-         reggroup_next can be use. We assume the first group name we create
-         does not exist.  */
-      reggroup_add (gdbarch, reggroup_new (group_name, USER_REGGROUP));
-      first = 0;
-    }
-
-  return 0;
-}
-
-/* Register all reg found in a feature section and create a group for each
-   new register group name found in the tdesc file.  */
-
-static int
-get_feature_registers (const struct tdesc_feature *feature,
-		       struct tdesc_arch_data *tdesc_data, int *reg_index,
-		       struct gdbarch *gdbarch)
-{
-  int valid_p;
-  int i;
-  const char *name;
-  const char *group_name;
-
-  if (feature)
-    {
-      valid_p = 1;
-      i = 0;
-      while (1)
-	{
-	  name = tdesc_find_register_name (feature, i);
-	  if (name)
-	    {
-	      valid_p &=
-		tdesc_numbered_register (feature, tdesc_data, (*reg_index)++,
-					 name);
-	      if (valid_p)
-		{
-		  group_name = tdesc_find_register_group_name (feature, i);
-		  if (group_name)
-		    create_register_group (gdbarch, group_name);
-		}
-	      i++;
-	    }
-	  else
-	    break;
-	}
-
-      if (!valid_p)
-	{
-	  tdesc_data_cleanup (tdesc_data);
-	  return -1;
-	}
-
-      return i;
-
-    }
-
-  return 0;
-}
-
 /* Architecture initialization for OpenRISC 1000.  */
 
 static struct gdbarch *
@@ -1467,7 +1306,6 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Functions to supply register information */
   set_gdbarch_register_name (gdbarch, or1k_register_name);
   set_gdbarch_register_type (gdbarch, or1k_register_type);
-  set_gdbarch_print_registers_info (gdbarch, or1k_registers_info);
   set_gdbarch_register_reggroup_p (gdbarch, or1k_register_reggroup_p);
 
   /* Functions to analyse frames */
@@ -1514,73 +1352,51 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Check any target description for validity.  */
   if (tdesc_has_registers (info.target_desc))
-    {
-
+    { 
       const struct tdesc_feature *feature;
-      int total_regs = 0;
-      int nb_features;
-      char feature_name[30];
+      int valid_p;
 
-      tdesc_data = tdesc_data_alloc ();
+      feature = tdesc_find_feature (info.target_desc, "org.gnu.gdb.or1k.group0");
+      if (feature == NULL)
+        return NULL;
 
-      /* OpenRisc architecture manual define a maximum of 32 registers
-	 groups.  */
-      for (group = 0; group < 32; group++)
-	{
+      tdesc_data = tdesc_data_alloc ();
 
-	  sprintf (feature_name, "org.gnu.gdb.or1k.group%d", group);
-	  feature = tdesc_find_feature (info.target_desc, feature_name);
+      valid_p = 1;
 
-	  retval =
-	    get_feature_registers (feature, tdesc_data, &reg_index, gdbarch);
+      for (i = 0; i < OR1K_NUM_REGS_CACHED; i++)
+        valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
+                                            or1k_reg_names[i]);
 
-	  if (retval < 0)
-	    {
-	      tdesc_data_cleanup (tdesc_data);
-	      return NULL;
-	    }
-	  else
-	    {
-	      total_regs += retval;
-	      if (retval && gdbarch_debug)
-		fprintf_unfiltered (gdb_stdout,
-				    "Found %4d registers in feature %s\n",
-				    retval, feature_name);
-	    }
-	}
-/*
-TODO YQ
-I don't fully understand what you want to achieve here, can you
-elaborate?  What do these features look alike?
-*/
-      if (gdbarch_debug)
-	fprintf_unfiltered (gdb_stdout,
-			    "Found %4d registers in the tdesc file\n",
-			    total_regs);
-
-      if (!total_regs)
-	{
-	  tdesc_data_cleanup (tdesc_data);
-	  return NULL;
-	}
+      if (!valid_p)
+        { 
+          tdesc_data_cleanup (tdesc_data);
+          return NULL;
+        }
     }
 
   if (tdesc_data)
     {
       tdesc_use_registers (gdbarch, info.target_desc, tdesc_data);
 
-      /* Override the normal target description methods to handle our
-         dual real and pseudo registers.  */
-/* TODO SMH
-These look wrong they are already set above
-*/
-      set_gdbarch_register_name (gdbarch, or1k_register_name);
-      set_gdbarch_register_reggroup_p (gdbarch, or1k_register_reggroup_p);
-
-      set_gdbarch_register_name (gdbarch, or1k_register_name);
-      set_gdbarch_sp_regnum (gdbarch, OR1K_SP_REGNUM);
-      set_gdbarch_pc_regnum (gdbarch, OR1K_NPC_REGNUM);
-      set_gdbarch_num_pseudo_regs (gdbarch, OR1K_NUM_PSEUDO_REGS);
+      /* Target descriptions may extend into the following groups.  */
+      reggroup_add (gdbarch, general_reggroup);
+      reggroup_add (gdbarch, system_reggroup);
+      reggroup_add (gdbarch, float_reggroup);
+      reggroup_add (gdbarch, vector_reggroup);
+      reggroup_add (gdbarch, reggroup_new ("immu", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("dmmu", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("icache", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("dcache", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("pic", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("timer", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("power", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("perf", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("mac", USER_REGGROUP));
+      reggroup_add (gdbarch, reggroup_new ("debug", USER_REGGROUP));
+      reggroup_add (gdbarch, all_reggroup);
+      reggroup_add (gdbarch, save_reggroup);
+      reggroup_add (gdbarch, restore_reggroup);
     }
 
   return gdbarch;
gdb/target-descriptions.c +0 -34
index a542ef9..dfc2e93 100644
@@ -900,40 +900,6 @@ tdesc_numbered_register (const struct tdesc_feature *feature,
   return 1;
 }
 
-/* Search FEATURE for a register REGNO and return its name. */
-char *
-tdesc_find_register_name (const struct tdesc_feature *feature,
-			   int regno)
-{
-  int ixr;
-  struct tdesc_reg *reg;
-
-  for (ixr = 0;
-       VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
-       ixr++)
-    if (ixr == regno)
-      return reg->name;
-
-  return NULL;
-}
-
-/* Search FEATURE for a register REGNO and return its group name. */
-char *
-tdesc_find_register_group_name (const struct tdesc_feature *feature,
-			   int regno)
-{
-  int ixr;
-  struct tdesc_reg *reg;
-
-  for (ixr = 0;
-       VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
-       ixr++)
-    if (ixr == regno)
-      return reg->group;
-
-  return NULL;
-}
-
 /* Search FEATURE for a register named NAME, but do not assign a fixed
    register number to it.  */
 
gdb/target-descriptions.h +0 -12
index 0d8f03f..ef97d1d 100644
@@ -111,18 +111,6 @@ struct tdesc_arch_data *tdesc_data_alloc (void);
 
 void tdesc_data_cleanup (void *data_untyped);
 
-/* Search FEATURE for a register REGNO and return its name. */
-
-char *tdesc_find_register_name (const struct tdesc_feature *feature,
-				int regno);
-
-
-/* Search FEATURE for a register REGNO and return its group name. */
-
-char *tdesc_find_register_group_name (const struct tdesc_feature *feature,
-				      int regno);
-
-
 /* Search FEATURE for a register named NAME.  Record REGNO and the
    register in DATA; when tdesc_use_registers is called, REGNO will be
    assigned to the register.  1 is returned if the register was found,
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/5 or1k: gdb: Remove spr commands

In reply to Stafford Horne

The recommended was to read/write registers is through the g packet.

Lets try that way. As suggested by Yao.

---
 gdb/or1k-tdep.c | 943 --------------------------------------------------------
 gdb/or1k-tdep.h | 148 ---------
 2 files changed, 1091 deletions(-)
gdb/or1k-tdep.c +0 -943
index 2ea3c24..bd982b6 100644
@@ -1423,943 +1423,6 @@ or1k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 }
 
 
-
-/* Functions to add extra commands to GDB.  */
-
-/* Get a special purpose register group name.  */
-
-static const char *
-or1k_spr_group_name (int group)
-{
-  static const char *or1k_group_names[OR1K_NUM_SPGS] = {
-    "SYS",
-    "DMMU",
-    "IMMU",
-    "DCACHE",
-    "ICACHE",
-    "MAC",
-    "DEBUG",
-    "PERF",
-    "POWER",
-    "PIC",
-    "TIMER",
-    "FPU"
-  };
-
-  if ((0 <= group) && (group < OR1K_NUM_SPGS))
-    {
-      return or1k_group_names[group];
-    }
-  else
-    {
-      return "";
-    }
-}
-
-
-/* Get a special purpose register name.  */
-
-static char *
-or1k_spr_register_name (int group, int index, char *name)
-{
-  char di;
-
-  switch (group)
-    {
-
-    case OR1K_SPG_SYS:
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_SYS_VR:
-	  sprintf (name, "VR");
-	  return name;
-	case OR1K_SPG_SYS_UPR:
-	  sprintf (name, "UPR");
-	  return name;
-	case OR1K_SPG_SYS_CPUCFGR:
-	  sprintf (name, "CPUCFGR");
-	  return name;
-	case OR1K_SPG_SYS_DMMUCFGR:
-	  sprintf (name, "DMMUCFGR");
-	  return name;
-	case OR1K_SPG_SYS_IMMUCFGR:
-	  sprintf (name, "IMMUCFGR");
-	  return name;
-	case OR1K_SPG_SYS_DCCFGR:
-	  sprintf (name, "DCCFGR");
-	  return name;
-	case OR1K_SPG_SYS_ICCFGR:
-	  sprintf (name, "ICCFGR");
-	  return name;
-	case OR1K_SPG_SYS_DCFGR:
-	  sprintf (name, "DCFGR");
-	  return name;
-	case OR1K_SPG_SYS_PCCFGR:
-	  sprintf (name, "PCCFGR");
-	  return name;
-	case OR1K_SPG_SYS_NPC:
-	  sprintf (name, "NPC");
-	  return name;
-	case OR1K_SPG_SYS_SR:
-	  sprintf (name, "SR");
-	  return name;
-	case OR1K_SPG_SYS_PPC:
-	  sprintf (name, "PPC");
-	  return name;
-	case OR1K_SPG_SYS_FPCSR:
-	  sprintf (name, "FPCSR");
-	  return name;
-	}
-
-      /* Exception PC regs */
-      if ((OR1K_SPG_SYS_EPCR <= index) && (index <= OR1K_SPG_SYS_EPCR_END))
-	{
-	  sprintf (name, "EPCR%d", index - OR1K_SPG_SYS_EPCR);
-	  return name;
-	}
-
-      /* Exception EA regs */
-      if ((OR1K_SPG_SYS_EEAR <= index) && (index <= OR1K_SPG_SYS_EEAR_END))
-	{
-	  sprintf (name, "EEAR%d", index - OR1K_SPG_SYS_EEAR);
-	  return name;
-	}
-
-      /* Exception SR regs */
-      if ((OR1K_SPG_SYS_ESR <= index) && (index <= OR1K_SPG_SYS_ESR_END))
-	{
-	  sprintf (name, "ESR%d", index - OR1K_SPG_SYS_ESR);
-	  return name;
-	}
-
-      /* GPRs */
-      if ((OR1K_SPG_SYS_GPR <= index) && (index <= OR1K_SPG_SYS_GPR_END))
-	{
-	  sprintf (name, "GPR%d", index - OR1K_SPG_SYS_GPR);
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_DMMU:
-    case OR1K_SPG_IMMU:
-      /* MMU registers. Use DMMU constants throughout, but these are identical
-         to the corresponding IMMU constants.  */
-      di = OR1K_SPG_DMMU == group ? 'D' : 'I';
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_DMMU_DMMUCR:
-	  sprintf (name, "%cMMUCR", di);
-	  return name;
-	case OR1K_SPG_DMMU_DMMUPR:
-	  sprintf (name, "%cMMUPR", di);
-	  return name;
-	case OR1K_SPG_DMMU_DTLBEIR:
-	  sprintf (name, "%cTLBEIR", di);
-	  return name;
-	}
-
-      /* ATB Match registers */
-      if ((OR1K_SPG_DMMU_DATBMR <= index)
-	  && (index <= OR1K_SPG_DMMU_DATBMR_END))
-	{
-	  sprintf (name, "%cATBMR%d", di, index - OR1K_SPG_DMMU_DATBMR);
-	  return name;
-	}
-
-      /* ATB Translate registers */
-      if ((OR1K_SPG_DMMU_DATBTR <= index)
-	  && (index <= OR1K_SPG_DMMU_DATBTR_END))
-	{
-	  sprintf (name, "%cATBTR%d", di, index - OR1K_SPG_DMMU_DATBTR);
-	  return name;
-	}
-
-      /* TLB Way 1 Match registers */
-      if ((OR1K_SPG_DMMU_DTLBW1MR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW1MR_END))
-	{
-	  sprintf (name, "%cTLBW1MR%d", di, index - OR1K_SPG_DMMU_DTLBW1MR);
-	  return name;
-	}
-
-      /* TLB Way 1 Translate registers */
-      if ((OR1K_SPG_DMMU_DTLBW1TR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW1TR_END))
-	{
-	  sprintf (name, "%cTLBW1TR%d", di, index - OR1K_SPG_DMMU_DTLBW1TR);
-	  return name;
-	}
-
-      /* TLB Way 2 Match registers */
-      if ((OR1K_SPG_DMMU_DTLBW2MR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW2MR_END))
-	{
-	  sprintf (name, "%cTLBW2MR%d", di, index - OR1K_SPG_DMMU_DTLBW2MR);
-	  return name;
-	}
-
-      /* TLB Way 2 Translate registers */
-      if ((OR1K_SPG_DMMU_DTLBW2TR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW2TR_END))
-	{
-	  sprintf (name, "%cTLBW2TR%d", di, index - OR1K_SPG_DMMU_DTLBW2TR);
-	  return name;
-	}
-
-      /* TLB Way 3 Match registers */
-      if ((OR1K_SPG_DMMU_DTLBW3MR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW3MR_END))
-	{
-	  sprintf (name, "%cTLBW3MR%d", di, index - OR1K_SPG_DMMU_DTLBW3MR);
-	  return name;
-	}
-
-      /* TLB Way 3 Translate registers */
-      if ((OR1K_SPG_DMMU_DTLBW3TR <= index)
-	  && (index <= OR1K_SPG_DMMU_DTLBW3TR_END))
-	{
-	  sprintf (name, "%cTLBW3TR%d", di, index - OR1K_SPG_DMMU_DTLBW3TR);
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_DC:
-      /* Data cache registers. These do not have an exact correspondence with
-         their instruction cache counterparts, so must be done separately.  */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_DC_DCCR:
-	  sprintf (name, "DCCR");
-	  return name;
-	case OR1K_SPG_DC_DCBPR:
-	  sprintf (name, "DCBPR");
-	  return name;
-	case OR1K_SPG_DC_DCBFR:
-	  sprintf (name, "DCBFR");
-	  return name;
-	case OR1K_SPG_DC_DCBIR:
-	  sprintf (name, "DCBIR");
-	  return name;
-	case OR1K_SPG_DC_DCBWR:
-	  sprintf (name, "DCBWR");
-	  return name;
-	case OR1K_SPG_DC_DCBLR:
-	  sprintf (name, "DCBLR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_IC:
-      /* Instruction cache registers */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_IC_ICCR:
-	  sprintf (name, "ICCR");
-	  return name;
-	case OR1K_SPG_IC_ICBPR:
-	  sprintf (name, "ICBPR");
-	  return name;
-	case OR1K_SPG_IC_ICBIR:
-	  sprintf (name, "ICBIR");
-	  return name;
-	case OR1K_SPG_IC_ICBLR:
-	  sprintf (name, "ICBLR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_MAC:
-      /* MAC registers */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_MAC_MACLO:
-	  sprintf (name, "MACLO");
-	  return name;
-	case OR1K_SPG_MAC_MACHI:
-	  sprintf (name, "MACHI");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_DEBUG:
-      /* Debug registers */
-
-      /* Debug Value registers */
-      if ((OR1K_SPG_DEBUG_DVR <= index) && (index <= OR1K_SPG_DEBUG_DVR_END))
-	{
-	  sprintf (name, "DVR%d", index - OR1K_SPG_DEBUG_DVR);
-	  return name;
-	}
-
-      /* Debug Control registers */
-      if ((OR1K_SPG_DEBUG_DCR <= index) && (index <= OR1K_SPG_DEBUG_DCR_END))
-	{
-	  sprintf (name, "DCR%d", index - OR1K_SPG_DEBUG_DCR);
-	  return name;
-	}
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_DEBUG_DMR1:
-	  sprintf (name, "DMR1");
-	  return name;
-	case OR1K_SPG_DEBUG_DMR2:
-	  sprintf (name, "DMR2");
-	  return name;
-	case OR1K_SPG_DEBUG_DCWR0:
-	  sprintf (name, "DCWR0");
-	  return name;
-	case OR1K_SPG_DEBUG_DCWR1:
-	  sprintf (name, "DCWR1");
-	  return name;
-	case OR1K_SPG_DEBUG_DSR:
-	  sprintf (name, "DSR");
-	  return name;
-	case OR1K_SPG_DEBUG_DRR:
-	  sprintf (name, "DRR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_PC:
-      /* Performance Counter registers */
-
-      /* Performance Counters Count registers */
-      if ((OR1K_SPG_PC_PCCR <= index) && (index <= OR1K_SPG_PC_PCCR_END))
-	{
-	  sprintf (name, "PCCR%d", index - OR1K_SPG_PC_PCCR);
-	  return name;
-	}
-
-      /* Performance Counters Mode registers */
-      if ((OR1K_SPG_PC_PCMR <= index) && (index <= OR1K_SPG_PC_PCMR_END))
-	{
-	  sprintf (name, "PCMR%d", index - OR1K_SPG_PC_PCMR);
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_PM:
-      /* Power Management registers */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_PM_PMR:
-	  sprintf (name, "PMR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_PIC:
-      /* Programmable Interrupt Controller registers */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_PIC_PICMR:
-	  sprintf (name, "PICMR");
-	  return name;
-	case OR1K_SPG_PIC_PICSR:
-	  sprintf (name, "PICSR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_TT:
-      /* Tick Timer registers */
-
-      /* 1:1 names */
-      switch (index)
-	{
-	case OR1K_SPG_TT_TTMR:
-	  sprintf (name, "TTMR");
-	  return name;
-	case OR1K_SPG_TT_TTCR:
-	  sprintf (name, "TTCR");
-	  return name;
-	}
-
-      break;
-
-    case OR1K_SPG_FPU:
-
-      break;
-    }
-
-  /* Not a recognized register */
-  strcpy (name, "");
-  return name;
-
-}
-
-
-/* Get SPR group number from a name.  */
-
-static int
-or1k_groupnum_from_name (char *group_name)
-{
-  int group;
-
-  for (group = 0; group < OR1K_NUM_SPGS; group++)
-    {
-      if (0 == strcasecmp (group_name, or1k_spr_group_name (group)))
-	{
-	  return group;
-	}
-    }
-
-  return -1;
-
-}
-
-
-/* Get register index in special purpose register group from name.
-   The name may either be SPR<group_num>_<index> or a known unique name. In
-   either case the group number must match the supplied group number.  */
-
-static int
-or1k_regnum_from_name (int group, char *name)
-{
-  /* Last valid register in each group.  */
-  static const int or1k_spr_group_last[OR1K_NUM_SPGS] = {
-    OR1K_SPG_SYS_LAST,
-    OR1K_SPG_DMMU_LAST,
-    OR1K_SPG_IMMU_LAST,
-    OR1K_SPG_DC_LAST,
-    OR1K_SPG_IC_LAST,
-    OR1K_SPG_MAC_LAST,
-    OR1K_SPG_DEBUG_LAST,
-    OR1K_SPG_PC_LAST,
-    OR1K_SPG_PM_LAST,
-    OR1K_SPG_PIC_LAST,
-    OR1K_SPG_TT_LAST,
-    OR1K_SPG_FPU_LAST
-  };
-
-  int i;
-  char spr_name[32];
-
-  if (0 == strcasecmp (name, "SPR"))
-    {
-      char *ptr_c;
-
-      /* skip SPR */
-      name += 3;
-
-      /* get group number */
-      i = (int) strtoul (name, &ptr_c, 10);
-      if (*ptr_c != '_' || i != group)
-	{
-	  return -1;
-	}
-
-      /* get index */
-      ptr_c++;
-      i = (int) strtoul (name, &ptr_c, 10);
-      if (*ptr_c)
-	{
-	  return -1;
-	}
-      else
-	{
-	  return i;
-	}
-    }
-
-  /* Look for a "known" name in this group.  */
-  for (i = 0; i <= or1k_spr_group_last[group]; i++)
-    {
-      char *s = or1k_spr_register_name (group, i, spr_name);
-
-      if (0 == strcasecmp (name, s))
-	{
-	  return i;
-	}
-    }
-
-  /* Failure */
-  return -1;
-
-}
-
-/* Get the next token from a string. Take a string and find the start of the
-   next token and its length. A token is anything containing non-blank
-   characters.  */
-/* TODO make sure we cant use something existing here */
-static int
-or1k_tokenize (char *str, char **tok)
-{
-  char *ptr;
-  int len;
-
-  if (NULL == str)
-    {
-      if (NULL != tok)
-	{
-	  *tok = NULL;
-	}
-      return 0;
-    }
-
-  /* Find the start.  */
-  for (ptr = str; ISBLANK (*ptr); ptr++)
-    {
-      continue;
-    }
-
-  /* Return the start pointer if requested.  */
-  if (NULL != tok)
-    {
-      *tok = ptr;
-    }
-
-  /* Find the end and put in EOS.  */
-  for (len = 0; ('\0' != ptr[len]) && (!ISBLANK (ptr[len])); len++)
-    {
-      continue;
-    }
-
-  return len;
-
-}
-
-/* Parses args for spr commands. Where arg_str syntax is:
-
-   <spr_args>    -> <group_ref> | <reg_name>
-   <group_ref>   -> <group_id> <index>
-   <group_id>    -> <group_num> | <group_name>
-
-   Where the indices/names have to be valid.  */
-
-static char *
-or1k_parse_spr_params (char *arg_str, int *group, int *index, int is_set)
-{
-  struct
-  {
-    char *str;
-    int len;
-    unsigned long int val;
-    int is_num;
-  } arg[3] =
-  {
-    {
-    .str = NULL,.len = 0,.val = 0,.is_num = 0,},
-    {
-    .str = NULL,.len = 0,.val = 0,.is_num = 0,},
-    {
-    .str = NULL,.len = 0,.val = 0,.is_num = 0,}
-  };
-
-  int num_args;
-  char *trailer = arg_str;
-  char *tmp_str;
-  int i;
-  struct ui_out *uiout = current_uiout;
-  char spr_name[32];
-
-  /* Break out the arguments. Note that the strings are NOT null terminated
-     (we don't want to change arg_str), so we must rely on len. The stroul
-     call will still work, since there is always a non-digit char (possibly EOS)
-     after the last digit.  */
-  if (NULL == arg_str)
-    {
-      num_args = 0;
-    }
-  else
-    {
-      for (num_args = 0; num_args < 3; num_args++)
-	{
-	  arg[num_args].len = or1k_tokenize (trailer, &(arg[num_args].str));
-	  trailer = arg[num_args].str + arg[num_args].len;
-
-	  if (0 == arg[num_args].len)
-	    {
-	      break;
-	    }
-	}
-    }
-
-  /* Patch nulls into the arg strings and see about values. Couldn't do this
-     earlier, since we needed the next char clean to check later args. This
-     means advancing trailer, UNLESS it was already@EOS.  */
-
-  if ((NULL != arg_str) && ('\0' != *trailer))
-    {
-      trailer++;
-    }
-
-  for (i = 0; i < num_args; i++)
-    {
-      (arg[i].str)[arg[i].len] = '\0';
-      errno = 0;
-      arg[i].val = strtoul (arg[i].str, &tmp_str, 0);
-      arg[i].is_num = (0 == errno) && ('\0' == *tmp_str);
-    }
-
-  /* Deal with the case where we are setting a register, so the final argument
-     should be disregarded (it is the trailer). Do this anyway if we get a
-     third argument.  */
-  if ((is_set & (num_args > 0)) || (num_args > 2))
-    {
-      trailer = arg[num_args - 1].str;
-      num_args--;
-    }
-
-  /* Deal with different numbers of args */
-
-  switch (num_args)
-    {
-
-    case 0:
-      ui_out_message (uiout, 0,
-		      "Usage: <command> <register>      |\n"
-		      "       <command> <group>         |\n"
-		      "       <command> <group> <index>\n"
-		      "Valid groups are:\n");
-      for (i = 0; i < OR1K_NUM_SPGS; i++)
-	{
-	  ui_out_field_string (uiout, NULL, or1k_spr_group_name (i));
-	  ui_out_spaces (uiout, 1);
-	  ui_out_wrap_hint (uiout, NULL);
-	}
-      ui_out_field_string (uiout, NULL, "\n");
-
-      *index = -1;
-      return trailer;
-
-    case 1:
-      /* See if it is a numeric group */
-      if (arg[0].is_num)
-	{
-	  if (arg[0].val < OR1K_NUM_SPGS)
-	    {
-	      *group = arg[0].val;
-	      *index = -1;
-	      return trailer;
-	    }
-	  else
-	    {
-	      ui_out_message (uiout, 0,
-			      "Group index should be in the range 0 - %d\n",
-			      OR1K_NUM_SPGS);
-	      *group = -1;
-	      *index = -1;
-	      return trailer;
-	    }
-	}
-
-      /* Is is it a group name? */
-      *group = or1k_groupnum_from_name (arg[0].str);
-      if (*group >= 0)
-	{
-	  *index = -1;
-	  return trailer;
-	}
-
-      /* See if it is a valid register name in any group */
-      for (*group = 0; *group < OR1K_NUM_SPGS; (*group)++)
-	{
-	  *index = or1k_regnum_from_name (*group, arg[0].str);
-
-	  if (*index >= 0)
-	    {
-	      return trailer;
-	    }
-	}
-
-      /* Couldn't find it - print out a rude message */
-      ui_out_message (uiout, 0,
-		      "Group or register name not recognized.\n"
-		      "Valid groups are:\n");
-      for (i = 0; i < OR1K_NUM_SPGS; i++)
-	{
-	  ui_out_field_string (uiout, NULL, or1k_spr_group_name (i));
-	  ui_out_spaces (uiout, 1);
-	  ui_out_wrap_hint (uiout, NULL);
-	}
-      ui_out_field_string (uiout, NULL, "\n");
-
-      *group = -1;
-      *index = -1;
-      return trailer;
-
-    case 2:
-      /* See if first arg is a numeric group */
-      if (arg[0].is_num)
-	{
-	  if (arg[0].val < OR1K_NUM_SPGS)
-	    {
-	      *group = arg[0].val;
-	      *index = -1;
-	    }
-	  else
-	    {
-	      ui_out_message (uiout, 0,
-			      "Group index should be in the range 0 - %d\n",
-			      OR1K_NUM_SPGS - 1);
-	      *group = -1;
-	      *index = -1;
-	      return trailer;
-	    }
-	}
-      else
-	{
-	  /* Is is it a group name? */
-	  *group = or1k_groupnum_from_name (arg[0].str);
-	  if (*group >= 0)
-	    {
-	      *index = -1;
-	    }
-	  else
-	    {
-	      ui_out_message (uiout, 0,
-			      "Group name not recognized.\n"
-			      "Valid groups are:\n");
-	      for (i = 0; i < OR1K_NUM_SPGS; i++)
-		{
-		  ui_out_field_string (uiout, NULL, or1k_spr_group_name (i));
-		  ui_out_spaces (uiout, 1);
-		  ui_out_wrap_hint (uiout, NULL);
-		}
-	      ui_out_field_string (uiout, NULL, "\n");
-
-	      *group = -1;
-	      *index = -1;
-	      return trailer;
-	    }
-	}
-
-      /* Is second arg an index or name? */
-      if (arg[1].is_num)
-	{
-	  if (arg[1].val < OR1K_SPG_SIZE)
-	    {
-	      /* Check this really is a register */
-	      if (0 != strlen (or1k_spr_register_name (*group, arg[1].val,
-						       spr_name)))
-		{
-		  *index = arg[1].val;
-		  return trailer;
-		}
-	      else
-		{
-		  ui_out_message (uiout, 0,
-				  "No valid register@that index in group\n");
-		  *group = -1;
-		  *index = -1;
-		  return trailer;
-		}
-	    }
-	  else
-	    {
-	      ui_out_message (uiout, 0,
-			      "Register index should be in the range 0 - %d\n",
-			      OR1K_SPG_SIZE - 1);
-	      *group = -1;
-	      *index = -1;
-	      return trailer;
-	    }
-	}
-
-      /* Must be a name */
-      *index = or1k_regnum_from_name (*group, arg[1].str);
-
-      if (*index >= 0)
-	{
-	  return trailer;
-	}
-
-      /* Couldn't find it - print out a rude message */
-      ui_out_message (uiout, 0, "Register name not recognized in group.\n");
-      *group = -1;
-      *index = -1;
-      return trailer;
-
-    default:
-      /* Anything else is an error */
-      ui_out_message (uiout, 0, "Unable to parse arguments\n");
-      *group = -1;
-      *index = -1;
-      return trailer;
-    }
-}
-
-/* Read a special purpose register from the target.  */
-
-static ULONGEST
-or1k_read_spr (unsigned int regnum)
-{
-  struct ui_file *uibuf = mem_fileopen ();
-  char cmd[sizeof ("readspr ffff")];
-  unsigned long int data;
-  char *res;
-  long int len;
-
-  /* Create the command string and pass it to target remote command function */
-  sprintf (cmd, "readspr %4x", regnum);
-  target_rcmd (cmd, uibuf);
-
-/* TODO YQ
-Why don't you put these special purpose register to g packet, so that
-we can read them through g packet?  It is not a good idea to extend rcmd this way.
-*/
-
-  /* Get the output for the UI file as a string */
-  res = ui_file_xstrdup (uibuf, &len);
-  sscanf (res, "%lx", &data);
-
-  /* Tidy up */
-  xfree (res);
-  ui_file_delete (uibuf);
-
-  return (ULONGEST) data;
-
-}
-
-/* Write a special purpose register on the target.  */
-
-static void
-or1k_write_spr (unsigned int regnum, ULONGEST data)
-{
-  struct ui_file *uibuf = mem_fileopen ();
-  char cmd[sizeof ("writespr ffff ffffffff")];
-  char *res;
-  long int len;
-
-  /* Create the command string and pass it to target remote command function */
-  sprintf (cmd, "writespr %4x %8llx", regnum, (long long unsigned int) data);
-  target_rcmd (cmd, uibuf);
-
-  /* Flush the register cache */
-  registers_changed ();
-
-  /* We ignore the result - Rcmd can put out its own error messages. Just
-     tidy up.  */
-  ui_file_delete (uibuf);
-
-}
-
-/* Show the value of a special purpose register or group.  */
-
-static void
-or1k_info_spr_command (char *args, int from_tty)
-{
-  int group;
-  int index;
-  struct ui_out *uiout = current_uiout;
-  char spr_name[32];
-
-  or1k_parse_spr_params (args, &group, &index, 0);
-
-/* TODO YQ
-Could you explain what do you want to do for special purpose
-register/group here?
-*/
-
-  if (group < 0)
-    {
-      return; /* couldn't parse the args */
-    }
-
-  if (index >= 0)
-    {
-      ULONGEST value = or1k_read_spr (OR1K_SPR (group, index));
-
-      ui_out_field_fmt (uiout, NULL, "%s.%s = SPR%i_%i = %llu (0x%llx)\n",
-			or1k_spr_group_name (group),
-			or1k_spr_register_name (group, index, spr_name),
-			group, index, (long long unsigned int) value,
-			(long long unsigned int) value);
-    }
-  else
-    {
-      /* Print all valid registers in the group.  */
-      for (index = 0; index < OR1K_SPG_SIZE; index++)
-	{
-	  if (0 != strlen (or1k_spr_register_name (group, index, spr_name)))
-	    {
-	      ULONGEST value = or1k_read_spr (OR1K_SPR (group, index));
-
-	      ui_out_field_fmt (uiout, NULL,
-				"%s.%s = SPR%i_%i = %llu (0x%llx)\n",
-				or1k_spr_group_name (group),
-				or1k_spr_register_name (group, index,
-							spr_name), group,
-				index, (long long unsigned int) value,
-				(long long unsigned int) value);
-	    }
-	}
-    }
-}
-
-/* Set a special purpose register command.  */
-
-static void
-or1k_spr_command (char *args, int from_tty)
-{
-  int group;
-  int index;
-  char *tmp_str;
-  char *nargs = or1k_parse_spr_params (args, &group, &index, 1);
-  struct ui_out *uiout = current_uiout;
-  ULONGEST old_val;
-  ULONGEST new_val;
-
-  char spr_name[32];
-
-  /* Do we have a valid register spec?  */
-  if (index < 0)
-    {
-      return; /* Parser will have printed the error message.  */
-    }
-
-  /* Do we have a value to set?  */
-
-  errno = 0;
-  new_val = (ULONGEST) strtoul (nargs, &tmp_str, 0);
-
-  if ((0 != errno) || ('\0' != *tmp_str))
-    {
-      ui_out_message (uiout, 0, "Invalid value - register not changed\n");
-      return;
-    }
-
-  old_val = or1k_read_spr (OR1K_SPR (group, index));
-
-  or1k_write_spr (OR1K_SPR (group, index), new_val);
-
-  ui_out_field_fmt (uiout, NULL,
-		    "%s.%s (SPR%i_%i) set to %llu (0x%llx), "
-		    "was: %llu (0x%llx)\n",
-		    or1k_spr_group_name (group),
-		    or1k_spr_register_name (group, index, spr_name), group,
-		    index, (long long unsigned int) new_val,
-		    (long long unsigned int) new_val,
-		    (long long unsigned int) old_val,
-		    (long long unsigned int) old_val);
-
-}
-
 extern initialize_file_ftype _initialize_or1k_tdep; /* -Wmissing-prototypes */
 
 void
@@ -2370,10 +1433,4 @@ _initialize_or1k_tdep (void)
 
   /* Tell remote stub that we support XML target description.  */
   register_remote_support_xml ("or1k");
-
-  add_info ("spr", or1k_info_spr_command,
-	    "Show the value of a special purpose register");
-  add_com ("spr", class_support, or1k_spr_command,
-	   "Set a special purpose register");
-
 }
gdb/or1k-tdep.h +0 -148

154 lines not on this page · raw message

Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/5 gdb: or1k: Just have one number of registers

In reply to Stafford Horne

Old logic about local vs remote registers and having a cache is trying to be removed. Remove these variables to match that.

---
 gdb/or1k-tdep.c | 10 +++++-----
 gdb/or1k-tdep.h |  4 +---
 2 files changed, 6 insertions(+), 8 deletions(-)
gdb/or1k-tdep.c +5 -5
index bd982b6..d906066 100644
@@ -397,7 +397,7 @@ or1k_single_step_through_delay (struct gdbarch *gdbarch,
 
 /* Name for or1k general registers.  */
 
-static const char *const or1k_reg_names[OR1K_NUM_REGS_CACHED] = {
+static const char *const or1k_reg_names[OR1K_NUM_REGS] = {
   /* general purpose registers */
   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -413,7 +413,7 @@ static const char *const or1k_reg_names[OR1K_NUM_REGS_CACHED] = {
 static const char *
 or1k_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  if (0 <= regnum && regnum < OR1K_NUM_REGS_CACHED)
+  if (0 <= regnum && regnum < OR1K_NUM_REGS)
     {
       return or1k_reg_names[regnum];
     }
@@ -426,7 +426,7 @@ or1k_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 or1k_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  if ((regnum >= 0) && (regnum < OR1K_TOTAL_NUM_REGS))
+  if ((regnum >= 0) && (regnum < OR1K_NUM_REGS))
     {
       switch (regnum)
 	{
@@ -461,7 +461,7 @@ or1k_register_reggroup_p (struct gdbarch *gdbarch,
   if (group == all_reggroup)
     {
       return ((regnum >= 0)
-	      && (regnum < OR1K_NUM_REGS_CACHED)
+	      && (regnum < OR1K_NUM_REGS)
 	      && (or1k_register_name (gdbarch, regnum)[0] != '\0'));
     }
 
@@ -1364,7 +1364,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
       valid_p = 1;
 
-      for (i = 0; i < OR1K_NUM_REGS_CACHED; i++)
+      for (i = 0; i < OR1K_NUM_REGS; i++)
         valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
                                             or1k_reg_names[i]);
 
gdb/or1k-tdep.h +1 -3
index 0684004..335cd5c 100644
@@ -51,9 +51,7 @@
 #define OR1K_MAX_GPR_REGS            32
 #define OR1K_MAX_SPR_REGS           (32 * 2048)
 #define OR1K_NUM_PSEUDO_REGS         0
-#define OR1K_NUM_REGS_CACHED        (OR1K_MAX_GPR_REGS + 3)
-#define OR1K_NUM_REGS               (OR1K_NUM_REGS_CACHED + OR1K_MAX_SPR_REGS)
-#define OR1K_TOTAL_NUM_REGS         (OR1K_NUM_REGS + OR1K_NUM_PSEUDO_REGS)
+#define OR1K_NUM_REGS               (OR1K_MAX_GPR_REGS + 3)
 #define OR1K_STACK_ALIGN             4
 #define OR1K_INSTLEN                 4
 #define OR1K_INSTBITLEN             (OR1K_INSTLEN * 8)
Signature · 1 line
2.7.4
#6 lore raw

cover Openrisc gdb patches after yao's comments

In reply to Stafford Horne

By the way. The entire tree is here

https://github.com/stffrdhrn/binutils-gdb/commits/or1k-upstream/gdb

Quoted 52 lines · Stafford Horne

Hi All,

I wanted to circulate these patches on the openrisc list first. These are in
response to Yao's gdb patch review.

- The first patch is baiscally format and comment updates as per gnu
style.
- The second removes the unimplemented pseudo register functions
- Next is the BIG one it removes the handling of target-description
parsing
and intercepting. But this is as per the recommended way. May what is questionable is how I hard code the reggroups.
- Next removes the special spr commands. I think or1ksim would need to be updated to work with the target-descriptor xml.
- Last is just a cleanup.

The plan would be to squash all of these into the previous patch set I sent.

Test results look ok. Also I tested against openocd and I can reed sprs with
commands like info reg upr as expected.

                === gdb Summary ===
# of expected passes            19241
# of unexpected failures        406
# of expected failures          29
# of known failures             57
# of unresolved testcases       2
# of untested testcases         190
# of unsupported tests          264
/home/shorne/work/openrisc/build-gdb/gdb/gdb version  7.12.50.20161122-git

-Stafford

Stafford Horne (5):
gdb: or1k: Updates suggested by yao in gdb review
gdb: or1k: Remove pseudo registers
or1k: gdb: Simplify handling of tdesc
or1k: gdb: Remove spr commands
gdb: or1k: Just have one number of registers

 gdb/configure.tgt         |   14 -
 gdb/or1k-tdep.c           | 2931 +++++++++---------------------
---------------
 gdb/or1k-tdep.h           |  389 +-----
 gdb/target-descriptions.c |   34 -
 gdb/target-descriptions.h |   12 -
 5 files changed, 549 insertions(+), 2831 deletions(-)
Quoted 4 lines

--
2.7.4

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20161217/5d16970c/attachment.html>