* gdbarch.sh (static_transform_name): New gdbarch callback.
[deliverable/binutils-gdb.git] / gdb / sparc-sol2-tdep.c
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);
This page took 0.027026 seconds and 4 git commands to generate.