This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc/rft] [2/3] Remove stabs target macros: STATIC_TRANSFORM_NAME
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 5 Oct 2007 20:05:46 +0200 (CEST)
- Subject: [rfc/rft] [2/3] Remove stabs target macros: STATIC_TRANSFORM_NAME
Hello,
this replaces the target macros STATIC_TRANSFORM_NAME and
IS_STATIC_TRANSFORM_NAME by a new gdbarch callback static_transform_name.
Bye,
Ulrich
ChangeLog:
* 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.
diff -urNp gdb-orig/gdb/config/i386/tm-i386sol2.h gdb-head/gdb/config/i386/tm-i386sol2.h
--- gdb-orig/gdb/config/i386/tm-i386sol2.h 2007-10-05 14:54:51.000000000 +0200
+++ gdb-head/gdb/config/i386/tm-i386sol2.h 2007-10-05 17:52:51.466898399 +0200
@@ -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 */
diff -urNp gdb-orig/gdb/config/sparc/tm-sol2.h gdb-head/gdb/config/sparc/tm-sol2.h
--- gdb-orig/gdb/config/sparc/tm-sol2.h 2007-10-05 14:54:51.000000000 +0200
+++ gdb-head/gdb/config/sparc/tm-sol2.h 2007-10-05 17:52:51.481896238 +0200
@@ -26,12 +26,4 @@
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 */
diff -urNp gdb-orig/gdb/dbxread.c gdb-head/gdb/dbxread.c
--- gdb-orig/gdb/dbxread.c 2007-10-05 17:52:44.503838204 +0200
+++ gdb-head/gdb/dbxread.c 2007-10-05 17:52:51.494894365 +0200
@@ -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,
diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c
--- gdb-orig/gdb/gdbarch.c 2007-10-05 17:52:44.606823368 +0200
+++ gdb-head/gdb/gdbarch.c 2007-10-05 17:52:51.507892493 +0200
@@ -232,6 +232,7 @@ struct gdbarch
gdbarch_overlay_update_ftype *overlay_update;
gdbarch_core_read_description_ftype *core_read_description;
gdbarch_variables_inside_block_ftype *variables_inside_block;
+ gdbarch_static_transform_name_ftype *static_transform_name;
};
@@ -356,6 +357,7 @@ struct gdbarch startup_gdbarch =
0, /* overlay_update */
0, /* core_read_description */
0, /* variables_inside_block */
+ 0, /* static_transform_name */
/* startup_gdbarch() */
};
@@ -605,6 +607,7 @@ verify_gdbarch (struct gdbarch *current_
/* Skip verify of overlay_update, has predicate */
/* Skip verify of core_read_description, has predicate */
/* Skip verify of variables_inside_block, has predicate */
+ /* Skip verify of static_transform_name, has predicate */
buf = ui_file_xstrdup (log, &dummy);
make_cleanup (xfree, buf);
if (strlen (buf) > 0)
@@ -1011,6 +1014,12 @@ gdbarch_dump (struct gdbarch *current_gd
"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: store_return_value = <0x%lx>\n",
(long) current_gdbarch->store_return_value);
fprintf_unfiltered (file,
@@ -3067,6 +3076,30 @@ set_gdbarch_variables_inside_block (stru
gdbarch->variables_inside_block = variables_inside_block;
}
+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. */
diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h
--- gdb-orig/gdb/gdbarch.h 2007-10-05 17:52:44.650817030 +0200
+++ gdb-head/gdb/gdbarch.h 2007-10-05 17:52:51.532888892 +0200
@@ -703,6 +703,14 @@ typedef int (gdbarch_variables_inside_bl
extern int gdbarch_variables_inside_block (struct gdbarch *gdbarch, int desc, int gcc_p);
extern void set_gdbarch_variables_inside_block (struct gdbarch *gdbarch, gdbarch_variables_inside_block_ftype *variables_inside_block);
+/* 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);
diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh
--- gdb-orig/gdb/gdbarch.sh 2007-10-05 17:52:44.657816022 +0200
+++ gdb-head/gdb/gdbarch.sh 2007-10-05 17:53:12.170106771 +0200
@@ -659,6 +659,8 @@ M::const struct target_desc *:core_read_
# lexical context are listed after the beginning LBRAC instead of
# before in the executables list of symbols.
F::int:variables_inside_block:int desc, int gcc_p:desc, gcc_p
+# Handle special encoding of static variables in stabs debug info.
+F::char *:static_transform_name:char *name:name
EOF
}
diff -urNp gdb-orig/gdb/i386-sol2-tdep.c gdb-head/gdb/i386-sol2-tdep.c
--- gdb-orig/gdb/i386-sol2-tdep.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/i386-sol2-tdep.c 2007-10-05 17:52:51.559885003 +0200
@@ -76,6 +76,29 @@ i386_sol2_mcontext_addr (struct frame_in
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
/* 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. */
diff -urNp gdb-orig/gdb/i386-tdep.c gdb-head/gdb/i386-tdep.c
--- gdb-orig/gdb/i386-tdep.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/i386-tdep.c 2007-10-05 17:52:51.567883850 +0200
@@ -2067,32 +2067,6 @@ i386_regset_from_core_section (struct gd
}
-#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 */
-
-
/* Stuff for WIN32 PE style DLL's but is pretty generic really. */
CORE_ADDR
diff -urNp gdb-orig/gdb/mdebugread.c gdb-head/gdb/mdebugread.c
--- gdb-orig/gdb/mdebugread.c 2007-10-05 17:52:33.140745603 +0200
+++ gdb-head/gdb/mdebugread.c 2007-10-05 17:52:51.593880105 +0200
@@ -2999,9 +2999,11 @@ parse_partial_symbols (struct objfile *o
{
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,
diff -urNp gdb-orig/gdb/sparc64-sol2-tdep.c gdb-head/gdb/sparc64-sol2-tdep.c
--- gdb-orig/gdb/sparc64-sol2-tdep.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/sparc64-sol2-tdep.c 2007-10-05 17:52:51.598879385 +0200
@@ -157,6 +157,11 @@ sparc64_sol2_init_abi (struct gdbarch_in
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);
diff -urNp gdb-orig/gdb/sparc-sol2-tdep.c gdb-head/gdb/sparc-sol2-tdep.c
--- gdb-orig/gdb/sparc-sol2-tdep.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/sparc-sol2-tdep.c 2007-10-05 17:52:51.603878665 +0200
@@ -168,6 +168,37 @@ sparc32_sol2_sigtramp_frame_sniffer (str
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;
+}
void
@@ -175,6 +206,11 @@ sparc32_sol2_init_abi (struct gdbarch_in
{
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);
diff -urNp gdb-orig/gdb/sparc-tdep.c gdb-head/gdb/sparc-tdep.c
--- gdb-orig/gdb/sparc-tdep.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/sparc-tdep.c 2007-10-05 17:52:51.610877657 +0200
@@ -1354,37 +1354,6 @@ sparc_write_pc (struct regcache *regcach
regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4);
}
-/* 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;
-}
-
/* Return the appropriate register set for the core section identified
by SECT_NAME and SECT_SIZE. */
diff -urNp gdb-orig/gdb/sparc-tdep.h gdb-head/gdb/sparc-tdep.h
--- gdb-orig/gdb/sparc-tdep.h 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/sparc-tdep.h 2007-10-05 17:52:51.615876936 +0200
@@ -190,6 +190,8 @@ extern const struct sparc_gregset sparc3
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);
diff -urNp gdb-orig/gdb/stabsread.c gdb-head/gdb/stabsread.c
--- gdb-orig/gdb/stabsread.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/stabsread.c 2007-10-05 17:52:51.627875208 +0200
@@ -664,11 +664,11 @@ define_symbol (CORE_ADDR valu, char *str
/* 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 *str
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 *str
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;
diff -urNp gdb-orig/gdb/xcoffread.c gdb-head/gdb/xcoffread.c
--- gdb-orig/gdb/xcoffread.c 2007-10-05 14:54:56.000000000 +0200
+++ gdb-head/gdb/xcoffread.c 2007-10-05 17:52:51.636873912 +0200
@@ -2581,9 +2581,11 @@ scan_xcoff_symtab (struct objfile *objfi
{
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,
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com