Blame SOURCES/gdb-rhbz1247107-backport-aarch64-stap-sdt-support-1of2.patch

01917d
commit 05c0465e16a5e2db92f8975aebf2bb5aacb1c542
01917d
Author: Sergio Durigan Junior <sergiodj@redhat.com>
01917d
Date:   Thu Dec 19 18:53:40 2013 -0200
01917d
01917d
    Extend SystemTap SDT probe argument parser
01917d
    
01917d
    This patch extends the current generic parser for SystemTap SDT probe
01917d
    arguments.  It can be almost considered a cleanup, but the main point of
01917d
    it is actually to allow the generic parser to accept multiple prefixes
01917d
    and suffixes for the its operands (i.e., integers, register names, and
01917d
    register indirection).
01917d
    
01917d
    I have chosen to implement this as a list of const strings, and declare
01917d
    this list as "static" inside each target's method used to initialize
01917d
    gdbarch.
01917d
    
01917d
    This patch is actually a preparation for an upcoming patch for ARM,
01917d
    which implements the support for multiple integer prefixes (as defined
01917d
    by ARM's asm spec).  And AArch64 will also need this, for the same
01917d
    reason.
01917d
    
01917d
    This patch was regtested on all architectures that it touches (i.e.,
01917d
    i386, x86_64, ARM, PPC/PPC64, s390x and IA-64).  No regressions were found.
01917d
    
01917d
    2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>
01917d
    
01917d
    	* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
01917d
    	argument prefixes and suffixes.  Initialize gdbarch with them.
01917d
    	* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
01917d
    	* gdbarch.c: Regenerate.
01917d
    	* gdbarch.h: Regenerate.
01917d
    	* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
01917d
    	(stap_register_prefix, stap_register_suffix)
01917d
    	(stap_register_indirection_prefix)
01917d
    	(stap_register_indirection_suffix): Declare as "const char *const
01917d
    	*" instead of "const char *".  Adjust printing function.  Rename
01917d
    	all of the variables to the plural.
01917d
    	(pstring_list): New function.
01917d
    	* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
01917d
    	argument prefixes and suffixes.  Initialize gdbarch with them.
01917d
    	* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
01917d
    	* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
01917d
    	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
01917d
    	* stap-probe.c (stap_is_generic_prefix): New function.
01917d
    	(stap_is_register_prefix): Likewise.
01917d
    	(stap_is_register_indirection_prefix): Likewise.
01917d
    	(stap_is_integer_prefix): Likewise.
01917d
    	(stap_generic_check_suffix): Likewise.
01917d
    	(stap_check_integer_suffix): Likewise.
01917d
    	(stap_check_register_suffix): Likewise.
01917d
    	(stap_check_register_indirection_suffix): Likewise.
01917d
    	(stap_parse_register_operand): Remove unecessary declarations for
01917d
    	variables holding prefix and suffix information.  Use the new
01917d
    	functions listed above for checking for prefixes and suffixes.
01917d
    	(stap_parse_single_operand): Likewise.
01917d
01917d
Index: gdb-7.6.1/gdb/amd64-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/amd64-tdep.c
01917d
+++ gdb-7.6.1/gdb/amd64-tdep.c
01917d
@@ -2867,6 +2867,12 @@ amd64_init_abi (struct gdbarch_info info
01917d
 {
01917d
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
01917d
   const struct target_desc *tdesc = info.target_desc;
01917d
+  static const char *const stap_integer_prefixes[] = { "$", NULL };
01917d
+  static const char *const stap_register_prefixes[] = { "%", NULL };
01917d
+  static const char *const stap_register_indirection_prefixes[] = { "(",
01917d
+								    NULL };
01917d
+  static const char *const stap_register_indirection_suffixes[] = { ")",
01917d
+								    NULL };
01917d
 
01917d
   /* AMD64 generally uses `fxsave' instead of `fsave' for saving its
01917d
      floating-point registers.  */
01917d
@@ -2976,10 +2982,12 @@ amd64_init_abi (struct gdbarch_info info
01917d
   set_gdbarch_gen_return_address (gdbarch, amd64_gen_return_address);
01917d
 
01917d
   /* SystemTap variables and functions.  */
01917d
-  set_gdbarch_stap_integer_prefix (gdbarch, "$");
01917d
-  set_gdbarch_stap_register_prefix (gdbarch, "%");
01917d
-  set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
01917d
-  set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
01917d
+  set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
01917d
+  set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
01917d
+					  stap_register_indirection_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
01917d
+					  stap_register_indirection_suffixes);
01917d
   set_gdbarch_stap_is_single_operand (gdbarch,
01917d
 				      i386_stap_is_single_operand);
01917d
   set_gdbarch_stap_parse_special_token (gdbarch,
01917d
Index: gdb-7.6.1/gdb/arm-linux-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/arm-linux-tdep.c
01917d
+++ gdb-7.6.1/gdb/arm-linux-tdep.c
01917d
@@ -1182,6 +1182,12 @@ static void
01917d
 arm_linux_init_abi (struct gdbarch_info info,
01917d
 		    struct gdbarch *gdbarch)
01917d
 {
01917d
+  static const char *const stap_integer_prefixes[] = { "#", NULL };
01917d
+  static const char *const stap_register_prefixes[] = { "r", NULL };
01917d
+  static const char *const stap_register_indirection_prefixes[] = { "[",
01917d
+								    NULL };
01917d
+  static const char *const stap_register_indirection_suffixes[] = { "]",
01917d
+								    NULL };
01917d
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
01917d
 
01917d
   linux_init_abi (info, gdbarch);
01917d
@@ -1281,10 +1287,12 @@ arm_linux_init_abi (struct gdbarch_info
01917d
   set_gdbarch_process_record (gdbarch, arm_process_record);
01917d
 
01917d
   /* SystemTap functions.  */
01917d
-  set_gdbarch_stap_integer_prefix (gdbarch, "#");
01917d
-  set_gdbarch_stap_register_prefix (gdbarch, "r");
01917d
-  set_gdbarch_stap_register_indirection_prefix (gdbarch, "[");
01917d
-  set_gdbarch_stap_register_indirection_suffix (gdbarch, "]");
01917d
+  set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
01917d
+  set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
01917d
+					  stap_register_indirection_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
01917d
+					  stap_register_indirection_suffixes);
01917d
   set_gdbarch_stap_gdb_register_prefix (gdbarch, "r");
01917d
   set_gdbarch_stap_is_single_operand (gdbarch, arm_stap_is_single_operand);
01917d
   set_gdbarch_stap_parse_special_token (gdbarch,
01917d
Index: gdb-7.6.1/gdb/gdbarch.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/gdbarch.c
01917d
+++ gdb-7.6.1/gdb/gdbarch.c
01917d
@@ -86,6 +86,35 @@ pstring (const char *string)
01917d
   return string;
01917d
 }
01917d
 
01917d
+/* Helper function to print a list of strings, represented as "const
01917d
+   char *const *".  The list is printed comma-separated.  */
01917d
+
01917d
+static char *
01917d
+pstring_list (const char *const *list)
01917d
+{
01917d
+  static char ret[100];
01917d
+  const char *const *p;
01917d
+  size_t offset = 0;
01917d
+
01917d
+  if (list == NULL)
01917d
+    return "(null)";
01917d
+
01917d
+  ret[0] = '\0';
01917d
+  for (p = list; *p != NULL && offset < sizeof (ret); ++p)
01917d
+    {
01917d
+      size_t s = xsnprintf (ret + offset, sizeof (ret) - offset, "%s, ", *p);
01917d
+      offset += 2 + s;
01917d
+    }
01917d
+
01917d
+  if (offset > 0)
01917d
+    {
01917d
+      gdb_assert (offset - 2 < sizeof (ret));
01917d
+      ret[offset - 2] = '\0';
01917d
+    }
01917d
+
01917d
+  return ret;
01917d
+}
01917d
+
01917d
 
01917d
 /* Maintain the struct gdbarch object.  */
01917d
 
01917d
@@ -264,12 +293,12 @@ struct gdbarch
01917d
   gdbarch_get_siginfo_type_ftype *get_siginfo_type;
01917d
   gdbarch_record_special_symbol_ftype *record_special_symbol;
01917d
   gdbarch_get_syscall_number_ftype *get_syscall_number;
01917d
-  const char * stap_integer_prefix;
01917d
-  const char * stap_integer_suffix;
01917d
-  const char * stap_register_prefix;
01917d
-  const char * stap_register_suffix;
01917d
-  const char * stap_register_indirection_prefix;
01917d
-  const char * stap_register_indirection_suffix;
01917d
+  const char *const * stap_integer_prefixes;
01917d
+  const char *const * stap_integer_suffixes;
01917d
+  const char *const * stap_register_prefixes;
01917d
+  const char *const * stap_register_suffixes;
01917d
+  const char *const * stap_register_indirection_prefixes;
01917d
+  const char *const * stap_register_indirection_suffixes;
01917d
   const char * stap_gdb_register_prefix;
01917d
   const char * stap_gdb_register_suffix;
01917d
   gdbarch_stap_is_single_operand_ftype *stap_is_single_operand;
01917d
@@ -436,12 +465,12 @@ struct gdbarch startup_gdbarch =
01917d
   0,  /* get_siginfo_type */
01917d
   0,  /* record_special_symbol */
01917d
   0,  /* get_syscall_number */
01917d
-  0,  /* stap_integer_prefix */
01917d
-  0,  /* stap_integer_suffix */
01917d
-  0,  /* stap_register_prefix */
01917d
-  0,  /* stap_register_suffix */
01917d
-  0,  /* stap_register_indirection_prefix */
01917d
-  0,  /* stap_register_indirection_suffix */
01917d
+  0,  /* stap_integer_prefixes */
01917d
+  0,  /* stap_integer_suffixes */
01917d
+  0,  /* stap_register_prefixes */
01917d
+  0,  /* stap_register_suffixes */
01917d
+  0,  /* stap_register_indirection_prefixes */
01917d
+  0,  /* stap_register_indirection_suffixes */
01917d
   0,  /* stap_gdb_register_prefix */
01917d
   0,  /* stap_gdb_register_suffix */
01917d
   0,  /* stap_is_single_operand */
01917d
@@ -741,12 +770,12 @@ verify_gdbarch (struct gdbarch *gdbarch)
01917d
   /* Skip verify of get_siginfo_type, has predicate.  */
01917d
   /* Skip verify of record_special_symbol, has predicate.  */
01917d
   /* Skip verify of get_syscall_number, has predicate.  */
01917d
-  /* Skip verify of stap_integer_prefix, invalid_p == 0 */
01917d
-  /* Skip verify of stap_integer_suffix, invalid_p == 0 */
01917d
-  /* Skip verify of stap_register_prefix, invalid_p == 0 */
01917d
-  /* Skip verify of stap_register_suffix, invalid_p == 0 */
01917d
-  /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */
01917d
-  /* Skip verify of stap_register_indirection_suffix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_integer_prefixes, invalid_p == 0 */
01917d
+  /* Skip verify of stap_integer_suffixes, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_prefixes, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_suffixes, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_indirection_prefixes, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_indirection_suffixes, invalid_p == 0 */
01917d
   /* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */
01917d
   /* Skip verify of stap_gdb_register_suffix, invalid_p == 0 */
01917d
   /* Skip verify of stap_is_single_operand, has predicate.  */
01917d
@@ -1342,11 +1371,11 @@ gdbarch_dump (struct gdbarch *gdbarch, s
01917d
                       "gdbarch_dump: stap_gdb_register_suffix = %s\n",
01917d
                       pstring (gdbarch->stap_gdb_register_suffix));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_integer_prefix = %s\n",
01917d
-                      pstring (gdbarch->stap_integer_prefix));
01917d
+                      "gdbarch_dump: stap_integer_prefixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_integer_prefixes));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_integer_suffix = %s\n",
01917d
-                      pstring (gdbarch->stap_integer_suffix));
01917d
+                      "gdbarch_dump: stap_integer_suffixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_integer_suffixes));
01917d
   fprintf_unfiltered (file,
01917d
                       "gdbarch_dump: gdbarch_stap_is_single_operand_p() = %d\n",
01917d
                       gdbarch_stap_is_single_operand_p (gdbarch));
01917d
@@ -1360,17 +1389,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
01917d
                       "gdbarch_dump: stap_parse_special_token = <%s>\n",
01917d
                       host_address_to_string (gdbarch->stap_parse_special_token));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_register_indirection_prefix = %s\n",
01917d
-                      pstring (gdbarch->stap_register_indirection_prefix));
01917d
+                      "gdbarch_dump: stap_register_indirection_prefixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_register_indirection_prefixes));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_register_indirection_suffix = %s\n",
01917d
-                      pstring (gdbarch->stap_register_indirection_suffix));
01917d
+                      "gdbarch_dump: stap_register_indirection_suffixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_register_indirection_suffixes));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_register_prefix = %s\n",
01917d
-                      pstring (gdbarch->stap_register_prefix));
01917d
+                      "gdbarch_dump: stap_register_prefixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_register_prefixes));
01917d
   fprintf_unfiltered (file,
01917d
-                      "gdbarch_dump: stap_register_suffix = %s\n",
01917d
-                      pstring (gdbarch->stap_register_suffix));
01917d
+                      "gdbarch_dump: stap_register_suffixes = %s\n",
01917d
+                      pstring_list (gdbarch->stap_register_suffixes));
01917d
   fprintf_unfiltered (file,
01917d
                       "gdbarch_dump: gdbarch_static_transform_name_p() = %d\n",
01917d
                       gdbarch_static_transform_name_p (gdbarch));
