This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH/SPARC] Add back support for "native" Solaris compilers
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 31 Dec 2003 21:20:14 +0100 (CET)
- Subject: [PATCH/SPARC] Add back support for "native" Solaris compilers
This should be multi-arched, but I want to postpone that until I've
merged things back to mainline.
Committed to the branch.
Index: ChangeLog
from 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.
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.127.2.9
diff -u -p -r1.127.2.9 sparc-tdep.c
--- sparc-tdep.c 21 Dec 2003 23:13:59 -0000 1.127.2.9
+++ sparc-tdep.c 31 Dec 2003 20:15:28 -0000
@@ -968,6 +968,37 @@ sparc_write_pc (CORE_ADDR pc, ptid_t pti
write_register_pid (tdep->npc_regnum, pc + 4, ptid);
}
+/* 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;
+}
+
static struct gdbarch *
sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
Index: config/sparc/tm-sol2.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/Attic/tm-sol2.h,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 tm-sol2.h
--- config/sparc/tm-sol2.h 18 Sep 2003 20:14:17 -0000 1.1.2.1
+++ config/sparc/tm-sol2.h 31 Dec 2003 20:15:28 -0000
@@ -23,4 +23,18 @@
#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 */