mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 20:14:06 +08:00
Remove find_old_style_renaming_symbol
We found a case where a "bt" was very slow with Ada code. Profiling with callgrind showed this to be primarily due to calls to find_old_style_renaming_symbol. Because new-style renaming symbols were implemented in 2007, it seems safe enough to remove this old code. A "-batch -ex bt" test on a large Ada program improves from: 13.23user 0.57system 0:13.82elapsed 99%CPU (0avgtext+0avgdata 571408maxresident)k to 4.25user 0.48system 0:04.74elapsed 99%CPU (0avgtext+0avgdata 559844maxresident)k with this patch. Tested on x86-64 Fedora 29. Joel reviewed this internally; and as it is Ada-specific, I am checking it in. gdb/ChangeLog 2019-05-28 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_remove_Xbn_suffix) (find_old_style_renaming_symbol) (parse_old_style_renaming): Remove. (ada_find_renaming_symbol): Don't call find_old_style_renaming_symbol. (ada_is_renaming_symbol): Rename from ada_find_renaming_symbol. Remove "block" parameter. Return bool. Now static. (ada_read_var_value): Update and simplify. * ada-exp.y (write_var_or_type): Remove old code.
This commit is contained in:
parent
88981b157b
commit
c0e70c624f
@ -1,3 +1,16 @@
|
||||
2019-05-28 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* ada-lang.c (ada_remove_Xbn_suffix)
|
||||
(find_old_style_renaming_symbol)
|
||||
(parse_old_style_renaming): Remove.
|
||||
(ada_find_renaming_symbol): Don't call
|
||||
find_old_style_renaming_symbol.
|
||||
(ada_is_renaming_symbol): Rename from
|
||||
ada_find_renaming_symbol. Remove "block" parameter. Return
|
||||
bool. Now static.
|
||||
(ada_read_var_value): Update and simplify.
|
||||
* ada-exp.y (write_var_or_type): Remove old code.
|
||||
|
||||
2019-05-28 Alan Hayward <alan.hayward@arm.com>
|
||||
|
||||
* event-top.c: Remove include comment.
|
||||
|
@ -1229,19 +1229,6 @@ write_var_or_type (struct parser_state *par_state,
|
||||
VAR_DOMAIN, &syms);
|
||||
encoded_name[tail_index] = terminator;
|
||||
|
||||
/* A single symbol may rename a package or object. */
|
||||
|
||||
/* This should go away when we move entirely to new version.
|
||||
FIXME pnh 7/20/2007. */
|
||||
if (nsyms == 1)
|
||||
{
|
||||
struct symbol *ren_sym =
|
||||
ada_find_renaming_symbol (syms[0].symbol, syms[0].block);
|
||||
|
||||
if (ren_sym != NULL)
|
||||
syms[0].symbol = ren_sym;
|
||||
}
|
||||
|
||||
type_sym = select_possible_type_sym (syms);
|
||||
|
||||
if (type_sym != NULL)
|
||||
|
180
gdb/ada-lang.c
180
gdb/ada-lang.c
@ -146,14 +146,6 @@ static int scalar_type_p (struct type *);
|
||||
|
||||
static int discrete_type_p (struct type *);
|
||||
|
||||
static enum ada_renaming_category parse_old_style_renaming (struct type *,
|
||||
const char **,
|
||||
int *,
|
||||
const char **);
|
||||
|
||||
static struct symbol *find_old_style_renaming_symbol (const char *,
|
||||
const struct block *);
|
||||
|
||||
static struct type *ada_lookup_struct_elt_type (struct type *, const char *,
|
||||
int, int);
|
||||
|
||||
@ -1112,26 +1104,6 @@ ada_remove_po_subprogram_suffix (const char *encoded, int *len)
|
||||
*len = *len - 1;
|
||||
}
|
||||
|
||||
/* Remove trailing X[bn]* suffixes (indicating names in package bodies). */
|
||||
|
||||
static void
|
||||
ada_remove_Xbn_suffix (const char *encoded, int *len)
|
||||
{
|
||||
int i = *len - 1;
|
||||
|
||||
while (i > 0 && (encoded[i] == 'b' || encoded[i] == 'n'))
|
||||
i--;
|
||||
|
||||
if (encoded[i] != 'X')
|
||||
return;
|
||||
|
||||
if (i == 0)
|
||||
return;
|
||||
|
||||
if (isalnum (encoded[i-1]))
|
||||
*len = i;
|
||||
}
|
||||
|
||||
/* If ENCODED follows the GNAT entity encoding conventions, then return
|
||||
the decoded form of ENCODED. Otherwise, return "<%s>" where "%s" is
|
||||
replaced by ENCODED.
|
||||
@ -4301,9 +4273,6 @@ ada_parse_renaming (struct symbol *sym,
|
||||
{
|
||||
default:
|
||||
return ADA_NOT_RENAMING;
|
||||
case LOC_TYPEDEF:
|
||||
return parse_old_style_renaming (SYMBOL_TYPE (sym),
|
||||
renamed_entity, len, renaming_expr);
|
||||
case LOC_LOCAL:
|
||||
case LOC_STATIC:
|
||||
case LOC_COMPUTED:
|
||||
@ -4347,65 +4316,6 @@ ada_parse_renaming (struct symbol *sym,
|
||||
return kind;
|
||||
}
|
||||
|
||||
/* Assuming TYPE encodes a renaming according to the old encoding in
|
||||
exp_dbug.ads, returns details of that renaming in *RENAMED_ENTITY,
|
||||
*LEN, and *RENAMING_EXPR, as for ada_parse_renaming, above. Returns
|
||||
ADA_NOT_RENAMING otherwise. */
|
||||
static enum ada_renaming_category
|
||||
parse_old_style_renaming (struct type *type,
|
||||
const char **renamed_entity, int *len,
|
||||
const char **renaming_expr)
|
||||
{
|
||||
enum ada_renaming_category kind;
|
||||
const char *name;
|
||||
const char *info;
|
||||
const char *suffix;
|
||||
|
||||
if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM
|
||||
|| TYPE_NFIELDS (type) != 1)
|
||||
return ADA_NOT_RENAMING;
|
||||
|
||||
name = TYPE_NAME (type);
|
||||
if (name == NULL)
|
||||
return ADA_NOT_RENAMING;
|
||||
|
||||
name = strstr (name, "___XR");
|
||||
if (name == NULL)
|
||||
return ADA_NOT_RENAMING;
|
||||
switch (name[5])
|
||||
{
|
||||
case '\0':
|
||||
case '_':
|
||||
kind = ADA_OBJECT_RENAMING;
|
||||
break;
|
||||
case 'E':
|
||||
kind = ADA_EXCEPTION_RENAMING;
|
||||
break;
|
||||
case 'P':
|
||||
kind = ADA_PACKAGE_RENAMING;
|
||||
break;
|
||||
case 'S':
|
||||
kind = ADA_SUBPROGRAM_RENAMING;
|
||||
break;
|
||||
default:
|
||||
return ADA_NOT_RENAMING;
|
||||
}
|
||||
|
||||
info = TYPE_FIELD_NAME (type, 0);
|
||||
if (info == NULL)
|
||||
return ADA_NOT_RENAMING;
|
||||
if (renamed_entity != NULL)
|
||||
*renamed_entity = info;
|
||||
suffix = strstr (info, "___XE");
|
||||
if (renaming_expr != NULL)
|
||||
*renaming_expr = suffix + 5;
|
||||
if (suffix == NULL || suffix == info)
|
||||
return ADA_NOT_RENAMING;
|
||||
if (len != NULL)
|
||||
*len = suffix - info;
|
||||
return kind;
|
||||
}
|
||||
|
||||
/* Compute the value of the given RENAMING_SYM, which is expected to
|
||||
be a symbol encoding a renaming expression. BLOCK is the block
|
||||
used to evaluate the renaming. */
|
||||
@ -7986,80 +7896,11 @@ ada_find_any_type (const char *name)
|
||||
symbols whose name is that of NAME_SYM suffixed with "___XR".
|
||||
Return symbol if found, and NULL otherwise. */
|
||||
|
||||
struct symbol *
|
||||
ada_find_renaming_symbol (struct symbol *name_sym, const struct block *block)
|
||||
static bool
|
||||
ada_is_renaming_symbol (struct symbol *name_sym)
|
||||
{
|
||||
const char *name = SYMBOL_LINKAGE_NAME (name_sym);
|
||||
struct symbol *sym;
|
||||
|
||||
if (strstr (name, "___XR") != NULL)
|
||||
return name_sym;
|
||||
|
||||
sym = find_old_style_renaming_symbol (name, block);
|
||||
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
|
||||
/* Not right yet. FIXME pnh 7/20/2007. */
|
||||
sym = ada_find_any_type_symbol (name);
|
||||
if (sym != NULL && strstr (SYMBOL_LINKAGE_NAME (sym), "___XR") != NULL)
|
||||
return sym;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct symbol *
|
||||
find_old_style_renaming_symbol (const char *name, const struct block *block)
|
||||
{
|
||||
const struct symbol *function_sym = block_linkage_function (block);
|
||||
char *rename;
|
||||
|
||||
if (function_sym != NULL)
|
||||
{
|
||||
/* If the symbol is defined inside a function, NAME is not fully
|
||||
qualified. This means we need to prepend the function name
|
||||
as well as adding the ``___XR'' suffix to build the name of
|
||||
the associated renaming symbol. */
|
||||
const char *function_name = SYMBOL_LINKAGE_NAME (function_sym);
|
||||
/* Function names sometimes contain suffixes used
|
||||
for instance to qualify nested subprograms. When building
|
||||
the XR type name, we need to make sure that this suffix is
|
||||
not included. So do not include any suffix in the function
|
||||
name length below. */
|
||||
int function_name_len = ada_name_prefix_len (function_name);
|
||||
const int rename_len = function_name_len + 2 /* "__" */
|
||||
+ strlen (name) + 6 /* "___XR\0" */ ;
|
||||
|
||||
/* Strip the suffix if necessary. */
|
||||
ada_remove_trailing_digits (function_name, &function_name_len);
|
||||
ada_remove_po_subprogram_suffix (function_name, &function_name_len);
|
||||
ada_remove_Xbn_suffix (function_name, &function_name_len);
|
||||
|
||||
/* Library-level functions are a special case, as GNAT adds
|
||||
a ``_ada_'' prefix to the function name to avoid namespace
|
||||
pollution. However, the renaming symbols themselves do not
|
||||
have this prefix, so we need to skip this prefix if present. */
|
||||
if (function_name_len > 5 /* "_ada_" */
|
||||
&& strstr (function_name, "_ada_") == function_name)
|
||||
{
|
||||
function_name += 5;
|
||||
function_name_len -= 5;
|
||||
}
|
||||
|
||||
rename = (char *) alloca (rename_len * sizeof (char));
|
||||
strncpy (rename, function_name, function_name_len);
|
||||
xsnprintf (rename + function_name_len, rename_len - function_name_len,
|
||||
"__%s___XR", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rename_len = strlen (name) + 6;
|
||||
|
||||
rename = (char *) alloca (rename_len * sizeof (char));
|
||||
xsnprintf (rename, rename_len * sizeof (char), "%s___XR", name);
|
||||
}
|
||||
|
||||
return ada_find_any_type_symbol (rename);
|
||||
return strstr (name, "___XR") != NULL;
|
||||
}
|
||||
|
||||
/* Because of GNAT encoding conventions, several GDB symbols may match a
|
||||
@ -14375,17 +14216,14 @@ static struct value *
|
||||
ada_read_var_value (struct symbol *var, const struct block *var_block,
|
||||
struct frame_info *frame)
|
||||
{
|
||||
const struct block *frame_block = NULL;
|
||||
struct symbol *renaming_sym = NULL;
|
||||
|
||||
/* The only case where default_read_var_value is not sufficient
|
||||
is when VAR is a renaming... */
|
||||
if (frame)
|
||||
frame_block = get_frame_block (frame, NULL);
|
||||
if (frame_block)
|
||||
renaming_sym = ada_find_renaming_symbol (var, frame_block);
|
||||
if (renaming_sym != NULL)
|
||||
return ada_read_renaming_var_value (renaming_sym, frame_block);
|
||||
if (frame != nullptr)
|
||||
{
|
||||
const struct block *frame_block = get_frame_block (frame, NULL);
|
||||
if (frame_block != nullptr && ada_is_renaming_symbol (var))
|
||||
return ada_read_renaming_var_value (var, frame_block);
|
||||
}
|
||||
|
||||
/* This is a typical case where we expect the default_read_var_value
|
||||
function to work. */
|
||||
|
@ -343,9 +343,6 @@ extern struct type *ada_find_parallel_type (struct type *,
|
||||
|
||||
extern bool get_int_var_value (const char *, LONGEST &value);
|
||||
|
||||
extern struct symbol *ada_find_renaming_symbol (struct symbol *name_sym,
|
||||
const struct block *block);
|
||||
|
||||
extern int ada_prefer_type (struct type *, struct type *);
|
||||
|
||||
extern struct type *ada_get_base_type (struct type *);
|
||||
|
Loading…
Reference in New Issue
Block a user