]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* sparc-tdep.c (sparc_stabs_unglobalize_name): New function.
authorMark Kettenis <kettenis@gnu.org>
Wed, 31 Dec 2003 20:20:08 +0000 (20:20 +0000)
committerMark Kettenis <kettenis@gnu.org>
Wed, 31 Dec 2003 20:20:08 +0000 (20:20 +0000)
* config/sparc/tm-sol2.h (SOFUN_ADDRESS_MAYBE_MISSING): Define.
(sparc_stabs_unglobalize_name): New prototype.
(STATIC_TRANSFORM_NAME, IS_STATIC_TRANSFORM_NAME): New defines.

gdb/ChangeLog
gdb/config/sparc/tm-sol2.h
gdb/sparc-tdep.c

index a575fb88512509f448f7307d9e428a75b4a766b5..c80cddfcdd608712b5e3b0decd252e83da1cdfb3 100644 (file)
@@ -1,5 +1,10 @@
 2003-12-31  Mark Kettenis  <kettenis@gnu.org>
 
+       * sparc-tdep.c (sparc_stabs_unglobalize_name): New function.
+       * config/sparc/tm-sol2.h (SOFUN_ADDRESS_MAYBE_MISSING): Define.
+       (sparc_stabs_unglobalize_name): New prototype.
+       (STATIC_TRANSFORM_NAME, IS_STATIC_TRANSFORM_NAME): New defines.
+
        * sparc64-sol2-tdep.c: Include "frame.h", "frame-unwind.h",
        "trad-frame.h" and "gdb_assert.h".
        (BIAS): Define if not already defined.
index 3f1569cfd52d89a2ef548fb5cd6c201dbc7f1519..d111c1a77688d40195d6d5d72bfdb80383e72e9e 100644 (file)
 
 #define GDB_MULTI_ARCH GDB_MULTI_ARCH_TM
 
+/* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop,
+   SunPRO) compiler puts out 0 instead of the address in N_SO stabs.
+   Starting with SunPRO 3.0, the compiler does this for N_FUN stabs
+   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 d8b83ca920a1fd0bc9a36bcd88a8428dee14baf9..7de4a8e19187a9267893febe23ed166c63226bec 100644 (file)
@@ -968,6 +968,37 @@ sparc_write_pc (CORE_ADDR pc, ptid_t ptid)
   write_register_pid (tdep->npc_regnum, pc + 4, ptid);
 }
 \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
 
 static struct gdbarch *
 sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)