* valops.c (value_of_this): Use lookup_language_this.
* symtab.h (lookup_language_this): Declare. * symtab.c (lookup_language_this): New function. (lookup_symbol_aux): Use lookup_language_this. * ax-gdb.c (gen_expr) <OP_THIS>: Use lookup_language_this.
This commit is contained in:
parent
7518bff55a
commit
66a17cb629
|
@ -1,3 +1,11 @@
|
||||||
|
2011-06-17 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* valops.c (value_of_this): Use lookup_language_this.
|
||||||
|
* symtab.h (lookup_language_this): Declare.
|
||||||
|
* symtab.c (lookup_language_this): New function.
|
||||||
|
(lookup_symbol_aux): Use lookup_language_this.
|
||||||
|
* ax-gdb.c (gen_expr) <OP_THIS>: Use lookup_language_this.
|
||||||
|
|
||||||
2011-06-17 Tom Tromey <tromey@redhat.com>
|
2011-06-17 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* value.h (value_of_this): Update.
|
* value.h (value_of_this): Update.
|
||||||
|
|
15
gdb/ax-gdb.c
15
gdb/ax-gdb.c
|
@ -2138,18 +2138,17 @@ gen_expr (struct expression *exp, union exp_element **pc,
|
||||||
case OP_THIS:
|
case OP_THIS:
|
||||||
{
|
{
|
||||||
char *this_name;
|
char *this_name;
|
||||||
struct symbol *func, *sym;
|
struct symbol *sym, *func;
|
||||||
struct block *b;
|
struct block *b;
|
||||||
|
const struct language_defn *lang;
|
||||||
|
|
||||||
func = block_linkage_function (block_for_pc (ax->scope));
|
b = block_for_pc (ax->scope);
|
||||||
this_name = language_def (SYMBOL_LANGUAGE (func))->la_name_of_this;
|
func = block_linkage_function (b);
|
||||||
b = SYMBOL_BLOCK_VALUE (func);
|
lang = language_def (SYMBOL_LANGUAGE (func));
|
||||||
|
|
||||||
/* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
|
sym = lookup_language_this (lang, b);
|
||||||
symbol instead of the LOC_ARG one (if both exist). */
|
|
||||||
sym = lookup_block_symbol (b, this_name, VAR_DOMAIN);
|
|
||||||
if (!sym)
|
if (!sym)
|
||||||
error (_("no `%s' found"), this_name);
|
error (_("no `%s' found"), lang->la_name_of_this);
|
||||||
|
|
||||||
gen_var_ref (exp->gdbarch, ax, value, sym);
|
gen_var_ref (exp->gdbarch, ax, value, sym);
|
||||||
|
|
||||||
|
|
37
gdb/symtab.c
37
gdb/symtab.c
|
@ -1090,6 +1090,29 @@ lookup_symbol (const char *name, const struct block *block,
|
||||||
is_a_field_of_this);
|
is_a_field_of_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
|
||||||
|
found, or NULL if not found. */
|
||||||
|
|
||||||
|
struct symbol *
|
||||||
|
lookup_language_this (const struct language_defn *lang,
|
||||||
|
const struct block *block)
|
||||||
|
{
|
||||||
|
if (lang->la_name_of_this == NULL || block == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
struct symbol *sym;
|
||||||
|
|
||||||
|
sym = lookup_block_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
|
||||||
|
if (sym != NULL)
|
||||||
|
return sym;
|
||||||
|
if (BLOCK_FUNCTION (block))
|
||||||
|
return NULL;
|
||||||
|
block = BLOCK_SUPERBLOCK (block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Behave like lookup_symbol except that NAME is the natural name
|
/* Behave like lookup_symbol except that NAME is the natural name
|
||||||
of the symbol that we're looking for and, if LINKAGE_NAME is
|
of the symbol that we're looking for and, if LINKAGE_NAME is
|
||||||
non-NULL, ensure that the symbol's linkage name matches as
|
non-NULL, ensure that the symbol's linkage name matches as
|
||||||
|
@ -1123,20 +1146,10 @@ lookup_symbol_aux (const char *name, const struct block *block,
|
||||||
|
|
||||||
langdef = language_def (language);
|
langdef = language_def (language);
|
||||||
|
|
||||||
if (langdef->la_name_of_this != NULL && is_a_field_of_this != NULL
|
if (is_a_field_of_this != NULL)
|
||||||
&& block != NULL)
|
|
||||||
{
|
{
|
||||||
struct symbol *sym = NULL;
|
struct symbol *sym = lookup_language_this (langdef, block);
|
||||||
const struct block *function_block = block;
|
|
||||||
|
|
||||||
/* 'this' is only defined in the function's block, so find the
|
|
||||||
enclosing function block. */
|
|
||||||
for (; function_block && !BLOCK_FUNCTION (function_block);
|
|
||||||
function_block = BLOCK_SUPERBLOCK (function_block));
|
|
||||||
|
|
||||||
if (function_block && !dict_empty (BLOCK_DICT (function_block)))
|
|
||||||
sym = lookup_block_symbol (function_block, langdef->la_name_of_this,
|
|
||||||
VAR_DOMAIN);
|
|
||||||
if (sym)
|
if (sym)
|
||||||
{
|
{
|
||||||
struct type *t = sym->type;
|
struct type *t = sym->type;
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct blockvector;
|
||||||
struct axs_value;
|
struct axs_value;
|
||||||
struct agent_expr;
|
struct agent_expr;
|
||||||
struct program_space;
|
struct program_space;
|
||||||
|
struct language_defn;
|
||||||
|
|
||||||
/* Some of the structures in this file are space critical.
|
/* Some of the structures in this file are space critical.
|
||||||
The space-critical structures are:
|
The space-critical structures are:
|
||||||
|
@ -917,6 +918,9 @@ extern struct symbol *lookup_symbol_aux_block (const char *name,
|
||||||
const struct block *block,
|
const struct block *block,
|
||||||
const domain_enum domain);
|
const domain_enum domain);
|
||||||
|
|
||||||
|
extern struct symbol *lookup_language_this (const struct language_defn *lang,
|
||||||
|
const struct block *block);
|
||||||
|
|
||||||
/* Lookup a symbol only in the file static scope of all the objfiles. */
|
/* Lookup a symbol only in the file static scope of all the objfiles. */
|
||||||
|
|
||||||
struct symbol *lookup_static_symbol_aux (const char *name,
|
struct symbol *lookup_static_symbol_aux (const char *name,
|
||||||
|
|
31
gdb/valops.c
31
gdb/valops.c
|
@ -3603,13 +3603,12 @@ value_full_object (struct value *argp,
|
||||||
struct value *
|
struct value *
|
||||||
value_of_this (const struct language_defn *lang, int complain)
|
value_of_this (const struct language_defn *lang, int complain)
|
||||||
{
|
{
|
||||||
struct symbol *func, *sym;
|
struct symbol *sym;
|
||||||
struct block *b;
|
struct block *b;
|
||||||
struct value * ret;
|
struct value * ret;
|
||||||
struct frame_info *frame;
|
struct frame_info *frame;
|
||||||
const char *name = lang->la_name_of_this;
|
|
||||||
|
|
||||||
if (!name)
|
if (!lang->la_name_of_this)
|
||||||
{
|
{
|
||||||
if (complain)
|
if (complain)
|
||||||
error (_("no `this' in current language"));
|
error (_("no `this' in current language"));
|
||||||
|
@ -3625,39 +3624,21 @@ value_of_this (const struct language_defn *lang, int complain)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
func = get_frame_function (frame);
|
b = get_frame_block (frame, NULL);
|
||||||
if (!func)
|
|
||||||
{
|
|
||||||
if (complain)
|
|
||||||
error (_("no `%s' in nameless context"), name);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
b = SYMBOL_BLOCK_VALUE (func);
|
sym = lookup_language_this (lang, b);
|
||||||
if (dict_empty (BLOCK_DICT (b)))
|
|
||||||
{
|
|
||||||
if (complain)
|
|
||||||
error (_("no args, no `%s'"), name);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
|
|
||||||
symbol instead of the LOC_ARG one (if both exist). */
|
|
||||||
sym = lookup_block_symbol (b, name, VAR_DOMAIN);
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
{
|
{
|
||||||
if (complain)
|
if (complain)
|
||||||
error (_("current stack frame does not contain a variable named `%s'"),
|
error (_("current stack frame does not contain a variable named `%s'"),
|
||||||
name);
|
lang->la_name_of_this);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = read_var_value (sym, frame);
|
ret = read_var_value (sym, frame);
|
||||||
if (ret == 0 && complain)
|
if (ret == 0 && complain)
|
||||||
error (_("`%s' argument unreadable"), name);
|
error (_("`%s' argument unreadable"), lang->la_name_of_this);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue