* gdbarch.sh (static_transform_name): New gdbarch callback.
authorUlrich Weigand <uweigand@de.ibm.com>
Fri, 19 Oct 2007 12:23:21 +0000 (12:23 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Fri, 19 Oct 2007 12:23:21 +0000 (12:23 +0000)
* gdbarch.c, gdbarch.h: Regenerate.
* dbxread.c (read_dbx_symtab): Use gdbarch_static_transform_name
instead of STATIC_TRANSFORM_NAME.
* mdebugread.c (parse_partial_symbols): Likewise.
* stabsread.c (define_symbol): Likewise.
* xcoffread.c (scan_xcoff_symtab): Likewise.

* config/i368/tm-i386sol2.h (STATIC_TRANSFORM_NAME): Remove.
(IS_STATIC_TRANSFORM_NAME): Remove.
* i386-tdep.c (sunpro_static_transform_name): Remove, move to ...
* i386-sol2-tdep.c (i386_sol2_static_transform_name): ... here.
(i386_sol2_init_abi): Install it.

* config/sparc/tm-sol2.h (STATIC_TRANSFORM_NAME): Remove.
(IS_STATIC_TRANSFORM_NAME): Remove.
* sparc-tdep.c (sparc_stabs_unglobalize_name): Remove, move to ...
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): ... here.
(sparc32_sol2_init_abi): Install it.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Likewise.
* sparc-tdep.h (sparc_sol2_static_transform_name): Add prototype.

16 files changed:
gdb/ChangeLog
gdb/config/i386/tm-i386sol2.h
gdb/config/sparc/tm-sol2.h
gdb/dbxread.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-sol2-tdep.c
gdb/i386-tdep.c
gdb/mdebugread.c
gdb/sparc-sol2-tdep.c
gdb/sparc-tdep.c
gdb/sparc-tdep.h
gdb/sparc64-sol2-tdep.c
gdb/stabsread.c
gdb/xcoffread.c

index 2e66f039aa955dfc301380aab48cebef13d173eb..69491a26511acff82c9a00f741460d669926a353 100644 (file)
@@ -1,3 +1,27 @@
+2007-10-19  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * gdbarch.sh (static_transform_name): New gdbarch callback.
+       * gdbarch.c, gdbarch.h: Regenerate.
+       * dbxread.c (read_dbx_symtab): Use gdbarch_static_transform_name
+       instead of STATIC_TRANSFORM_NAME.
+       * mdebugread.c (parse_partial_symbols): Likewise.
+       * stabsread.c (define_symbol): Likewise.
+       * xcoffread.c (scan_xcoff_symtab): Likewise.
+
+       * config/i368/tm-i386sol2.h (STATIC_TRANSFORM_NAME): Remove.
+       (IS_STATIC_TRANSFORM_NAME): Remove.
+       * i386-tdep.c (sunpro_static_transform_name): Remove, move to ...
+       * i386-sol2-tdep.c (i386_sol2_static_transform_name): ... here.
+       (i386_sol2_init_abi): Install it.
+
+       * config/sparc/tm-sol2.h (STATIC_TRANSFORM_NAME): Remove.
+       (IS_STATIC_TRANSFORM_NAME): Remove.
+       * sparc-tdep.c (sparc_stabs_unglobalize_name): Remove, move to ...
+       * sparc-sol2-tdep.c (sparc_sol2_static_transform_name): ... here.
+       (sparc32_sol2_init_abi): Install it.
+       * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Likewise.
+       * sparc-tdep.h (sparc_sol2_static_transform_name): Add prototype.
+
 2007-10-18  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * mips-tdep.c (mips_xfer_register): Take a gdbarch argument.
index af7649ced5869dac995ddcc81ae359b1414a9a3c..02f299ddb26e1ded823ac46ed4f8081f5febac2b 100644 (file)
@@ -24,8 +24,4 @@
    and for SunPRO 3.0, N_FUN symbols too.  */
 #define SOFUN_ADDRESS_MAYBE_MISSING
 