01917d
@@ -3971,106 +4000,106 @@ set_gdbarch_get_syscall_number (struct g
01917d
   gdbarch->get_syscall_number = get_syscall_number;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_integer_prefix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_integer_prefix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_integer_prefixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_prefix called\n");
01917d
-  return gdbarch->stap_integer_prefix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_prefixes called\n");
01917d
+  return gdbarch->stap_integer_prefixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_integer_prefix (struct gdbarch *gdbarch,
01917d
-                                 const char * stap_integer_prefix)
01917d
+set_gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch,
01917d
+                                   const char *const * stap_integer_prefixes)
01917d
 {
01917d
-  gdbarch->stap_integer_prefix = stap_integer_prefix;
01917d
+  gdbarch->stap_integer_prefixes = stap_integer_prefixes;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_integer_suffix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_integer_suffix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_integer_suffixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_suffix called\n");
01917d
-  return gdbarch->stap_integer_suffix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_suffixes called\n");
01917d
+  return gdbarch->stap_integer_suffixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_integer_suffix (struct gdbarch *gdbarch,
01917d
-                                 const char * stap_integer_suffix)
01917d
+set_gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch,
01917d
+                                   const char *const * stap_integer_suffixes)
01917d
 {
01917d
-  gdbarch->stap_integer_suffix = stap_integer_suffix;
01917d
+  gdbarch->stap_integer_suffixes = stap_integer_suffixes;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_register_prefix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_register_prefixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_register_prefix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_prefixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_prefix called\n");
01917d
-  return gdbarch->stap_register_prefix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_prefixes called\n");
01917d
+  return gdbarch->stap_register_prefixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_register_prefix (struct gdbarch *gdbarch,
01917d
-                                  const char * stap_register_prefix)
01917d
+set_gdbarch_stap_register_prefixes (struct gdbarch *gdbarch,
01917d
+                                    const char *const * stap_register_prefixes)
01917d
 {
01917d
-  gdbarch->stap_register_prefix = stap_register_prefix;
01917d
+  gdbarch->stap_register_prefixes = stap_register_prefixes;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_register_suffix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_register_suffixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_register_suffix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_suffixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_suffix called\n");
01917d
-  return gdbarch->stap_register_suffix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_suffixes called\n");
01917d
+  return gdbarch->stap_register_suffixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_register_suffix (struct gdbarch *gdbarch,
01917d
-                                  const char * stap_register_suffix)
01917d
+set_gdbarch_stap_register_suffixes (struct gdbarch *gdbarch,
01917d
+                                    const char *const * stap_register_suffixes)
01917d
 {
01917d
-  gdbarch->stap_register_suffix = stap_register_suffix;
01917d
+  gdbarch->stap_register_suffixes = stap_register_suffixes;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_indirection_prefixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_prefix called\n");
01917d
-  return gdbarch->stap_register_indirection_prefix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_prefixes called\n");
01917d
+  return gdbarch->stap_register_indirection_prefixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch,
01917d
-                                              const char * stap_register_indirection_prefix)
01917d
+set_gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch,
01917d
+                                                const char *const * stap_register_indirection_prefixes)
01917d
 {
01917d
-  gdbarch->stap_register_indirection_prefix = stap_register_indirection_prefix;
01917d
+  gdbarch->stap_register_indirection_prefixes = stap_register_indirection_prefixes;
01917d
 }
01917d
 
01917d
-const char *
01917d
-gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch)
01917d
+const char *const *
01917d
+gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch)
01917d
 {
01917d
   gdb_assert (gdbarch != NULL);
01917d
-  /* Skip verify of stap_register_indirection_suffix, invalid_p == 0 */
01917d
+  /* Skip verify of stap_register_indirection_suffixes, invalid_p == 0 */
01917d
   if (gdbarch_debug >= 2)
01917d
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_suffix called\n");
01917d
-  return gdbarch->stap_register_indirection_suffix;
01917d
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_suffixes called\n");
01917d
+  return gdbarch->stap_register_indirection_suffixes;
01917d
 }
