summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog24
-rw-r--r--gdb/config/i386/tm-i386sol2.h4
-rw-r--r--gdb/config/sparc/tm-sol2.h8
-rw-r--r--gdb/dbxread.c8
-rw-r--r--gdb/gdbarch.c33
-rw-r--r--gdb/gdbarch.h8
-rwxr-xr-xgdb/gdbarch.sh3
-rw-r--r--gdb/i386-sol2-tdep.c26
-rw-r--r--gdb/i386-tdep.c26
-rw-r--r--gdb/mdebugread.c8
-rw-r--r--gdb/sparc-sol2-tdep.c36
-rw-r--r--gdb/sparc-tdep.c31
-rw-r--r--gdb/sparc-tdep.h2
-rw-r--r--gdb/sparc64-sol2-tdep.c5
-rw-r--r--gdb/stabsread.c28
-rw-r--r--gdb/xcoffread.c8
16 files changed, 169 insertions, 89 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2e66f039aa9..69491a26511 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,27 @@
+2007-10-19 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * 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.
+
2007-10-18 Daniel Jacobowitz <dan@codesourcery.com>
* mips-tdep.c (mips_xfer_register): Take a gdbarch argument.
diff --git a/gdb/config/i386/tm-i386sol2.h b/gdb/config/i386/tm-i386sol2.h
index af7649ced58..02f299ddb26 100644
--- a/gdb/config/i386/tm-i386sol2.h
+++ b/gdb/config/i386/tm-i386sol2.h
@@ -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 --git a/gdb/config/sparc/tm-sol2.h b/gdb/config/sparc/tm-sol2.h
index 2ed183ed5f5..28746afa002 100644
--- a/gdb/config/sparc/tm-sol2.h
+++ b/gdb/config/sparc/tm-sol2.h
@@ -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 --git a/gdb/dbxread.c b/gdb/dbxread.c
index d472d3e3c0d..a51fe9d757e 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -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 --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 8b51c022095..818e055d7f8 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -227,6 +227,7 @@ struct gdbarch
gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
gdbarch_overlay_update_ftype *overlay_update;
gdbarch_core_read_description_ftype *core_read_description;
+ gdbarch_static_transform_name_ftype *static_transform_name;
};
@@ -346,6 +347,7 @@ struct gdbarch startup_gdbarch =
0, /* skip_permanent_breakpoint */
0, /* overlay_update */
0, /* core_read_description */
+ 0, /* static_transform_name */
/* startup_gdbarch() */
};
@@ -590,6 +592,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of skip_permanent_breakpoint, has predicate */
/* Skip verify of overlay_update, has predicate */
/* Skip verify of core_read_description, has predicate */
+ /* Skip verify of static_transform_name, has predicate */
buf = ui_file_xstrdup (log, &dummy);
make_cleanup (xfree, buf);
if (strlen (buf) > 0)
@@ -984,6 +987,12 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
"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: target_desc = %s\n",
paddr_d ((long) current_gdbarch->target_desc));
fprintf_unfiltered (file,
@@ -2931,6 +2940,30 @@ set_gdbarch_core_read_description (struct gdbarch *gdbarch,
gdbarch->core_read_description = core_read_description;
}
+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 --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index b6824510295..412e74fd97a 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -664,6 +664,14 @@ typedef const struct target_desc * (gdbarch_core_read_description_ftype) (struct
extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
+/* 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 --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index a5f0a2a0609..965bd9b7c88 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -638,6 +638,9 @@ F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache
F::void:overlay_update:struct obj_section *osect:osect
M::const struct target_desc *:core_read_description:struct target_ops *target, bfd *abfd:target, abfd
+
+# Handle special encoding of static variables in stabs debug info.
+F::char *:static_transform_name:char *name:name
EOF
}
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index 0f7f8df9809..586ca963dd7 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -76,6 +76,29 @@ i386_sol2_mcontext_addr (struct frame_info *next_frame)
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 info, struct gdbarch *gdbarch)
/* 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 --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 48b03911e3c..58e1cf22df6 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2067,32 +2067,6 @@ i386_regset_from_core_section (struct gdbarch *gdbarch,
}
-#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 --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index c9cc2600398..3797287a682 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2999,9 +2999,11 @@ parse_partial_symbols (struct objfile *objfile)
{
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 --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
index fcfb5553c5c..bb04fd5f63b 100644
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -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;
+}
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);
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 6f2838546d9..734389229de 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1354,37 +1354,6 @@ sparc_write_pc (struct regcache *regcache, CORE_ADDR pc)
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 --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 3fd39339495..9e4f3e4c5ad 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -190,6 +190,8 @@ extern const struct sparc_gregset sparc32_sol2_gregset;
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 --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
index c885460e72d..5411b9bdff6 100644
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -157,6 +157,11 @@ sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
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 --git a/gdb/stabsread.c b/gdb/stabsread.c
index 929a856d3c4..fb031c71116 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -664,11 +664,11 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* 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 *string, int desc, int type,
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 *string, int desc, int type,
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 --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 49bf023679a..1aeddbc8d83 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2581,9 +2581,11 @@ scan_xcoff_symtab (struct objfile *objfile)
{
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,