[RFA/Ada] suppress internally-generated symbols from "info locals"
Joel Brobecker
brobecker@adacore.com
Mon Jan 14 05:36:00 GMT 2008
Hello,
A customer reported that he was seeing strange symbols sometimes when
using the "info locals" command. For instance:
(gdb) info locals
my_object = (prev => 0x0, next => 0x0, value => 42)
<F1b> = (access system.finalization_root.root_controlled) 0xbfcc94d0
This happens at -g3 only.
The second entity should not be visible to the user. We normally always
modify the compiler to stop generating debugging info for these entities,
but we also add guards against them when we easily can to improve the life
of our users who are stuck with an older compiler. In this case, the
machinery was already in place, so it was easy. I think we also have
other types of symbols that we need to suppress and yet need to be
defined in the debugging info (renames for instance), but I can't
construct a testcase that shows that.
We introduced a new language function (la_symbol_printing_suppressed),
and all languages except Ada have been set to never suppress any symbol.
Ada uses the already defined ada_suppress_symbol_printing. We also
defined a new SYMBOL_PRINTING_SUPPRESSED macro in symtab.h which is
a convenient shortcut more than a symtab macro. The testcase in
question also uncovered a bug in our ada-lang.c:is_suppressed_name
function, which Paul fixed.
Unfortunately, I cannot submit a testcase this time.
2008-01-13 Paul Hilfinger <hilfinger@adacore.com>
Joel Brobecker <brobecker@adacore.com>
* language.h (struct language_defn): Add new field
la_symbol_printing_suppressed.
(no_symbol_printing_suppressed): Add declaration.
* langauge.c (no_symbol_printing_suppressed): New function.
(unknown_language): Set la_symbol_printing_suppressed.
(auto_language, local_language): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* scm-lang.c (scm_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* f-lang.c (f_language_defn): Likewise.
* jv-lang.c (java_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
* c-lang.c (c_language_defn, cplus_language_defn, asm_language_defn)
(minimal_language_defn): Likewise.
* ada-lang.c (is_suppressed_name): Correct the loop so that it will
correctly handle cases where the first letter of an identifier is
capitalized.
(ada_language_defn): Set la_symbol_printing_suppressed to
ada_suppress_symbol_printing.
* symtab.h (SYMBOL_PRINTING_SUPPRESSED): New macro.
* stack.c (print_block_frame_locals): Do not print symbols that
should be suppressed.
Tested on x86-linux, no regression.
OK to commit?
Thanks,
--
Joel
-------------- next part --------------
Index: language.h
===================================================================
--- language.h (revision 124)
+++ language.h (revision 125)
@@ -268,6 +268,11 @@ struct language_defn
reference at the language level. */
int (*la_pass_by_reference) (struct type *type);
+ /* Return non-zero if SYMBOL represents an entity that is not
+ supposed to be seen by the user. To be used to filter symbols
+ during printing. */
+ int (*la_symbol_printing_suppressed) (struct symbol *symbol);
+
/* Add fields above this point, so the magic number is always last. */
/* Magic number for compat checking */
@@ -470,4 +475,9 @@ int language_pass_by_reference (struct t
independent of this. */
int default_pass_by_reference (struct type *type);
+/* Always return zero. This function can be used by languages
+ that do not have any symbol that should be filtered out during
+ symbol printing. */
+int no_symbol_printing_suppressed (struct symbol *symbol);
+
#endif /* defined (LANGUAGE_H) */
Index: language.c
===================================================================
--- language.c (revision 124)
+++ language.c (revision 125)
@@ -1205,6 +1205,7 @@ const struct language_defn unknown_langu
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -1241,6 +1242,7 @@ const struct language_defn auto_language
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -1276,6 +1278,7 @@ const struct language_defn local_languag
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -1334,6 +1337,12 @@ language_lookup_primitive_type_by_name (
return (NULL);
}
+int
+no_symbol_printing_suppressed (struct symbol *symbol)
+{
+ return 0;
+}
+
/* Initialize the language routines */
void
Index: objc-lang.c
===================================================================
--- objc-lang.c (revision 124)
+++ objc-lang.c (revision 125)
@@ -521,6 +521,7 @@ const struct language_defn objc_language
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: scm-lang.c
===================================================================
--- scm-lang.c (revision 124)
+++ scm-lang.c (revision 125)
@@ -266,6 +266,7 @@ const struct language_defn scm_language_
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: m2-lang.c
===================================================================
--- m2-lang.c (revision 124)
+++ m2-lang.c (revision 125)
@@ -388,6 +388,7 @@ const struct language_defn m2_language_d
m2_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: f-lang.c
===================================================================
--- f-lang.c (revision 124)
+++ f-lang.c (revision 125)
@@ -337,6 +337,7 @@ const struct language_defn f_language_de
f_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: jv-lang.c
===================================================================
--- jv-lang.c (revision 124)
+++ jv-lang.c (revision 125)
@@ -1083,6 +1083,7 @@ const struct language_defn java_language
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: p-lang.c
===================================================================
--- p-lang.c (revision 124)
+++ p-lang.c (revision 125)
@@ -427,6 +427,7 @@ const struct language_defn pascal_langua
pascal_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: c-lang.c
===================================================================
--- c-lang.c (revision 124)
+++ c-lang.c (revision 125)
@@ -427,6 +427,7 @@ const struct language_defn c_language_de
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -540,6 +541,7 @@ const struct language_defn cplus_languag
cplus_language_arch_info,
default_print_array_index,
cp_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -575,6 +577,7 @@ const struct language_defn asm_language_
c_language_arch_info, /* FIXME: la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
@@ -615,6 +618,7 @@ const struct language_defn minimal_langu
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
+ no_symbol_printing_suppressed,
LANG_MAGIC
};
Index: ada-lang.c
===================================================================
--- ada-lang.c (revision 124)
+++ ada-lang.c (revision 125)
@@ -844,16 +844,16 @@ is_suppressed_name (const char *str)
return 1;
if (suffix == NULL)
suffix = str + strlen (str);
- for (p = suffix - 1; p != str; p -= 1)
- if (isupper (*p))
+ for (p = suffix; p != str; p -= 1)
+ if (isupper (p[-1]))
{
int i;
- if (p[0] == 'X' && p[-1] != '_')
+ if (p-1 != str && p[-1] == 'X' && p[-2] != '_')
goto OK;
- if (*p != 'O')
+ if (p[-1] != 'O')
return 1;
for (i = 0; ada_opname_table[i].encoded != NULL; i += 1)
- if (strncmp (ada_opname_table[i].encoded, p,
+ if (strncmp (ada_opname_table[i].encoded, p-1,
strlen (ada_opname_table[i].encoded)) == 0)
goto OK;
return 1;
@@ -11860,6 +11860,7 @@ const struct language_defn ada_language_
ada_language_arch_info,
ada_print_array_index,
default_pass_by_reference,
+ ada_suppress_symbol_printing,
LANG_MAGIC
};
Index: symtab.h
===================================================================
--- symtab.h (revision 124)
+++ symtab.h (revision 125)
@@ -270,6 +270,12 @@ extern char *symbol_search_name (const s
#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name) \
(strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
+/* Macro that returns non-zero if the symbol should be filtered out
+ when doing symbol printing. */
+
+#define SYMBOL_PRINTING_SUPPRESSED(sym) \
+ (language_def (SYMBOL_LANGUAGE (sym))->la_symbol_printing_suppressed (sym))
+
/* Classification types for a minimal symbol. These should be taken as
"advisory only", since if gdb can't easily figure out a
classification it simply selects mst_unknown. It may also have to
Index: stack.c
===================================================================
--- stack.c (revision 124)
+++ stack.c (revision 125)
@@ -1370,6 +1370,9 @@ print_block_frame_locals (struct block *
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
+ if (SYMBOL_PRINTING_SUPPRESSED (sym))
+ continue;
+
switch (SYMBOL_CLASS (sym))
{
case LOC_LOCAL:
More information about the Gdb-patches
mailing list