01917d
 
01917d
 void
01917d
-set_gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch,
01917d
-                                              const char * stap_register_indirection_suffix)
01917d
+set_gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch,
01917d
+                                                const char *const * stap_register_indirection_suffixes)
01917d
 {
01917d
-  gdbarch->stap_register_indirection_suffix = stap_register_indirection_suffix;
01917d
+  gdbarch->stap_register_indirection_suffixes = stap_register_indirection_suffixes;
01917d
 }
01917d
 
01917d
 const char *
01917d
Index: gdb-7.6.1/gdb/gdbarch.h
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/gdbarch.h
01917d
+++ gdb-7.6.1/gdb/gdbarch.h
01917d
@@ -1030,37 +1030,42 @@ extern LONGEST gdbarch_get_syscall_numbe
01917d
 extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number);
01917d
 
01917d
 /* SystemTap related fields and functions.
01917d
-   Prefix used to mark an integer constant on the architecture's assembly
01917d
+   A NULL-terminated array of prefixes used to mark an integer constant
01917d
+   on the architecture's assembly.
01917d
    For example, on x86 integer constants are written as:
01917d
   
01917d
     $10 ;; integer constant 10
01917d
   
01917d
    in this case, this prefix would be the character `$'. */
01917d
 
01917d
-extern const char * gdbarch_stap_integer_prefix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_integer_prefix (struct gdbarch *gdbarch, const char * stap_integer_prefix);
01917d
+extern const char *const * gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch, const char *const * stap_integer_prefixes);
01917d
 
