* symtab.h: Rename SYMBOL_OPS to SYMBOL_COMPUTED_OPS.

* ax-gdb.c (gen_var_ref): Likewise.
	* findvar.c (read_var_value, symbol_read_needs_frame): Likewise.
	* printcmd.c (address_info): Likewise.
	* dwarf2loc.c (dwarf_expr_frame_base): Likewise.
	* dwarf2read.c (dwarf2_symbol_mark_computed): Likewise.
	* symtab.h: Rename struct symbol_ops to struct symbol_computed_ops.
	* dwarf2loc.h: Likewise.
	* dwarf2loc.c (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Likewise.

	* symtab.h: (struct symbol_register_ops): New struct definition.
	(struct symbol): Make "ops" member a union of symbol_computed_ops and
	symbol_register_ops callback pointers.
	(SYMBOL_REGISTER_OPS): New macro.
	* tracepoint.c: Include "objfiles.h".
	(scope_info, collect_symbol): Use SYMBOL_REGISTER_OPS register_number
	callback to retrieve register numbers.
	* ax-gdb.c (gen_var_ref): Likewise.
	* findvar.c (read_var_value): Likewise.
	* printcmd.c (address_info): Likewise.

	* coffread.c (coff_reg_to_regnum): New function.
	(coff_register_funcs): New static variable.
	(process_coff_symbol): Do not call gdbarch_sdb_reg_to_regnum.
	Install SYMBOL_REGISTER_OPS callbacks.
	* mdebugread.c (mdebug_reg_to_regnum): New function.
	(mdebug_register_funcs): New static variable.
	(parse_symbol): Do not call gdbarch_ecoff_reg_to_regnum.
	Install SYMBOL_REGISTER_OPS callbacks.
	* stabsread.c (stab_reg_to_regnum): New function.
	(stab_register_funcs): New static variable.
	(define_symbol): Do not call gdbarch_stab_reg_to_regnum.
	Install SYMBOL_REGISTER_OPS callbacks.
This commit is contained in:
Ulrich Weigand 2009-06-04 12:28:39 +00:00
parent e36aef4220
commit 768a979c31
12 changed files with 181 additions and 82 deletions

View file

@ -1,3 +1,39 @@
2009-06-04 Ulrich Weigand <uweigand@de.ibm.com>
* symtab.h: Rename SYMBOL_OPS to SYMBOL_COMPUTED_OPS.
* ax-gdb.c (gen_var_ref): Likewise.
* findvar.c (read_var_value, symbol_read_needs_frame): Likewise.
* printcmd.c (address_info): Likewise.
* dwarf2loc.c (dwarf_expr_frame_base): Likewise.
* dwarf2read.c (dwarf2_symbol_mark_computed): Likewise.
* symtab.h: Rename struct symbol_ops to struct symbol_computed_ops.
* dwarf2loc.h: Likewise.
* dwarf2loc.c (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Likewise.
* symtab.h: (struct symbol_register_ops): New struct definition.
(struct symbol): Make "ops" member a union of symbol_computed_ops and
symbol_register_ops callback pointers.
(SYMBOL_REGISTER_OPS): New macro.
* tracepoint.c: Include "objfiles.h".
(scope_info, collect_symbol): Use SYMBOL_REGISTER_OPS register_number
callback to retrieve register numbers.
* ax-gdb.c (gen_var_ref): Likewise.
* findvar.c (read_var_value): Likewise.
* printcmd.c (address_info): Likewise.
* coffread.c (coff_reg_to_regnum): New function.
(coff_register_funcs): New static variable.
(process_coff_symbol): Do not call gdbarch_sdb_reg_to_regnum.
Install SYMBOL_REGISTER_OPS callbacks.
* mdebugread.c (mdebug_reg_to_regnum): New function.
(mdebug_register_funcs): New static variable.
(parse_symbol): Do not call gdbarch_ecoff_reg_to_regnum.
Install SYMBOL_REGISTER_OPS callbacks.
* stabsread.c (stab_reg_to_regnum): New function.
(stab_register_funcs): New static variable.
(define_symbol): Do not call gdbarch_stab_reg_to_regnum.
Install SYMBOL_REGISTER_OPS callbacks.
2009-06-03 Doug Evans <dje@google.com> 2009-06-03 Doug Evans <dje@google.com>
* symfile.c (reread_symbols): Reset psymtabs_addrmap to NULL * symfile.c (reread_symbols): Reset psymtabs_addrmap to NULL

View file

@ -592,7 +592,7 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax,
this as an lvalue or rvalue, the caller will generate the this as an lvalue or rvalue, the caller will generate the
right code. */ right code. */
value->kind = axs_lvalue_register; value->kind = axs_lvalue_register;
value->u.reg = SYMBOL_VALUE (var); value->u.reg = SYMBOL_REGISTER_OPS (var)->register_number (var, gdbarch);
break; break;
/* A lot like LOC_REF_ARG, but the pointer lives directly in a /* A lot like LOC_REF_ARG, but the pointer lives directly in a
@ -600,7 +600,7 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax,
because it's just like any other case where the thing because it's just like any other case where the thing
has a real address. */ has a real address. */
case LOC_REGPARM_ADDR: case LOC_REGPARM_ADDR:
ax_reg (ax, SYMBOL_VALUE (var)); ax_reg (ax, SYMBOL_REGISTER_OPS (var)->register_number (var, gdbarch));
value->kind = axs_lvalue_memory; value->kind = axs_lvalue_memory;
break; break;
@ -619,11 +619,11 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax,
case LOC_COMPUTED: case LOC_COMPUTED:
/* FIXME: cagney/2004-01-26: It should be possible to /* FIXME: cagney/2004-01-26: It should be possible to
unconditionally call the SYMBOL_OPS method when available. unconditionally call the SYMBOL_COMPUTED_OPS method when available.
Unfortunately DWARF 2 stores the frame-base (instead of the Unfortunately DWARF 2 stores the frame-base (instead of the
function) location in a function's symbol. Oops! For the function) location in a function's symbol. Oops! For the
moment enable this when/where applicable. */ moment enable this when/where applicable. */
SYMBOL_OPS (var)->tracepoint_var_ref (var, ax, value); SYMBOL_COMPUTED_OPS (var)->tracepoint_var_ref (var, ax, value);
break; break;
case LOC_OPTIMIZED_OUT: case LOC_OPTIMIZED_OUT:

View file

@ -1474,6 +1474,16 @@ patch_opaque_types (struct symtab *s)
} }
} }
static int
coff_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
{
return gdbarch_sdb_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
}
static const struct symbol_register_ops coff_register_funcs = {
coff_reg_to_regnum
};
static struct symbol * static struct symbol *
process_coff_symbol (struct coff_symbol *cs, process_coff_symbol (struct coff_symbol *cs,
union internal_auxent *aux, union internal_auxent *aux,
@ -1554,8 +1564,8 @@ process_coff_symbol (struct coff_symbol *cs,
#endif #endif
case C_REG: case C_REG:
SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_VALUE (sym) = gdbarch_sdb_reg_to_regnum SYMBOL_REGISTER_OPS (sym) = &coff_register_funcs;
(current_gdbarch, cs->c_value); SYMBOL_VALUE (sym) = cs->c_value;
add_symbol_to_list (sym, &local_symbols); add_symbol_to_list (sym, &local_symbols);
break; break;
@ -1571,9 +1581,9 @@ process_coff_symbol (struct coff_symbol *cs,
case C_REGPARM: case C_REGPARM:
SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_REGISTER_OPS (sym) = &coff_register_funcs;
SYMBOL_IS_ARGUMENT (sym) = 1; SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = gdbarch_sdb_reg_to_regnum SYMBOL_VALUE (sym) = cs->c_value;
(current_gdbarch, cs->c_value);
add_symbol_to_list (sym, &local_symbols); add_symbol_to_list (sym, &local_symbols);
break; break;

View file

@ -154,7 +154,7 @@ dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length)
something has gone wrong. */ something has gone wrong. */
gdb_assert (framefunc != NULL); gdb_assert (framefunc != NULL);
if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs) if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_loclist_funcs)
{ {
struct dwarf2_loclist_baton *symbaton; struct dwarf2_loclist_baton *symbaton;
struct frame_info *frame = debaton->frame; struct frame_info *frame = debaton->frame;
@ -532,7 +532,7 @@ locexpr_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
/* The set of location functions used with the DWARF-2 expression /* The set of location functions used with the DWARF-2 expression
evaluator. */ evaluator. */
const struct symbol_ops dwarf2_locexpr_funcs = { const struct symbol_computed_ops dwarf2_locexpr_funcs = {
locexpr_read_variable, locexpr_read_variable,
locexpr_read_needs_frame, locexpr_read_needs_frame,
locexpr_describe_location, locexpr_describe_location,
@ -610,7 +610,7 @@ loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
/* The set of location functions used with the DWARF-2 expression /* The set of location functions used with the DWARF-2 expression
evaluator and location lists. */ evaluator and location lists. */
const struct symbol_ops dwarf2_loclist_funcs = { const struct symbol_computed_ops dwarf2_loclist_funcs = {
loclist_read_variable, loclist_read_variable,
loclist_read_needs_frame, loclist_read_needs_frame,
loclist_describe_location, loclist_describe_location,

View file

@ -20,7 +20,7 @@
#if !defined (DWARF2LOC_H) #if !defined (DWARF2LOC_H)
#define DWARF2LOC_H #define DWARF2LOC_H
struct symbol_ops; struct symbol_computed_ops;
struct objfile; struct objfile;
struct dwarf2_per_cu_data; struct dwarf2_per_cu_data;
@ -69,7 +69,7 @@ struct dwarf2_loclist_baton
struct dwarf2_per_cu_data *per_cu; struct dwarf2_per_cu_data *per_cu;
}; };
extern const struct symbol_ops dwarf2_locexpr_funcs; extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
extern const struct symbol_ops dwarf2_loclist_funcs; extern const struct symbol_computed_ops dwarf2_loclist_funcs;
#endif /* dwarf2loc.h */ #endif /* dwarf2loc.h */

View file

@ -10477,7 +10477,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
complaint (&symfile_complaints, complaint (&symfile_complaints,
_("Location list used without specifying the CU base address.")); _("Location list used without specifying the CU base address."));
SYMBOL_OPS (sym) = &dwarf2_loclist_funcs; SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
SYMBOL_LOCATION_BATON (sym) = baton; SYMBOL_LOCATION_BATON (sym) = baton;
} }
else else
@ -10507,7 +10507,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
baton->data = NULL; baton->data = NULL;
} }
SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs; SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
SYMBOL_LOCATION_BATON (sym) = baton; SYMBOL_LOCATION_BATON (sym) = baton;
} }
} }

