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.
#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 */
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)