01917d
-/* Suffix used to mark an integer constant on the architecture's assembly. */
01917d
+/* A NULL-terminated array of suffixes used to mark an integer constant
01917d
+   on the architecture's assembly. */
01917d
 
01917d
-extern const char * gdbarch_stap_integer_suffix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_integer_suffix (struct gdbarch *gdbarch, const char * stap_integer_suffix);
01917d
+extern const char *const * gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch, const char *const * stap_integer_suffixes);
01917d
 
01917d
-/* Prefix used to mark a register name on the architecture's assembly.
01917d
+/* A NULL-terminated array of prefixes used to mark a register name on
01917d
+   the architecture's assembly.
01917d
    For example, on x86 the register name is written as:
01917d
   
01917d
     %eax ;; register eax
01917d
   
01917d
    in this case, this prefix would be the character `%'. */
01917d
 
01917d
-extern const char * gdbarch_stap_register_prefix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_register_prefix (struct gdbarch *gdbarch, const char * stap_register_prefix);
01917d
+extern const char *const * gdbarch_stap_register_prefixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_register_prefixes (struct gdbarch *gdbarch, const char *const * stap_register_prefixes);
01917d
 
01917d
-/* Suffix used to mark a register name on the architecture's assembly */
01917d
+/* A NULL-terminated array of suffixes used to mark a register name on
01917d
+   the architecture's assembly. */
01917d
 
01917d
-extern const char * gdbarch_stap_register_suffix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_register_suffix (struct gdbarch *gdbarch, const char * stap_register_suffix);
01917d
+extern const char *const * gdbarch_stap_register_suffixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_register_suffixes (struct gdbarch *gdbarch, const char *const * stap_register_suffixes);
01917d
 
01917d
-/* Prefix used to mark a register indirection on the architecture's assembly.
01917d
+/* A NULL-terminated array of prefixes used to mark a register
01917d
+   indirection on the architecture's assembly.
01917d
    For example, on x86 the register indirection is written as:
01917d
   
01917d
     (%eax) ;; indirecting eax
01917d
@@ -1070,10 +1075,11 @@ extern void set_gdbarch_stap_register_su
01917d
    Please note that we use the indirection prefix also for register
01917d
    displacement, e.g., `4(%eax)' on x86. */
01917d
 
01917d
-extern const char * gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch, const char * stap_register_indirection_prefix);
01917d
+extern const char *const * gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch, const char *const * stap_register_indirection_prefixes);
01917d
 
01917d
-/* Suffix used to mark a register indirection on the architecture's assembly.
01917d
+/* A NULL-terminated array of suffixes used to mark a register
01917d
+   indirection on the architecture's assembly.
01917d
    For example, on x86 the register indirection is written as:
01917d
   
01917d
     (%eax) ;; indirecting eax
01917d
@@ -1083,10 +1089,10 @@ extern void set_gdbarch_stap_register_in
01917d
    Please note that we use the indirection suffix also for register
01917d
    displacement, e.g., `4(%eax)' on x86. */
01917d
 
01917d
-extern const char * gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch);
01917d
-extern void set_gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch, const char * stap_register_indirection_suffix);
01917d
+extern const char *const * gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch);
01917d
+extern void set_gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch, const char *const * stap_register_indirection_suffixes);
01917d
 