View file

@ -347,11 +347,11 @@ symbol_read_needs_frame (struct symbol *sym)
we failed to consider one. */ we failed to consider one. */
case LOC_COMPUTED: case LOC_COMPUTED:
/* FIXME: cagney/2004-01-26: It should be possible to /* FIXME: cagney/2004-01-26: It should be possible to
unconditionally call the SYMBOL_OPS method when available. unconditionally call the SYMBOL_COMPUTED_OPS method when available.
Unfortunately DWARF 2 stores the frame-base (instead of the Unfortunately DWARF 2 stores the frame-base (instead of the
function) location in a function's symbol. Oops! For the function) location in a function's symbol. Oops! For the
moment enable this when/where applicable. */ moment enable this when/where applicable. */
return SYMBOL_OPS (sym)->read_needs_frame (sym); return SYMBOL_COMPUTED_OPS (sym)->read_needs_frame (sym);
case LOC_REGISTER: case LOC_REGISTER:
case LOC_ARG: case LOC_ARG:
@ -486,7 +486,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
case LOC_REGISTER: case LOC_REGISTER:
case LOC_REGPARM_ADDR: case LOC_REGPARM_ADDR:
{ {
int regno = SYMBOL_VALUE (var); int regno = SYMBOL_REGISTER_OPS (var)
->register_number (var, get_frame_arch (frame));
struct value *regval; struct value *regval;
if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR) if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
@ -514,11 +515,11 @@ read_var_value (struct symbol *var, struct frame_info *frame)
case LOC_COMPUTED: case LOC_COMPUTED:
/* FIXME: cagney/2004-01-26: It should be possible to /* FIXME: cagney/2004-01-26: It should be possible to
unconditionally call the SYMBOL_OPS method when available. unconditionally call the SYMBOL_COMPUTED_OPS method when available.
Unfortunately DWARF 2 stores the frame-base (instead of the Unfortunately DWARF 2 stores the frame-base (instead of the
function) location in a function's symbol. Oops! For the function) location in a function's symbol. Oops! For the
moment enable this when/where applicable. */ moment enable this when/where applicable. */
return SYMBOL_OPS (var)->read_variable (var, frame); return SYMBOL_COMPUTED_OPS (var)->read_variable (var, frame);
case LOC_UNRESOLVED: case LOC_UNRESOLVED:
{ {

View file

@ -527,6 +527,16 @@ add_pending (FDR *fh, char *sh, struct type *t)
aux symbols are big-endian or little-endian. Return count of aux symbols are big-endian or little-endian. Return count of
SYMR's handled (normally one). */ SYMR's handled (normally one). */
static int
mdebug_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
{
return gdbarch_ecoff_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
}
static const struct symbol_register_ops mdebug_register_funcs = {
mdebug_reg_to_regnum
};
static int static int
parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct section_offsets *section_offsets, struct objfile *objfile) struct section_offsets *section_offsets, struct objfile *objfile)
@ -607,16 +617,16 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
goto data; goto data;
case stLocal: /* local variable, goes into current block */ case stLocal: /* local variable, goes into current block */
if (sh->sc == scRegister)
{
class = LOC_REGISTER;
svalue = gdbarch_ecoff_reg_to_regnum (current_gdbarch, svalue);
}
else
class = LOC_LOCAL;
b = top_stack->cur_block; b = top_stack->cur_block;
s = new_symbol (name); s = new_symbol (name);
SYMBOL_VALUE (s) = svalue; SYMBOL_VALUE (s) = svalue;
if (sh->sc == scRegister)
{
class = LOC_REGISTER;
SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs;
}
else
class = LOC_LOCAL;
data: /* Common code for symbols describing data */ data: /* Common code for symbols describing data */
SYMBOL_DOMAIN (s) = VAR_DOMAIN; SYMBOL_DOMAIN (s) = VAR_DOMAIN;
@ -649,7 +659,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
case scRegister: case scRegister:
/* Pass by value in register. */ /* Pass by value in register. */
SYMBOL_CLASS (s) = LOC_REGISTER; SYMBOL_CLASS (s) = LOC_REGISTER;
svalue = gdbarch_ecoff_reg_to_regnum (current_gdbarch, svalue); SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs;
break; break;
case scVar: case scVar:
/* Pass by reference on stack. */ /* Pass by reference on stack. */
@ -658,7 +668,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
case scVarRegister: case scVarRegister:
/* Pass by reference in register. */ /* Pass by reference in register. */
SYMBOL_CLASS (s) = LOC_REGPARM_ADDR; SYMBOL_CLASS (s) = LOC_REGPARM_ADDR;
svalue = gdbarch_ecoff_reg_to_regnum (current_gdbarch, svalue); SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs;
break; break;
default: default:
/* Pass by value on stack. */ /* Pass by value on stack. */

View file

@ -1105,6 +1105,8 @@ sym_info (char *arg, int from_tty)
static void static void
address_info (char *exp, int from_tty) address_info (char *exp, int from_tty)
{ {
struct gdbarch *gdbarch;
int regno;
struct symbol *sym; struct symbol *sym;
struct minimal_symbol *msymbol; struct minimal_symbol *msymbol;
long val; long val;
@ -1167,6 +1169,7 @@ address_info (char *exp, int from_tty)
printf_filtered ("\" is "); printf_filtered ("\" is ");
val = SYMBOL_VALUE (sym); val = SYMBOL_VALUE (sym);
section = SYMBOL_OBJ_SECTION (sym); section = SYMBOL_OBJ_SECTION (sym);
gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
switch (SYMBOL_CLASS (sym)) switch (SYMBOL_CLASS (sym))
{ {
@ -1191,20 +1194,28 @@ address_info (char *exp, int from_tty)
case LOC_COMPUTED: case LOC_COMPUTED:
/* FIXME: cagney/2004-01-26: It should be possible to /* FIXME: cagney/2004-01-26: It should be possible to
unconditionally call the SYMBOL_OPS method when available. unconditionally call the SYMBOL_COMPUTED_OPS method when available.
Unfortunately DWARF 2 stores the frame-base (instead of the Unfortunately DWARF 2 stores the frame-base (instead of the
function) location in a function's symbol. Oops! For the function) location in a function's symbol. Oops! For the
moment enable this when/where applicable. */ moment enable this when/where applicable. */
SYMBOL_OPS (sym)->describe_location (sym, gdb_stdout); SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, gdb_stdout);
break; break;
case LOC_REGISTER: case LOC_REGISTER:
/* GDBARCH is the architecture associated with the objfile the symbol
is defined in; the target architecture may be different, and may
provide additional registers. However, we do not know the target
architecture at this point. We assume the objfile architecture
will contain all the standard registers that occur in debug info
in that objfile. */
regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
if (SYMBOL_IS_ARGUMENT (sym)) if (SYMBOL_IS_ARGUMENT (sym))
printf_filtered (_("an argument in register %s"), printf_filtered (_("an argument in register %s"),
gdbarch_register_name (current_gdbarch, val)); gdbarch_register_name (gdbarch, regno));
else else
printf_filtered (_("a variable in register %s"), printf_filtered (_("a variable in register %s"),
gdbarch_register_name (current_gdbarch, val)); gdbarch_register_name (gdbarch, regno));
break; break;
case LOC_STATIC: case LOC_STATIC:
@ -1222,8 +1233,10 @@ address_info (char *exp, int from_tty)
break; break;
case LOC_REGPARM_ADDR: case LOC_REGPARM_ADDR:
/* Note comment at LOC_REGISTER. */
regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
printf_filtered (_("address of an argument in register %s"), printf_filtered (_("address of an argument in register %s"),
gdbarch_register_name (current_gdbarch, val)); gdbarch_register_name (gdbarch, regno));
break; break;
case LOC_ARG: case LOC_ARG:

View file

@ -579,6 +579,29 @@ symbol_reference_defined (char **string)
} }
} }
static int
stab_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
{
int regno = gdbarch_stab_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
if (regno >= gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
{
reg_value_complaint (regno,
gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch),
SYMBOL_PRINT_NAME (sym));
regno = gdbarch_sp_regnum (gdbarch); /* Known safe, though useless */
}
return regno;
}
static const struct symbol_register_ops stab_register_funcs = {
stab_reg_to_regnum
};
struct symbol * struct symbol *
define_symbol (CORE_ADDR valu, char *string, int desc, int type, define_symbol (CORE_ADDR valu, char *string, int desc, int type,
struct objfile *objfile) struct objfile *objfile)
@ -993,18 +1016,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* Parameter which is in a register. */ /* Parameter which is in a register. */
SYMBOL_TYPE (sym) = read_type (&p, objfile); SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
SYMBOL_IS_ARGUMENT (sym) = 1; SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu); SYMBOL_VALUE (sym) = valu;
if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
{
reg_value_complaint (SYMBOL_VALUE (sym),
gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch),
SYMBOL_PRINT_NAME (sym));
SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
/* Known safe, though useless */
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols); add_symbol_to_list (sym, &local_symbols);
break; break;
@ -1013,17 +1027,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* Register variable (either global or local). */ /* Register variable (either global or local). */
SYMBOL_TYPE (sym) = read_type (&p, objfile); SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu); SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch) SYMBOL_VALUE (sym) = valu;
+ gdbarch_num_pseudo_regs (current_gdbarch))
{
reg_value_complaint (SYMBOL_VALUE (sym),
gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch),
SYMBOL_PRINT_NAME (sym));
SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
/* Known safe, though useless */
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
if (within_function) if (within_function)
{ {
@ -1059,6 +1064,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
SYMBOL_LINKAGE_NAME (sym)) == 0) SYMBOL_LINKAGE_NAME (sym)) == 0)
{ {
SYMBOL_CLASS (prev_sym) = LOC_REGISTER; SYMBOL_CLASS (prev_sym) = LOC_REGISTER;
SYMBOL_REGISTER_OPS (prev_sym) = &stab_register_funcs;
/* Use the type from the LOC_REGISTER; that is the type /* Use the type from the LOC_REGISTER; that is the type
that is actually in that register. */ that is actually in that register. */
SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym); SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
@ -1296,18 +1302,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* Reference parameter which is in a register. */ /* Reference parameter which is in a register. */
SYMBOL_TYPE (sym) = read_type (&p, objfile); SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
SYMBOL_IS_ARGUMENT (sym) = 1; SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu); SYMBOL_VALUE (sym) = valu;
if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
{
reg_value_complaint (SYMBOL_VALUE (sym),
gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch),
SYMBOL_PRINT_NAME (sym));
SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
/* Known safe, though useless */
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols); add_symbol_to_list (sym, &local_symbols);
break; break;

