[rfa] Add SYMBOL_SET_LINKAGE_NAME

Daniel Jacobowitz
2004-02-16T21:24:08Z

This patch adds a macro, SYMBOL_SET_LINKAGE_NAME, which is used to set
a symbol's name when the name should not be demangled. Used for things
like typedefs whose name comes from debug info. I did not change
anything related to memory allocation when I did this - though in
hpread I found a few inconsistencies.

After this patch and my others from today there are no direct
assignments to the symbol name. In addition to the cleanup value, I'm
testing an approach which would change the storage of symbol names,
which prompted me to do this. This patch has a trivial dependency on
the previous hpread patch (introduction of a local variable in
hpread_process_one_debug_symbol) but otherwise they can be applied in
any order.

OK?

--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer

2004-02-16 Daniel Jacobowitz <drow@mvista.com>

* symtab.h (SYMBOL_SET_LINKAGE_NAME): Define.

* ada-lang.c (add_symbols_from_enclosing_procs): Use
SYMBOL_SET_LINKAGE_NAME.
* dwarfread.c (enum_type, synthesize_typedef): Likewise.
* jv-lang.c (add_class_symbol): Likewise.
* stabsread.c (patch_block_stabs, define_symbol, read_enum_type)
(common_block_end): Likewise.
* xcoffread.c (process_xcoff_symbol): Likewise.
* hpread.c (hpread_read_enum_type, hpread_read_function_type)
(hpread_read_doc_function_type): Use SYMBOL_SET_LINKAGE_NAME.
(hpread_process_one_debug_symbol): Likewise.