-extern char *sunpro_static_transform_name (char *);
-#define STATIC_TRANSFORM_NAME(x) sunpro_static_transform_name (x)
-#define IS_STATIC_TRANSFORM_NAME(name) ((name)[0] == '.')
-
 #endif /* tm-i386sol2.h */
index 2ed183ed5f56d7caf6ae04bfb95c4f953a4a01e6..28746afa002da45332fc00c3e522c3fbca5e9fd8 100644 (file)
    too.  */
 #define SOFUN_ADDRESS_MAYBE_MISSING
 
-/* The Sun compilers also do "globalization"; see the comment in
-   sparc-tdep.c for more information.  */
-extern char *sparc_stabs_unglobalize_name (char *name);
-#define STATIC_TRANSFORM_NAME(name) \
-  sparc_stabs_unglobalize_name (name)
-#define IS_STATIC_TRANSFORM_NAME(name) \
-  ((name) != sparc_stabs_unglobalize_name (name))
-
 #endif /* tm-sol2.h */
index d472d3e3c0d2d97de7fc93833328bb1e3d9edc35..a51fe9d757eabb8b579dc35f47fea5a97a7ba839 100644 (file)
@@ -1680,9 +1680,11 @@ read_dbx_symtab (struct objfile *objfile)
          {
          case 'S':
            nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
-#ifdef STATIC_TRANSFORM_NAME
-           namestring = STATIC_TRANSFORM_NAME (namestring);
-#endif
+
+           if (gdbarch_static_transform_name_p (current_gdbarch))
+             namestring = gdbarch_static_transform_name
+                            (current_gdbarch, namestring);
+
            add_psymbol_to_list (namestring, p - namestring,
                                 VAR_DOMAIN, LOC_STATIC,
                                 &objfile->static_psymbols,
index 8b51c022095b3046656ef32b4deae052eaf15a0c..818e055d7f8d043faa3a78a6d16104d81cf924e6 100644 (file)
@@ -227,6 +227,7 @@ struct gdbarch
   gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
   gdbarch_overlay_update_ftype *overlay_update;
   gdbarch_core_read_description_ftype *core_read_description;
+  gdbarch_static_transform_name_ftype *static_transform_name;
 };
 
 
@@ -346,6 +347,7 @@ struct gdbarch startup_gdbarch =
   0,  /* skip_permanent_breakpoint */
   0,  /* overlay_update */
   0,  /* core_read_description */
+  0,  /* static_transform_name */
   /* startup_gdbarch() */
 };
 
@@ -590,6 +592,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
   /* Skip verify of skip_permanent_breakpoint, has predicate */
   /* Skip verify of overlay_update, has predicate */
   /* Skip verify of core_read_description, has predicate */
+  /* Skip verify of static_transform_name, has predicate */
   buf = ui_file_xstrdup (log, &dummy);
   make_cleanup (xfree, buf);
   if (strlen (buf) > 0)
@@ -983,6 +986,12 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: stabs_argument_has_addr = <0x%lx>\n",
                       (long) current_gdbarch->stabs_argument_has_addr);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_static_transform_name_p() = %d\n",
+                      gdbarch_static_transform_name_p (current_gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: static_transform_name = <0x%lx>\n",
+                      (long) current_gdbarch->static_transform_name);
   fprintf_unfiltered (file,
                       "gdbarch_dump: target_desc = %s\n",
                       paddr_d ((long) current_gdbarch->target_desc));
@@ -2931,6 +2940,30 @@ set_gdbarch_core_read_description (struct gdbarch *gdbarch,
   gdbarch->core_read_description = core_read_description;
 }
 
