[PATCH] missing scoping in dbxout
Matthias Riese
mri@megatel.de
Sun Apr 30 23:04:00 GMT 2000
Hi!
dbxout.c doesn't always output the scope of types. Patch appended.
Best regards,
Matthias Riese
diff -Nur gcc-2.95.2-vanilla/gcc/dbxout.c gcc-2.95.2/gcc/dbxout.c
--- gcc-2.95.2-vanilla/gcc/dbxout.c Sat Apr 8 09:21:28 2000
+++ gcc-2.95.2/gcc/dbxout.c Sat Apr 8 09:19:45 2000
@@ -1668,6 +1668,31 @@
CHARS (IDENTIFIER_LENGTH (t));
}
+/* Create a scoped name from decl and context. */
+static int dbxout_context(decl)
+ tree decl;
+{
+ int i = 0;
+ const char *name;
+
+ if(!decl)
+ {
+ return i;
+ }
+ if(TYPE_P(decl))
+ {
+ return dbxout_context(TYPE_NAME(decl));
+ }
+ else if (!DECL_P(decl))
+ {
+ return i;
+ }
+ i = dbxout_context(DECL_CONTEXT(decl));
+ name = IDENTIFIER_POINTER(DECL_NAME(decl));
+ i += fprintf (asmfile, i ? "::%s" : name, name);
+ return i;
+}
+
/* Output a .stabs for the symbol defined by DECL,
which must be a ..._DECL node in the normal namespace.
It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
@@ -1694,8 +1719,8 @@
dbxout_prepare_symbol (decl);
- /* The output will always start with the symbol name,
- so always count that in the length-output-so-far. */
+ /* The output for FUNCTION_DECL and VAR_DECL will start with this
+ symbol name, so count that in the length-output-so-far here. */
if (DECL_NAME (decl) != 0)
current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
@@ -1786,24 +1811,21 @@
from explicit ones that might be found in C. */
&& DECL_ARTIFICIAL (decl))
{
- tree name = TYPE_NAME (type);
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
current_sym_code = DBX_TYPE_DECL_STABS_CODE;
current_sym_value = 0;
current_sym_addr = 0;
- current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
- fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
- IDENTIFIER_POINTER (name));
+ fprintf (asmfile, "%s \"", ASM_STABS_OP);
+ current_sym_nchars = 2 + dbxout_context(decl);
+ fprintf (asmfile, ":T");
dbxout_type (type, 1, 0);
dbxout_finish_symbol (NULL_TREE);
}
/* Output typedef name. */
- fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
- IDENTIFIER_POINTER (DECL_NAME (decl)));
+ fprintf (asmfile, "%s \"", ASM_STABS_OP);
+ current_sym_nchars = 2 + dbxout_context(decl);
+ fprintf (asmfile, ":");
/* Short cut way to output a tag also. */
if ((TREE_CODE (type) == RECORD_TYPE
@@ -1848,16 +1870,23 @@
/* In C++, the name of a type is the corresponding typedef.
In C, it is an IDENTIFIER_NODE. */
tree name = TYPE_NAME (type);
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
current_sym_code = DBX_TYPE_DECL_STABS_CODE;
current_sym_value = 0;
current_sym_addr = 0;
- current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
- fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
- IDENTIFIER_POINTER (name));
+ if (TREE_CODE (name) == TYPE_DECL)
+ {
+ fprintf (asmfile, "%s \"", ASM_STABS_OP);
+ current_sym_nchars = 2 + dbxout_context(name);
+ fprintf (asmfile, ":T");
+ }
+ else
+ {
+ current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
+ fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
+ IDENTIFIER_POINTER (name));
+ }
dbxout_type (type, 1, 0);
dbxout_finish_symbol (NULL_TREE);
did_output = 1;
More information about the Gcc-bugs
mailing list