01917d
-/* Prefix used to name a register using GDB's nomenclature.
01917d
+/* Prefix(es) used to name a register using GDB's nomenclature.
01917d
   
01917d
    For example, on PPC a register is represented by a number in the assembly
01917d
    language (e.g., `10' is the 10th general-purpose register).  However,
01917d
Index: gdb-7.6.1/gdb/gdbarch.sh
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/gdbarch.sh
01917d
+++ gdb-7.6.1/gdb/gdbarch.sh
01917d
@@ -823,29 +823,34 @@ M:LONGEST:get_syscall_number:ptid_t ptid
01917d
 
01917d
 # SystemTap related fields and functions.
01917d
 
01917d
-# Prefix used to mark an integer constant on the architecture's assembly
01917d
+# A NULL-terminated array of prefixes used to mark an integer constant
01917d
+# on the architecture's assembly.
01917d
 # For example, on x86 integer constants are written as:
01917d
 #
01917d
 #  \$10 ;; integer constant 10
01917d
 #
01917d
 # in this case, this prefix would be the character \`\$\'.
01917d
-v:const char *:stap_integer_prefix:::0:0::0:pstring (gdbarch->stap_integer_prefix)
01917d
+v:const char *const *:stap_integer_prefixes:::0:0::0:pstring_list (gdbarch->stap_integer_prefixes)
01917d
 
01917d
-# Suffix used to mark an integer constant on the architecture's assembly.
01917d
-v:const char *:stap_integer_suffix:::0:0::0:pstring (gdbarch->stap_integer_suffix)
01917d
+# A NULL-terminated array of suffixes used to mark an integer constant
01917d
+# on the architecture's assembly.
01917d
+v:const char *const *:stap_integer_suffixes:::0:0::0:pstring_list (gdbarch->stap_integer_suffixes)
01917d
 
01917d
-# Prefix used to mark a register name on the architecture's assembly.
01917d
+# A NULL-terminated array of prefixes used to mark a register name on
01917d
+# the architecture's assembly.
01917d
 # For example, on x86 the register name is written as:
01917d
 #
01917d
 #  \%eax ;; register eax
01917d
 #
01917d
 # in this case, this prefix would be the character \`\%\'.
01917d
-v:const char *:stap_register_prefix:::0:0::0:pstring (gdbarch->stap_register_prefix)
01917d
+v:const char *const *:stap_register_prefixes:::0:0::0:pstring_list (gdbarch->stap_register_prefixes)
01917d
 
01917d
-# Suffix used to mark a register name on the architecture's assembly
01917d
-v:const char *:stap_register_suffix:::0:0::0:pstring (gdbarch->stap_register_suffix)
01917d
+# A NULL-terminated array of suffixes used to mark a register name on
01917d
+# the architecture's assembly.
01917d
+v:const char *const *:stap_register_suffixes:::0:0::0:pstring_list (gdbarch->stap_register_suffixes)
01917d
 
01917d
-# Prefix used to mark a register indirection on the architecture's assembly.
01917d
+# A NULL-terminated array of prefixes used to mark a register
01917d
+# indirection on the architecture's assembly.
01917d
 # For example, on x86 the register indirection is written as:
01917d
 #
01917d
 #  \(\%eax\) ;; indirecting eax
01917d
@@ -854,9 +859,10 @@ v:const char *:stap_register_suffix:::0:
01917d
 #
01917d
 # Please note that we use the indirection prefix also for register
01917d
 # displacement, e.g., \`4\(\%eax\)\' on x86.
01917d
-v:const char *:stap_register_indirection_prefix:::0:0::0:pstring (gdbarch->stap_register_indirection_prefix)
01917d
+v:const char *const *:stap_register_indirection_prefixes:::0:0::0:pstring_list (gdbarch->stap_register_indirection_prefixes)
01917d
 
01917d
-# Suffix used to mark a register indirection on the architecture's assembly.
01917d
+# A NULL-terminated array of suffixes used to mark a register
01917d
+# indirection on the architecture's assembly.
01917d
 # For example, on x86 the register indirection is written as:
01917d
 #
01917d
 #  \(\%eax\) ;; indirecting eax
01917d
@@ -865,9 +871,9 @@ v:const char *:stap_register_indirection
01917d
 #
01917d
 # Please note that we use the indirection suffix also for register
01917d
 # displacement, e.g., \`4\(\%eax\)\' on x86.
01917d
-v:const char *:stap_register_indirection_suffix:::0:0::0:pstring (gdbarch->stap_register_indirection_suffix)
01917d
+v:const char *const *:stap_register_indirection_suffixes:::0:0::0:pstring_list (gdbarch->stap_register_indirection_suffixes)
01917d
 
01917d
-# Prefix used to name a register using GDB's nomenclature.
01917d
+# Prefix(es) used to name a register using GDB's nomenclature.
01917d
 #
01917d
 # For example, on PPC a register is represented by a number in the assembly
01917d
 # language (e.g., \`10\' is the 10th general-purpose register).  However,
01917d
@@ -1478,6 +1484,35 @@ pstring (const char *string)
01917d
   return string;
01917d
 }
01917d
 
01917d
+/* Helper function to print a list of strings, represented as "const
01917d
+   char *const *".  The list is printed comma-separated.  */
01917d
+
01917d
+static char *
01917d
+pstring_list (const char *const *list)
01917d
+{
01917d
+  static char ret[100];
01917d
+  const char *const *p;
01917d
+  size_t offset = 0;
01917d
+
01917d
+  if (list == NULL)
01917d
+    return "(null)";
01917d
+
01917d
+  ret[0] = '\0';
01917d
+  for (p = list; *p != NULL && offset < sizeof (ret); ++p)
01917d
+    {
01917d
+      size_t s = xsnprintf (ret + offset, sizeof (ret) - offset, "%s, ", *p);
01917d
+      offset += 2 + s;
01917d
+    }
01917d
+
01917d
+  if (offset > 0)
01917d
+    {
01917d
+      gdb_assert (offset - 2 < sizeof (ret));
01917d
+      ret[offset - 2] = '\0';
01917d
+    }
01917d
+
01917d
+  return ret;
01917d
+}
01917d
+
01917d
 EOF
01917d
 
01917d
 # gdbarch open the gdbarch object