+int
+gdbarch_static_transform_name_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->static_transform_name != NULL;
+}
+
+char *
+gdbarch_static_transform_name (struct gdbarch *gdbarch, char *name)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->static_transform_name != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_static_transform_name called\n");
+  return gdbarch->static_transform_name (name);
+}
+
+void
+set_gdbarch_static_transform_name (struct gdbarch *gdbarch,
+                                   gdbarch_static_transform_name_ftype static_transform_name)
+{
+  gdbarch->static_transform_name = static_transform_name;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
index b6824510295817a8db1541cab28340c1a415081b..412e74fd97a804c037d439598dd0773d8cb1c00f 100644 (file)
@@ -664,6 +664,14 @@ typedef const struct target_desc * (gdbarch_core_read_description_ftype) (struct
 extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
 extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
 
+/* Handle special encoding of static variables in stabs debug info. */
+
+extern int gdbarch_static_transform_name_p (struct gdbarch *gdbarch);
+
+typedef char * (gdbarch_static_transform_name_ftype) (char *name);
+extern char * gdbarch_static_transform_name (struct gdbarch *gdbarch, char *name);
+extern void set_gdbarch_static_transform_name (struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype *static_transform_name);
+
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
index a5f0a2a06094abd201542675c10139f79e710645..965bd9b7c88f320ec16bb1fc1b8d4c7da58192b0 100755 (executable)
@@ -638,6 +638,9 @@ F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache
 F::void:overlay_update:struct obj_section *osect:osect
 
 M::const struct target_desc *:core_read_description:struct target_ops *target, bfd *abfd:target, abfd
+
+# Handle special encoding of static variables in stabs debug info.
+F::char *:static_transform_name:char *name:name
 EOF
 }
 
index 0f7f8df9809be64984d776d9b7ef0b8a43ba0901..586ca963dd714f04d029b29808da1941c44f4ac9 100644 (file)
@@ -76,6 +76,29 @@ i386_sol2_mcontext_addr (struct frame_info *next_frame)
   return ucontext_addr + 36;
 }
 
+/* SunPRO encodes the static variables.  This is not related to C++
+   mangling, it is done for C too.  */
+
+static char *
+i386_sol2_static_transform_name (char *name)
+{
+  char *p;
+  if (name[0] == '.')
+    {
+      /* For file-local statics there will be a period, a bunch of
+         junk (the contents of which match a string given in the
+         N_OPT), a period and the name.  For function-local statics
+         there will be a bunch of junk (which seems to change the
+         second character from 'A' to 'B'), a period, the name of the
+         function, and the name.  So just skip everything before the
+         last period.  */
+      p = strrchr (name, '.');
+      if (p != NULL)
+        name = p + 1;
+    }
+  return name;
+}
+
 /* Solaris 2.  */
 
 static void
@@ -86,6 +109,9 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* Solaris is SVR4-based.  */
   i386_svr4_init_abi (info, gdbarch);
 
+  /* Handle SunPRO encoding of static symbols.  */
+  set_gdbarch_static_transform_name (gdbarch, i386_sol2_static_transform_name);
+
   /* Solaris reserves space for its FPU emulator in `fpregset_t'.
      There is also some space reserved for the registers of a Weitek
      math coprocessor.  */
index 48b03911e3c9b6d849cbbf973589905da9bd5936..58e1cf22df6cb87763542841f7350df03f759c1b 100644 (file)
@@ -2067,32 +2067,6 @@ i386_regset_from_core_section (struct gdbarch *gdbarch,
 }
 \f
 
-#ifdef STATIC_TRANSFORM_NAME
-/* SunPRO encodes the static variables.  This is not related to C++
-   mangling, it is done for C too.  */
-
-char *
-sunpro_static_transform_name (char *name)
-{
-  char *p;
-  if (IS_STATIC_TRANSFORM_NAME (name))
-    {
-      /* For file-local statics there will be a period, a bunch of
-         junk (the contents of which match a string given in the
-         N_OPT), a period and the name.  For function-local statics
-         there will be a bunch of junk (which seems to change the
-         second character from 'A' to 'B'), a period, the name of the
-         function, and the name.  So just skip everything before the
-         last period.  */
-      p = strrchr (name, '.');
-      if (p != NULL)
-       name = p + 1;
-    }
-  return name;
-}
-#endif /* STATIC_TRANSFORM_NAME */
-\f
-
 /* Stuff for WIN32 PE style DLL's but is pretty generic really.  */
 
 CORE_ADDR
