]> Git Repo - binutils.git/blobdiff - gdb/parse.c
* gdb.fortran/types.exp: Escape brackets in expect patterns
[binutils.git] / gdb / parse.c
index 99f0b2719a62c61758b2209cf1a5804e8e735279..edb374cea96f659ba9aa4989f46a13f94c057edd 100644 (file)
@@ -101,6 +101,44 @@ unsigned num_std_regs = (sizeof std_regs / sizeof std_regs[0]);
 
 #endif
 
+/* The generic method for targets to specify how their registers are named.
+   The mapping can be derived from three sources: reg_names; std_regs; or
+   a target specific alias hook. */
+
+int
+target_map_name_to_register (str, len)
+     char *str;
+     int len;
+{
+  int i;
+
+  /* First try target specific aliases. We try these first because on some 
+     systems standard names can be context dependent (eg. $pc on a 
+     multiprocessor can be could be any of several PCs).  */
+#ifdef REGISTER_NAME_ALIAS_HOOK
+  i =  REGISTER_NAME_ALIAS_HOOK (str, len);
+  if (i >= 0)
+    return i;
+#endif
+
+  /* Search architectural register name space. */
+  for (i = 0; i < NUM_REGS; i++)
+    if (reg_names[i] && len == strlen (reg_names[i])
+       && STREQN (str, reg_names[i], len))
+      {
+       return i;
+      }
+
+  /* Try standard aliases */
+  for (i = 0; i < num_std_regs; i++)
+    if (std_regs[i].name && len == strlen (std_regs[i].name)
+       && STREQN (str, std_regs[i].name, len))
+      {
+       return std_regs[i].regnum;
+      }
+
+  return -1;
+}
 
 /* Begin counting arguments for a function call,
    saving the data about any containing call.  */
@@ -455,19 +493,9 @@ write_dollar_variable (str)
   
   /* Handle tokens that refer to machine registers:
      $ followed by a register name.  */
-  for (i = 0; i < NUM_REGS; i++)
-    if (reg_names[i] && str.length - 1 == strlen (reg_names[i])
-       && STREQN (str.ptr + 1, reg_names[i], str.length - 1))
-      {
-       goto handle_register;
-      }
-  for (i = 0; i < num_std_regs; i++)
-    if (std_regs[i].name && str.length - 1 == strlen (std_regs[i].name)
-       && STREQN (str.ptr + 1, std_regs[i].name, str.length - 1))
-      {
-       i = std_regs[i].regnum;
-       goto handle_register;
-      }
+  i = target_map_name_to_register( str.ptr + 1, str.length - 1 );
+  if( i >= 0 )
+    goto handle_register;
 
   /* Any other names starting in $ are debugger internal variables.  */
 
This page took 0.026505 seconds and 4 git commands to generate.