View file

@ -414,7 +414,11 @@ enum address_class
LOC_STATIC, LOC_STATIC,
/* Value is in register. SYMBOL_VALUE is the register number. /* Value is in register. SYMBOL_VALUE is the register number
in the original debug format. SYMBOL_REGISTER_OPS holds a
function that can be called to transform this into the
actual register number this represents in a specific target
architecture (gdbarch).
For some symbol formats (stabs, for some compilers at least), For some symbol formats (stabs, for some compilers at least),
the compiler generates two symbols, an argument and a register. the compiler generates two symbols, an argument and a register.
@ -488,16 +492,16 @@ enum address_class
LOC_OPTIMIZED_OUT, LOC_OPTIMIZED_OUT,
/* The variable's address is computed by a set of location /* The variable's address is computed by a set of location
functions (see "struct symbol_ops" below). */ functions (see "struct symbol_computed_ops" below). */
LOC_COMPUTED, LOC_COMPUTED,
}; };
/* The methods needed to implement a symbol class. These methods can /* The methods needed to implement LOC_COMPUTED. These methods can
use the symbol's .aux_value for additional per-symbol information. use the symbol's .aux_value for additional per-symbol information.
At present this is only used to implement location expressions. */ At present this is only used to implement location expressions. */
struct symbol_ops struct symbol_computed_ops
{ {
/* Return the value of the variable SYMBOL, relative to the stack /* Return the value of the variable SYMBOL, relative to the stack
@ -527,6 +531,13 @@ struct symbol_ops
struct axs_value * value); struct axs_value * value);
}; };
/* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR. */
struct symbol_register_ops
{
int (*register_number) (struct symbol *symbol, struct gdbarch *gdbarch);
};
/* This structure is space critical. See space comments at the top. */ /* This structure is space critical. See space comments at the top. */
struct symbol struct symbol
@ -571,7 +582,14 @@ struct symbol
/* Method's for symbol's of this class. */ /* Method's for symbol's of this class. */
/* NOTE: cagney/2003-11-02: See comment above attached to "aclass". */ /* NOTE: cagney/2003-11-02: See comment above attached to "aclass". */
const struct symbol_ops *ops; union
{
/* Used with LOC_COMPUTED. */
const struct symbol_computed_ops *ops_computed;
/* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */
const struct symbol_register_ops *ops_register;
} ops;
/* An arbitrary data pointer, allowing symbol readers to record /* An arbitrary data pointer, allowing symbol readers to record
additional information on a per-symbol basis. Note that this data additional information on a per-symbol basis. Note that this data
@ -598,7 +616,8 @@ struct symbol
#define SYMBOL_TYPE(symbol) (symbol)->type #define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line #define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_SYMTAB(symbol) (symbol)->symtab #define SYMBOL_SYMTAB(symbol) (symbol)->symtab
#define SYMBOL_OPS(symbol) (symbol)->ops #define SYMBOL_COMPUTED_OPS(symbol) (symbol)->ops.ops_computed
#define SYMBOL_REGISTER_OPS(symbol) (symbol)->ops.ops_register
#define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
/* A partial_symbol records the name, domain, and address class of /* A partial_symbol records the name, domain, and address class of

View file

@ -41,6 +41,7 @@
#include "user-regs.h" #include "user-regs.h"
#include "valprint.h" #include "valprint.h"
#include "gdbcore.h" #include "gdbcore.h"
#include "objfiles.h"
#include "ax.h" #include "ax.h"
#include "ax-gdb.h" #include "ax-gdb.h"
@ -783,7 +784,7 @@ collect_symbol (struct collection_list *collect,
add_memrange (collect, memrange_absolute, offset, len); add_memrange (collect, memrange_absolute, offset, len);
break; break;
case LOC_REGISTER: case LOC_REGISTER:
reg = SYMBOL_VALUE (sym); reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, current_gdbarch);
if (info_verbose) if (info_verbose)
printf_filtered ("LOC_REG[parm] %s: ", printf_filtered ("LOC_REG[parm] %s: ",
SYMBOL_PRINT_NAME (sym)); SYMBOL_PRINT_NAME (sym));
@ -1845,6 +1846,8 @@ scope_info (char *args, int from_tty)
char **canonical, *symname, *save_args = args; char **canonical, *symname, *save_args = args;
struct dict_iterator iter; struct dict_iterator iter;
int j, count = 0; int j, count = 0;
struct gdbarch *gdbarch;
int regno;
if (args == 0 || *args == 0) if (args == 0 || *args == 0)
error (_("requires an argument (function, line or *addr) to define a scope")); error (_("requires an argument (function, line or *addr) to define a scope"));
@ -1871,6 +1874,8 @@ scope_info (char *args, int from_tty)
if (symname == NULL || *symname == '\0') if (symname == NULL || *symname == '\0')
continue; /* probably botched, certainly useless */ continue; /* probably botched, certainly useless */
gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
printf_filtered ("Symbol %s is ", symname); printf_filtered ("Symbol %s is ", symname);
switch (SYMBOL_CLASS (sym)) switch (SYMBOL_CLASS (sym))
{ {
@ -1896,14 +1901,21 @@ scope_info (char *args, int from_tty)
printf_filtered ("%s", paddress (SYMBOL_VALUE_ADDRESS (sym))); printf_filtered ("%s", paddress (SYMBOL_VALUE_ADDRESS (sym)));
break; break;
case LOC_REGISTER: case LOC_REGISTER:
/* GDBARCH is the architecture associated with the objfile
the symbol is defined in; the target architecture may be
different, and may provide additional registers. However,
we do not know the target architecture at this point.
We assume the objfile architecture will contain all the
standard registers that occur in debug info in that
objfile. */
regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
if (SYMBOL_IS_ARGUMENT (sym)) if (SYMBOL_IS_ARGUMENT (sym))
printf_filtered ("an argument in register $%s", printf_filtered ("an argument in register $%s",
gdbarch_register_name gdbarch_register_name (gdbarch, regno));
(current_gdbarch, SYMBOL_VALUE (sym)));
else else
printf_filtered ("a local variable in register $%s", printf_filtered ("a local variable in register $%s",
gdbarch_register_name gdbarch_register_name (gdbarch, regno));
(current_gdbarch, SYMBOL_VALUE (sym)));
break; break;
case LOC_ARG: case LOC_ARG:
printf_filtered ("an argument at stack/frame offset %ld", printf_filtered ("an argument at stack/frame offset %ld",
@ -1918,9 +1930,10 @@ scope_info (char *args, int from_tty)
SYMBOL_VALUE (sym)); SYMBOL_VALUE (sym));
break; break;
case LOC_REGPARM_ADDR: case LOC_REGPARM_ADDR:
/* Note comment at LOC_REGISTER. */
regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
printf_filtered ("the address of an argument, in register $%s", printf_filtered ("the address of an argument, in register $%s",
gdbarch_register_name gdbarch_register_name (gdbarch, regno));
(current_gdbarch, SYMBOL_VALUE (sym)));
break; break;
case LOC_TYPEDEF: case LOC_TYPEDEF:
printf_filtered ("a typedef.\n"); printf_filtered ("a typedef.\n");
@ -1948,7 +1961,7 @@ scope_info (char *args, int from_tty)
printf_filtered ("optimized out.\n"); printf_filtered ("optimized out.\n");
continue; continue;
case LOC_COMPUTED: case LOC_COMPUTED:
SYMBOL_OPS (sym)->describe_location (sym, gdb_stdout); SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, gdb_stdout);
break; break;
} }
if (SYMBOL_TYPE (sym)) if (SYMBOL_TYPE (sym))