index c9cc2600398c8382f614ff05ae48c8623653fbd6..3797287a6829f7f7507becba79f69588964ea4b0 100644 (file)
@@ -2999,9 +2999,11 @@ parse_partial_symbols (struct objfile *objfile)
                      {
                      case 'S':
                        sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
-#ifdef STATIC_TRANSFORM_NAME
-                       namestring = STATIC_TRANSFORM_NAME (namestring);
-#endif
+
+                       if (gdbarch_static_transform_name_p (current_gdbarch))
+                         namestring = gdbarch_static_transform_name
+                                        (current_gdbarch, namestring);
+
                        add_psymbol_to_list (namestring, p - namestring,
                                             VAR_DOMAIN, LOC_STATIC,
                                             &objfile->static_psymbols,
index fcfb5553c5c90f11bae727a0c2e0227534a70138..bb04fd5f63ba03ad3ff2fb389bcfff206d96b700 100644 (file)
@@ -168,6 +168,37 @@ sparc32_sol2_sigtramp_frame_sniffer (struct frame_info *next_frame)
 
   return NULL;
 }
+
+/* Unglobalize NAME.  */
+
+char *
+sparc_sol2_static_transform_name (char *name)
+{
+  /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop,
+     SunPRO) convert file static variables into global values, a
+     process known as globalization.  In order to do this, the
+     compiler will create a unique prefix and prepend it to each file
+     static variable.  For static variables within a function, this
+     globalization prefix is followed by the function name (nested
+     static variables within a function are supposed to generate a
+     warning message, and are left alone).  The procedure is
+     documented in the Stabs Interface Manual, which is distrubuted
+     with the compilers, although version 4.0 of the manual seems to
+     be incorrect in some places, at least for SPARC.  The
+     globalization prefix is encoded into an N_OPT stab, with the form
+     "G=<prefix>".  The globalization prefix always seems to start
+     with a dollar sign '$'; a dot '.' is used as a seperator.  So we
+     simply strip everything up until the last dot.  */
+
+  if (name[0] == '$')
+    {
+      char *p = strrchr (name, '.');
+      if (p)
+        return p + 1;
+    }
+
+  return name;
+}
 \f
 
 void
@@ -175,6 +206,11 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+  /* The Sun compilers also do "globalization"; see the comment in
+     sparc_sol2_static_transform_name for more information.  */
+  set_gdbarch_static_transform_name
+    (gdbarch, sparc_sol2_static_transform_name);
+
   /* Solaris has SVR4-style shared libraries...  */
   set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
   set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
index 6f2838546d9714c32d8a02098bddee5ea798bffd..734389229dec34dbc26525b792f8017f19f41175 100644 (file)
@@ -1354,37 +1354,6 @@ sparc_write_pc (struct regcache *regcache, CORE_ADDR pc)
   regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4);
 }
 \f
-/* Unglobalize NAME.  */
-
-char *
-sparc_stabs_unglobalize_name (char *name)
-{
-  /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop,
-     SunPRO) convert file static variables into global values, a
-     process known as globalization.  In order to do this, the
-     compiler will create a unique prefix and prepend it to each file
-     static variable.  For static variables within a function, this
-     globalization prefix is followed by the function name (nested
-     static variables within a function are supposed to generate a
-     warning message, and are left alone).  The procedure is
-     documented in the Stabs Interface Manual, which is distrubuted
-     with the compilers, although version 4.0 of the manual seems to
-     be incorrect in some places, at least for SPARC.  The
-     globalization prefix is encoded into an N_OPT stab, with the form
-     "G=<prefix>".  The globalization prefix always seems to start
-     with a dollar sign '$'; a dot '.' is used as a seperator.  So we
-     simply strip everything up until the last dot.  */
-
-  if (name[0] == '$')
-    {
-      char *p = strrchr (name, '.');
-      if (p)
-       return p + 1;
-    }
-
-  return name;
-}
-\f
 
 /* Return the appropriate register set for the core section identified
    by SECT_NAME and SECT_SIZE.  */
index 3fd393394958261b2494219081ca2922e62f4167..9e4f3e4c5ade0160ff6454f651b7d84e373a063d 100644 (file)
@@ -190,6 +190,8 @@ extern const struct sparc_gregset sparc32_sol2_gregset;
 
 extern int sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name);
 
+extern char *sparc_sol2_static_transform_name (char *name);
+
 extern void sparc32_sol2_init_abi (struct gdbarch_info info,
                                   struct gdbarch *gdbarch);
 
index c885460e72d480126cec6fa4382c5d3841149d62..5411b9bdff6d2cc1cce24b796bd4a350862ed82d 100644 (file)
@@ -157,6 +157,11 @@ sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   sparc64_init_abi (info, gdbarch);
 
+  /* The Sun compilers also do "globalization"; see the comment in
+     sparc_sol2_static_transform_name for more information.  */
+  set_gdbarch_static_transform_name
+    (gdbarch, sparc_sol2_static_transform_name);
+
   /* Solaris has SVR4-style shared libraries...  */
   set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
   set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
index 929a856d3c4d3aa0c214808f0d3e47a0baeddba9..fb031c71116ffe25838a9da9052c5eb089c96e13 100644 (file)
@@ -664,11 +664,11 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
          /* This was an anonymous type that was never fixed up.  */
          goto normal;
 
-#ifdef STATIC_TRANSFORM_NAME
        case 'X':
          /* SunPRO (3.0 at least) static variable encoding.  */
-         goto normal;
-#endif
+         if (gdbarch_static_transform_name_p (current_gdbarch))
+           goto normal;
+         /* ... fall through ... */
 
        default:
          complaint (&symfile_complaints, _("Unknown C++ symbol name `%s'"),
@@ -1096,18 +1096,21 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       SYMBOL_CLASS (sym) = LOC_STATIC;
       SYMBOL_VALUE_ADDRESS (sym) = valu;
-#ifdef STATIC_TRANSFORM_NAME
-      if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
+      if (gdbarch_static_transform_name_p (current_gdbarch)
+         && gdbarch_static_transform_name (current_gdbarch,
+                                           DEPRECATED_SYMBOL_NAME (sym))
+            != DEPRECATED_SYMBOL_NAME (sym))
        {
          struct minimal_symbol *msym;
          msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
          if (msym != NULL)
            {
-             DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+             DEPRECATED_SYMBOL_NAME (sym) = gdbarch_static_transform_name
+                                              (current_gdbarch,        
+                                               DEPRECATED_SYMBOL_NAME (sym));
              SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
            }
        }
-#endif
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, &file_symbols);
       break;
@@ -1276,18 +1279,21 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       SYMBOL_CLASS (sym) = LOC_STATIC;
       SYMBOL_VALUE_ADDRESS (sym) = valu;
-#ifdef STATIC_TRANSFORM_NAME
-      if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
+      if (gdbarch_static_transform_name_p (current_gdbarch)
+         && gdbarch_static_transform_name (current_gdbarch,
+                                           DEPRECATED_SYMBOL_NAME (sym))
+            != DEPRECATED_SYMBOL_NAME (sym))
        {
          struct minimal_symbol *msym;
          msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
          if (msym != NULL)
            {
-             DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+             DEPRECATED_SYMBOL_NAME (sym) = gdbarch_static_transform_name
+                                              (current_gdbarch,        
+                                               DEPRECATED_SYMBOL_NAME (sym));
              SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
            }
        }
-#endif
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
        add_symbol_to_list (sym, &local_symbols);
       break;
index 49bf023679a2923b2906fc078183aaee81d648d1..1aeddbc8d833054f58fec9f4f908de15ef1552b3 100644 (file)
@@ -2581,9 +2581,11 @@ scan_xcoff_symtab (struct objfile *objfile)
              {
              case 'S':
                symbol.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
-#ifdef STATIC_TRANSFORM_NAME
-               namestring = STATIC_TRANSFORM_NAME (namestring);
-#endif
+
+               if (gdbarch_static_transform_name_p (current_gdbarch))
+                 namestring = gdbarch_static_transform_name
+                                (current_gdbarch, namestring);
+
                add_psymbol_to_list (namestring, p - namestring,
                                     VAR_DOMAIN, LOC_STATIC,
                                     &objfile->static_psymbols,