01917d
Index: gdb-7.6.1/gdb/i386-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/i386-tdep.c
01917d
+++ gdb-7.6.1/gdb/i386-tdep.c
01917d
@@ -3767,14 +3767,23 @@ i386_stap_parse_special_token (struct gd
01917d
 void
01917d
 i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
01917d
 {
01917d
+  static const char *const stap_integer_prefixes[] = { "$", NULL };
01917d
+  static const char *const stap_register_prefixes[] = { "%", NULL };
01917d
+  static const char *const stap_register_indirection_prefixes[] = { "(",
01917d
+								    NULL };
01917d
+  static const char *const stap_register_indirection_suffixes[] = { ")",
01917d
+								    NULL };
01917d
+
01917d
   /* We typically use stabs-in-ELF with the SVR4 register numbering.  */
01917d
   set_gdbarch_stab_reg_to_regnum (gdbarch, i386_svr4_reg_to_regnum);
01917d
 
01917d
   /* Registering SystemTap handlers.  */
01917d
-  set_gdbarch_stap_integer_prefix (gdbarch, "$");
01917d
-  set_gdbarch_stap_register_prefix (gdbarch, "%");
01917d
-  set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
01917d
-  set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
01917d
+  set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
01917d
+  set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
01917d
+					  stap_register_indirection_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
01917d
+					  stap_register_indirection_suffixes);
01917d
   set_gdbarch_stap_is_single_operand (gdbarch,
01917d
 				      i386_stap_is_single_operand);
01917d
   set_gdbarch_stap_parse_special_token (gdbarch,
01917d
Index: gdb-7.6.1/gdb/ppc-linux-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/ppc-linux-tdep.c
01917d
+++ gdb-7.6.1/gdb/ppc-linux-tdep.c
01917d
@@ -1723,6 +1723,11 @@ ppc_linux_init_abi (struct gdbarch_info
01917d
 {
01917d
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
01917d
   struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
01917d
+  static const char *const stap_integer_prefixes[] = { "i", NULL };
01917d
+  static const char *const stap_register_indirection_prefixes[] = { "(",
01917d
+								    NULL };
01917d
+  static const char *const stap_register_indirection_suffixes[] = { ")",
01917d
+								    NULL };
01917d
 
01917d
   linux_init_abi (info, gdbarch);
01917d
 
01917d
@@ -1741,9 +1746,11 @@ ppc_linux_init_abi (struct gdbarch_info
01917d
   set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number);
01917d
 
01917d
   /* SystemTap functions.  */
01917d
-  set_gdbarch_stap_integer_prefix (gdbarch, "i");
01917d
-  set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
01917d
-  set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
01917d
+  set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
01917d
+					  stap_register_indirection_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
01917d
+					  stap_register_indirection_suffixes);
01917d
   set_gdbarch_stap_gdb_register_prefix (gdbarch, "r");
01917d
   set_gdbarch_stap_is_single_operand (gdbarch, ppc_stap_is_single_operand);
01917d
   set_gdbarch_stap_parse_special_token (gdbarch,
01917d
Index: gdb-7.6.1/gdb/s390-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/s390-tdep.c
01917d
+++ gdb-7.6.1/gdb/s390-tdep.c
01917d
@@ -3032,6 +3032,11 @@ s390_gdbarch_init (struct gdbarch_info i
01917d
   int have_linux_v1 = 0;
01917d
   int have_linux_v2 = 0;
01917d
   int first_pseudo_reg, last_pseudo_reg;
01917d
+  static const char *const stap_register_prefixes[] = { "%", NULL };
01917d
+  static const char *const stap_register_indirection_prefixes[] = { "(",
01917d
+								    NULL };
01917d
+  static const char *const stap_register_indirection_suffixes[] = { ")",
01917d
+								    NULL };
01917d
 
01917d
   /* Default ABI and register size.  */
01917d
   switch (info.bfd_arch_info->mach)
01917d
@@ -3364,9 +3369,11 @@ s390_gdbarch_init (struct gdbarch_info i
01917d
   set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
01917d
 
01917d
   /* SystemTap functions.  */
01917d
-  set_gdbarch_stap_register_prefix (gdbarch, "%");
01917d
-  set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
01917d
-  set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
01917d
+  set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_prefixes (gdbarch,
01917d
+					  stap_register_indirection_prefixes);
01917d
+  set_gdbarch_stap_register_indirection_suffixes (gdbarch,
01917d
+					  stap_register_indirection_suffixes);
01917d
   set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
01917d
 
01917d
   return gdbarch;
01917d
Index: gdb-7.6.1/gdb/stap-probe.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/stap-probe.c
01917d
+++ gdb-7.6.1/gdb/stap-probe.c
01917d
@@ -346,6 +346,191 @@ stap_get_expected_argument_type (struct
01917d
     }
01917d
 }
01917d
 
01917d
+/* Helper function to check for a generic list of prefixes.  GDBARCH
01917d
+   is the current gdbarch being used.  S is the expression being
01917d
+   analyzed.  If R is not NULL, it will be used to return the found
01917d
+   prefix.  PREFIXES is the list of expected prefixes.
01917d
+
01917d
+   This function does a case-insensitive match.
01917d
+
01917d
+   Return 1 if any prefix has been found, zero otherwise.  */
01917d
+
01917d
+static int
01917d
+stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
01917d
+			const char **r, const char *const *prefixes)
01917d
+{
01917d
+  const char *const *p;
01917d
+
01917d
+  if (prefixes == NULL)
01917d
+    {
01917d
+      if (r != NULL)
01917d
+	*r = "";
01917d
+
01917d
+      return 1;
01917d
+    }
01917d
+
01917d
+  for (p = prefixes; *p != NULL; ++p)
01917d
+    {
01917d
+      if (strncasecmp (s, *p, strlen (*p)) == 0)
01917d
+	{
01917d
+	  if (r != NULL)
01917d
+	    *r = *p;
01917d
+
01917d
+	  return 1;
01917d
+	}
01917d
+    }
01917d
+
01917d
+  return 0;
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to a register prefix, zero otherwise.  For a
01917d
+   description of the arguments, look at stap_is_generic_prefix.  */
01917d
+
01917d
+static int
01917d
+stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
01917d
+			 const char **r)
01917d
+{
01917d
+  const char *const *t = gdbarch_stap_register_prefixes (gdbarch);
01917d
+
01917d
+  return stap_is_generic_prefix (gdbarch, s, r, t);
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to a register indirection prefix, zero
01917d
+   otherwise.  For a description of the arguments, look at
01917d
+   stap_is_generic_prefix.  */
01917d
+
01917d
+static int
01917d
+stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
01917d
+				     const char **r)
01917d
+{
01917d
+  const char *const *t = gdbarch_stap_register_indirection_prefixes (gdbarch);
01917d
+
01917d
+  return stap_is_generic_prefix (gdbarch, s, r, t);
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to an integer prefix, zero otherwise.  For a
01917d
+   description of the arguments, look at stap_is_generic_prefix.
01917d
+
01917d
+   This function takes care of analyzing whether we are dealing with
01917d
+   an expected integer prefix, or, if there is no integer prefix to be
01917d
+   expected, whether we are dealing with a digit.  It does a
01917d
+   case-insensitive match.  */
01917d
+
01917d
+static int
01917d
+stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
01917d
+			const char **r)
01917d
+{
01917d
+  const char *const *t = gdbarch_stap_integer_prefixes (gdbarch);
01917d
+  const char *const *p;
01917d
+
01917d
+  if (t == NULL)
01917d
+    {
01917d
+      /* A NULL value here means that integers do not have a prefix.
01917d
+	 We just check for a digit then.  */
01917d
+      if (r != NULL)
01917d
+	*r = "";
01917d
+
01917d
+      return isdigit (*s);
01917d
+    }
01917d
+
01917d
+  for (p = t; *p != NULL; ++p)
01917d
+    {
01917d
+      size_t len = strlen (*p);
01917d
+
01917d
+      if ((len == 0 && isdigit (*s))
01917d
+	  || (len > 0 && strncasecmp (s, *p, len) == 0))
01917d
+	{
01917d
+	  /* Integers may or may not have a prefix.  The "len == 0"
01917d
+	     check covers the case when integers do not have a prefix
01917d
+	     (therefore, we just check if we have a digit).  The call
01917d
+	     to "strncasecmp" covers the case when they have a
01917d
+	     prefix.  */
01917d
+	  if (r != NULL)
01917d
+	    *r = *p;
01917d
+
01917d
+	  return 1;
01917d
+	}
01917d
+    }
01917d
+
01917d
+  return 0;
01917d
+}
01917d
+
01917d
+/* Helper function to check for a generic list of suffixes.  If we are
01917d
+   not expecting any suffixes, then it just returns 1.  If we are
01917d
+   expecting at least one suffix, then it returns 1 if a suffix has
01917d
+   been found, zero otherwise.  GDBARCH is the current gdbarch being
01917d
+   used.  S is the expression being analyzed.  If R is not NULL, it
01917d
+   will be used to return the found suffix.  SUFFIXES is the list of
01917d
+   expected suffixes.  This function does a case-insensitive
01917d
+   match.  */
01917d
+
01917d
+static int
01917d
+stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
01917d
+			   const char **r, const char *const *suffixes)
01917d
+{
01917d
+  const char *const *p;
01917d
+  int found = 0;
01917d
+
01917d
+  if (suffixes == NULL)
01917d
+    {
01917d
+      if (r != NULL)
01917d
+	*r = "";
01917d
+
01917d
+      return 1;
01917d
+    }
01917d
+
01917d
+  for (p = suffixes; *p != NULL; ++p)
01917d
+    if (strncasecmp (s, *p, strlen (*p)) == 0)
01917d
+      {
01917d
+	if (r != NULL)
01917d
+	  *r = *p;
01917d
+
01917d
+	found = 1;
01917d
+	break;
01917d
+      }
01917d
+
01917d
+  return found;
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to an integer suffix, zero otherwise.  For a
01917d
+   description of the arguments, look at
01917d
+   stap_generic_check_suffix.  */
01917d
+
01917d
+static int
01917d
+stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
01917d
+			   const char **r)
01917d
+{
01917d
+  const char *const *p = gdbarch_stap_integer_suffixes (gdbarch);
01917d
+
01917d
+  return stap_generic_check_suffix (gdbarch, s, r, p);
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to a register suffix, zero otherwise.  For a
01917d
+   description of the arguments, look at
01917d
+   stap_generic_check_suffix.  */
01917d
+
01917d
+static int
01917d
+stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
01917d
+			    const char **r)
01917d
+{
01917d
+  const char *const *p = gdbarch_stap_register_suffixes (gdbarch);
01917d
+
01917d
+  return stap_generic_check_suffix (gdbarch, s, r, p);
01917d
+}
01917d
+
01917d
+/* Return 1 if S points to a register indirection suffix, zero
01917d
+   otherwise.  For a description of the arguments, look at
01917d
+   stap_generic_check_suffix.  */
01917d
+
01917d
+static int
01917d
+stap_check_register_indirection_suffix (struct gdbarch *gdbarch, const char *s,
01917d
+					const char **r)
01917d
+{
01917d
+  const char *const *p = gdbarch_stap_register_indirection_suffixes (gdbarch);
01917d
+
01917d
+  return stap_generic_check_suffix (gdbarch, s, r, p);
01917d
+}
01917d
+
01917d
 /* Function responsible for parsing a register operand according to
01917d
    SystemTap parlance.  Assuming:
01917d
 
01917d
@@ -385,24 +570,14 @@ stap_parse_register_operand (struct stap
01917d
   const char *start;
01917d
   char *regname;
01917d
   int len;
01917d
-
01917d
-  /* Prefixes for the parser.  */
01917d
-  const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch);
01917d
-  const char *reg_ind_prefix
01917d
-    = gdbarch_stap_register_indirection_prefix (gdbarch);
01917d
   const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
01917d
-  int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0;
01917d
-  int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0;
01917d
   int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
01917d
-
01917d
-  /* Suffixes for the parser.  */
01917d
-  const char *reg_suffix = gdbarch_stap_register_suffix (gdbarch);
01917d
-  const char *reg_ind_suffix
01917d
-    = gdbarch_stap_register_indirection_suffix (gdbarch);
01917d
   const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
01917d
-  int reg_suffix_len = reg_suffix ? strlen (reg_suffix) : 0;
01917d
-  int reg_ind_suffix_len = reg_ind_suffix ? strlen (reg_ind_suffix) : 0;
01917d
   int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 0;
01917d
+  const char *reg_prefix;
01917d
+  const char *reg_ind_prefix;
01917d
+  const char *reg_suffix;
01917d
+  const char *reg_ind_suffix;
01917d
 
01917d
   /* Checking for a displacement argument.  */
01917d
   if (*p->arg == '+')
01917d
@@ -436,11 +611,10 @@ stap_parse_register_operand (struct stap
01917d
     }
01917d
 
01917d
   /* Getting rid of register indirection prefix.  */
01917d
-  if (reg_ind_prefix
01917d
-      && strncmp (p->arg, reg_ind_prefix, reg_ind_prefix_len) == 0)
01917d
+  if (stap_is_register_indirection_prefix (gdbarch, p->arg, &reg_ind_prefix))
01917d
     {
01917d
       indirect_p = 1;
01917d
-      p->arg += reg_ind_prefix_len;
01917d
+      p->arg += strlen (reg_ind_prefix);
01917d
     }
01917d
 
01917d
   if (disp_p && !indirect_p)
01917d
@@ -448,8 +622,8 @@ stap_parse_register_operand (struct stap
01917d
 	   p->saved_arg);
01917d
 
01917d
   /* Getting rid of register prefix.  */
01917d
-  if (reg_prefix && strncmp (p->arg, reg_prefix, reg_prefix_len) == 0)
01917d
-    p->arg += reg_prefix_len;
01917d
+  if (stap_is_register_prefix (gdbarch, p->arg, &reg_prefix))
01917d
+    p->arg += strlen (reg_prefix);
01917d
 
01917d
   /* Now we should have only the register name.  Let's extract it and get
01917d
      the associated number.  */
01917d
@@ -507,23 +681,21 @@ stap_parse_register_operand (struct stap
01917d
     }
01917d
 
01917d
   /* Getting rid of the register name suffix.  */
01917d
-  if (reg_suffix)
01917d
-    {
01917d
-      if (strncmp (p->arg, reg_suffix, reg_suffix_len) != 0)
01917d
-	error (_("Missing register name suffix `%s' on expression `%s'."),
01917d
-	       reg_suffix, p->saved_arg);
01917d
-
01917d
-      p->arg += reg_suffix_len;
01917d
-    }
01917d
+  if (stap_check_register_suffix (gdbarch, p->arg, &reg_suffix))
01917d
+    p->arg += strlen (reg_suffix);
01917d
+  else
01917d
+    error (_("Missing register name suffix on expression `%s'."),
01917d
+	   p->saved_arg);
01917d
 
01917d
   /* Getting rid of the register indirection suffix.  */
01917d
-  if (indirect_p && reg_ind_suffix)
01917d
+  if (indirect_p)
01917d
     {
01917d
-      if (strncmp (p->arg, reg_ind_suffix, reg_ind_suffix_len) != 0)
01917d
-	error (_("Missing indirection suffix `%s' on expression `%s'."),
01917d
-	       reg_ind_suffix, p->saved_arg);
01917d
-
01917d
-      p->arg += reg_ind_suffix_len;
01917d
+      if (stap_check_register_indirection_suffix (gdbarch, p->arg,
01917d
+						  &reg_ind_suffix))
01917d
+	p->arg += strlen (reg_ind_suffix);
01917d
+      else
01917d
+	error (_("Missing indirection suffix on expression `%s'."),
01917d
+	       p->saved_arg);
01917d
     }
01917d
 }
01917d
 
01917d
@@ -546,19 +718,7 @@ static void
01917d
 stap_parse_single_operand (struct stap_parse_info *p)
01917d
 {
01917d
   struct gdbarch *gdbarch = p->gdbarch;
01917d
-
01917d
-  /* Prefixes for the parser.  */
01917d
-  const char *const_prefix = gdbarch_stap_integer_prefix (gdbarch);
01917d
-  const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch);
01917d
-  const char *reg_ind_prefix
01917d
-    = gdbarch_stap_register_indirection_prefix (gdbarch);
01917d
-  int const_prefix_len = const_prefix ? strlen (const_prefix) : 0;
01917d
-  int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0;
01917d
-  int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0;
01917d
-
01917d
-  /* Suffixes for the parser.  */
01917d
-  const char *const_suffix = gdbarch_stap_integer_suffix (gdbarch);
01917d
-  int const_suffix_len = const_suffix ? strlen (const_suffix) : 0;
01917d
+  const char *int_prefix = NULL;
01917d
 
01917d
   /* We first try to parse this token as a "special token".  */
01917d
   if (gdbarch_stap_parse_special_token_p (gdbarch))
01917d
@@ -600,8 +760,7 @@ stap_parse_single_operand (struct stap_p
01917d
       if (isdigit (*tmp))
01917d
 	number = strtol (tmp, (char **) &tmp, 10);
01917d
 
01917d
-      if (!reg_ind_prefix
01917d
-	  || strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
01917d
+      if (!stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
01917d
 	{
01917d
 	  /* This is not a displacement.  We skip the operator, and deal
01917d
 	     with it later.  */
01917d
@@ -629,15 +788,22 @@ stap_parse_single_operand (struct stap_p
01917d
       const char *tmp = p->arg;
01917d
       long number;
01917d
 
01917d
-      /* We can be dealing with a numeric constant (if `const_prefix' is
01917d
-	 NULL), or with a register displacement.  */
01917d
+      /* We can be dealing with a numeric constant, or with a register
01917d
+	 displacement.  */
01917d
       number = strtol (tmp, (char **) &tmp, 10);
01917d
 
01917d
       if (p->inside_paren_p)
01917d
 	tmp = skip_spaces_const (tmp);
01917d
-      if (!const_prefix && reg_ind_prefix
01917d
-	  && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
01917d
+
01917d
+      /* If "stap_is_integer_prefix" returns true, it means we can
01917d
+	 accept integers without a prefix here.  But we also need to
01917d
+	 check whether the next token (i.e., "tmp") is not a register
01917d
+	 indirection prefix.  */
01917d
+      if (stap_is_integer_prefix (gdbarch, p->arg, NULL)
01917d
+	  && !stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
01917d
 	{
01917d
+	  const char *int_suffix;
01917d
+
01917d
 	  /* We are dealing with a numeric constant.  */
01917d
 	  write_exp_elt_opcode (OP_LONG);
01917d
 	  write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
01917d
@@ -646,29 +812,25 @@ stap_parse_single_operand (struct stap_p
01917d
 
01917d
 	  p->arg = tmp;
01917d
 
01917d
-	  if (const_suffix)
01917d
-	    {
01917d
-	      if (strncmp (p->arg, const_suffix, const_suffix_len) == 0)
01917d
-		p->arg += const_suffix_len;
01917d
-	      else
01917d
-		error (_("Invalid constant suffix on expression `%s'."),
01917d
-		       p->saved_arg);
01917d
-	    }
01917d
+	  if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
01917d
+	    p->arg += strlen (int_suffix);
01917d
+	  else
01917d
+	    error (_("Invalid constant suffix on expression `%s'."),
01917d
+		   p->saved_arg);
01917d
 	}
01917d
-      else if (reg_ind_prefix
01917d
-	       && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) == 0)
01917d
+      else if (stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
01917d
 	stap_parse_register_operand (p);
01917d
       else
01917d
 	error (_("Unknown numeric token on expression `%s'."),
01917d
 	       p->saved_arg);
01917d
     }
01917d
-  else if (const_prefix
01917d
-	   && strncmp (p->arg, const_prefix, const_prefix_len) == 0)
01917d
+  else if (stap_is_integer_prefix (gdbarch, p->arg, &int_prefix))
01917d
     {
01917d
       /* We are dealing with a numeric constant.  */
01917d
       long number;
01917d
+      const char *int_suffix;
01917d
 
01917d
-      p->arg += const_prefix_len;
01917d
+      p->arg += strlen (int_prefix);
01917d
       number = strtol (p->arg, (char **) &p->arg, 10);
01917d
 
01917d
       write_exp_elt_opcode (OP_LONG);
01917d
@@ -676,19 +838,14 @@ stap_parse_single_operand (struct stap_p
01917d
       write_exp_elt_longcst (number);
01917d
       write_exp_elt_opcode (OP_LONG);
01917d
 
01917d
-      if (const_suffix)
01917d
-	{
01917d
-	  if (strncmp (p->arg, const_suffix, const_suffix_len) == 0)
01917d
-	    p->arg += const_suffix_len;
01917d
-	  else
01917d
-	    error (_("Invalid constant suffix on expression `%s'."),
01917d
-		   p->saved_arg);
01917d
-	}
01917d
+      if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
01917d
+	p->arg += strlen (int_suffix);
01917d
+      else
01917d
+	error (_("Invalid constant suffix on expression `%s'."),
01917d
+	       p->saved_arg);
01917d
     }
01917d
-  else if ((reg_prefix
01917d
-	    && strncmp (p->arg, reg_prefix, reg_prefix_len) == 0)
01917d
-	   || (reg_ind_prefix
01917d
-	       && strncmp (p->arg, reg_ind_prefix, reg_ind_prefix_len) == 0))
01917d
+  else if (stap_is_register_prefix (gdbarch, p->arg, NULL)
01917d
+	   || stap_is_register_indirection_prefix (gdbarch, p->arg, NULL))
01917d
     stap_parse_register_operand (p);
01917d
   else
01917d
     error (_("Operator `%c' not recognized on expression `%s'."),