--- hpread.c 7 Feb 2004 23:13:47 -0000 1.45
+++ hpread.c 15 Feb 2004 23:56:30 -0000
@@ -5101,7 +5098,8 @@ hpread_process_one_debug_symbol (union d
sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
- DEPRECATED_SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->objfile_obstack);
+ set_name = obsavestring (name, strlen (name), &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym, set_name);
SYMBOL_LANGUAGE (sym) = language_auto;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_LINE (sym) = 0;
@@ -5889,7 +5867,7 @@ hpread_process_one_debug_symbol (union d
newsym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
memset (newsym, 0, sizeof (struct symbol));
- DEPRECATED_SYMBOL_NAME (newsym) = name;
+ SYMBOL_SET_LINKAGE_NAME (newsym, name);
SYMBOL_LANGUAGE (newsym) = language_auto;
SYMBOL_DOMAIN (newsym) = VAR_DOMAIN;
SYMBOL_LINE (newsym) = 0;
--- ada-lang.c 23 Jan 2004 23:03:28 -0000 1.35
+++ ada-lang.c 15 Feb 2004 23:56:24 -0000
@@ -3533,7 +3533,7 @@ add_symbols_from_enclosing_procs (const
/* Initialize the local variable symbol that stands for the
* static link (when it exists). */
static_link = &static_link_sym;
- DEPRECATED_SYMBOL_NAME (static_link) = "";
+ SYMBOL_SET_LINKAGE_NAME (static_link, "");
SYMBOL_LANGUAGE (static_link) = language_unknown;
SYMBOL_CLASS (static_link) = LOC_LOCAL;
SYMBOL_DOMAIN (static_link) = VAR_DOMAIN;
--- jv-lang.c 7 Feb 2004 23:13:47 -0000 1.29
+++ jv-lang.c 15 Feb 2004 23:56:30 -0000
@@ -142,7 +142,7 @@ add_class_symbol (struct type *type, COR
obstack_alloc (&dynamics_objfile->objfile_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_LANGUAGE (sym) = language_java;
- DEPRECATED_SYMBOL_NAME (sym) = TYPE_TAG_NAME (type);
+ SYMBOL_SET_LINKAGE_NAME (sym, TYPE_TAG_NAME (type));
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
/* SYMBOL_VALUE (sym) = valu; */
SYMBOL_TYPE (sym) = type;
--- stabsread.c 7 Feb 2004 23:13:47 -0000 1.74
+++ stabsread.c 15 Feb 2004 23:56:34 -0000
@@ -367,6 +367,8 @@ patch_block_stabs (struct pending *symbo
sym = find_symbol_in_list (symbols, name, pp - name);
if (!sym)
{
+ char *sym_name;
+
/* FIXME-maybe: it would be nice if we noticed whether
the variable was defined *anywhere*, not just whether
it is defined in this compilation unit. But neither
@@ -385,8 +387,9 @@ patch_block_stabs (struct pending *symbo
memset (sym, 0, sizeof (struct symbol));
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
- DEPRECATED_SYMBOL_NAME (sym) =
- obsavestring (name, pp - name, &objfile->objfile_obstack);
+ sym_name = obsavestring (name, pp - name,
+ &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym, sym_name);
pp += 2;
if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
{
@@ -641,12 +644,15 @@ define_symbol (CORE_ADDR valu, char *str

if (is_cplus_marker (string[0]))
{
+ char *sym_name;
+
/* Special GNU C++ names. */
switch (string[1])
{
case 't':
- DEPRECATED_SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
- &objfile->objfile_obstack);
+ sym_name = obsavestring ("this", strlen ("this"),
+ &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym, sym_name);
break;

case 'v': /* $vtbl_ptr_type */
@@ -654,8 +660,9 @@ define_symbol (CORE_ADDR valu, char *str
goto normal;

case 'e':
- DEPRECATED_SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
- &objfile->objfile_obstack);
+ sym_name = obsavestring ("eh_throw", strlen ("eh_throw"),
+ &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym, sym_name);
break;

case '_':
@@ -1130,13 +1137,15 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
#ifdef STATIC_TRANSFORM_NAME
- if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
+ if (IS_STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym)))
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, objfile);
if (msym != NULL)
{
- DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+ char *sym_name
+ = STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym));
+ SYMBOL_SET_LINKAGE_NAME (sym, sym_name);
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
}
@@ -1276,13 +1285,16 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
#ifdef STATIC_TRANSFORM_NAME
- if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
+ }
+ if (IS_STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym)))
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, objfile);
if (msym != NULL)
{
- DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+ char *sym_name
+ = STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym));
+ SYMBOL_SET_LINKAGE_NAME (sym, sym_name);
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
}
@@ -3493,7 +3505,7 @@ read_enum_type (char **pp, struct type *
sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
- DEPRECATED_SYMBOL_NAME (sym) = name;
+ SYMBOL_SET_LINKAGE_NAME (sym, name);
SYMBOL_LANGUAGE (sym) = current_subfile->language;
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -4068,7 +4080,7 @@ common_block_end (struct objfile *objfil
obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
/* Note: common_block_name already saved on objfile_obstack */
- DEPRECATED_SYMBOL_NAME (sym) = common_block_name;
+ SYMBOL_SET_LINKAGE_NAME (sym, common_block_name);
SYMBOL_CLASS (sym) = LOC_BLOCK;

/* Now we copy all the symbols which have been defined since the BCOMM. */
--- dwarfread.c 14 Feb 2004 15:46:32 -0000 1.37
+++ dwarfread.c 15 Feb 2004 23:56:27 -0000
@@ -1710,8 +1710,9 @@ enum_type (struct dieinfo *dip, struct o
sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
- DEPRECATED_SYMBOL_NAME (sym) = create_name (list->field.name,
- &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym,
+ create_name (list->field.name,
+ &objfile->objfile_obstack));
SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_CLASS (sym) = LOC_CONST;
@@ -3013,8 +3014,8 @@ synthesize_typedef (struct dieinfo *dip,
obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
OBJSTAT (objfile, n_syms++);
memset (sym, 0, sizeof (struct symbol));
- DEPRECATED_SYMBOL_NAME (sym) = create_name (dip->at_name,
- &objfile->objfile_obstack);
+ SYMBOL_SET_LINKAGE_NAME (sym, create_name (dip->at_name,
+ &objfile->objfile_obstack));
SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
SYMBOL_TYPE (sym) = type;
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
--- symtab.h 7 Feb 2004 23:13:47 -0000 1.87
+++ symtab.h 15 Feb 2004 23:56:37 -0000
@@ -195,6 +195,11 @@ extern void symbol_set_names (struct gen
const char *linkage_name, int len,
struct objfile *objfile);

+#define SYMBOL_SET_LINKAGE_NAME(symbol,linkage_name) \
+ do { \
+ (symbol)->ginfo.name = (linkage_name); \
+ } while (0)
+
/* Now come lots of name accessor macros. Short version as to when to
use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
symbol in the original source code. Use SYMBOL_LINKAGE_NAME if you
--- xcoffread.c 14 Feb 2004 15:46:33 -0000 1.40
+++ xcoffread.c 15 Feb 2004 23:56:38 -0000
@@ -1477,7 +1477,8 @@ process_xcoff_symbol (struct coff_symbol
will be patched with the type from its stab entry later on in
patch_block_stabs (), unless the file was compiled without -g. */

- DEPRECATED_SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
+ SYMBOL_SET_LINKAGE_NAME (sym,
+ SYMNAME_ALLOC (name, symname_alloced));
SYMBOL_TYPE (sym) = func_symbol_type;

SYMBOL_CLASS (sym) = LOC_BLOCK;