* dwarfread.c (isreg, optimized_out, offreg, basereg): Move

global variables into the struct dieinfo structure.
	(locval): Pass pointer to a dieinfo struct rather than a
	pointer to the raw location information.  Change prototype.
	Set isreg, optimized_out, offreg and basereg as appropriate.
	(struct_type): Call locval with dieinfo struct pointer.
	(new_symbol): Ditto.
	(new_symbol): Call locval and save location before testing
	the values of the new dieinfo struct flags, set by locval.
This commit is contained in:
Fred Fish
1997-06-18 21:38:57 +00:00
parent 585a4b7b35
commit 705ebd9239
2 changed files with 60 additions and 35 deletions

View File

@ -1,3 +1,15 @@
Wed Jun 18 13:47:52 1997 Fred Fish <fnf@cygnus.com>
* dwarfread.c (isreg, optimized_out, offreg, basereg): Move
global variables into the struct dieinfo structure.
(locval): Pass pointer to a dieinfo struct rather than a
pointer to the raw location information. Change prototype.
Set isreg, optimized_out, offreg and basereg as appropriate.
(struct_type): Call locval with dieinfo struct pointer.
(new_symbol): Ditto.
(new_symbol): Call locval and save location before testing
the values of the new dieinfo struct flags, set by locval.
Tue Jun 17 13:30:12 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) Tue Jun 17 13:30:12 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* procfs.c (proc_set_exec_trap, procfs_init_inferior, procfs_wait, * procfs.c (proc_set_exec_trap, procfs_init_inferior, procfs_wait,

View File

@ -314,6 +314,23 @@ struct dieinfo {
unsigned int has_at_stmt_list:1; unsigned int has_at_stmt_list:1;
unsigned int has_at_byte_size:1; unsigned int has_at_byte_size:1;
unsigned int short_element_list:1; unsigned int short_element_list:1;
/* Kludge to identify register variables */
unsigned int isreg;
/* Kludge to identify optimized out variables */
unsigned int optimized_out;
/* Kludge to identify basereg references.
Nonzero if we have an offset relative to a basereg. */
unsigned int offreg;
/* Kludge to identify which base register is it relative to. */
unsigned int basereg;
}; };
static int diecount; /* Approximate count of dies for compilation unit */ static int diecount; /* Approximate count of dies for compilation unit */
@ -323,13 +340,6 @@ static char *dbbase; /* Base pointer to dwarf info */
static int dbsize; /* Size of dwarf info in bytes */ static int dbsize; /* Size of dwarf info in bytes */
static int dbroff; /* Relative offset from start of .debug section */ static int dbroff; /* Relative offset from start of .debug section */
static char *lnbase; /* Base pointer to line section */ static char *lnbase; /* Base pointer to line section */
static int isreg; /* Kludge to identify register variables */
static int optimized_out; /* Kludge to identify optimized out variables */
/* Kludge to identify basereg references. Nonzero if we have an offset
relative to a basereg. */
static int offreg;
/* Which base register is it relative to? */
static int basereg;
/* This value is added to each symbol value. FIXME: Generalize to /* This value is added to each symbol value. FIXME: Generalize to
the section_offsets structure used by dbxread (once this is done, the section_offsets structure used by dbxread (once this is done,
@ -557,7 +567,7 @@ synthesize_typedef PARAMS ((struct dieinfo *, struct objfile *,
struct type *)); struct type *));
static int static int
locval PARAMS ((char *)); locval PARAMS ((struct dieinfo *));
static void static void
set_cu_language PARAMS ((struct dieinfo *)); set_cu_language PARAMS ((struct dieinfo *));
@ -1077,7 +1087,7 @@ struct_type (dip, thisdie, enddie, objfile)
obsavestring (mbr.at_name, strlen (mbr.at_name), obsavestring (mbr.at_name, strlen (mbr.at_name),
&objfile -> type_obstack); &objfile -> type_obstack);
list -> field.type = decode_die_type (&mbr); list -> field.type = decode_die_type (&mbr);
list -> field.bitpos = 8 * locval (mbr.at_location); list -> field.bitpos = 8 * locval (&mbr);
/* Handle bit fields. */ /* Handle bit fields. */
list -> field.bitsize = mbr.at_bit_size; list -> field.bitsize = mbr.at_bit_size;
if (BITS_BIG_ENDIAN) if (BITS_BIG_ENDIAN)
@ -2186,23 +2196,23 @@ LOCAL FUNCTION
SYNOPSIS SYNOPSIS
static int locval (char *loc) static int locval (struct dieinfo *dip)
DESCRIPTION DESCRIPTION
Given pointer to a string of bytes that define a location, compute Given pointer to a string of bytes that define a location, compute
the location and return the value. the location and return the value.
A location description containing no atoms indicates that the A location description containing no atoms indicates that the
object is optimized out. The global optimized_out flag is set for object is optimized out. The optimized_out flag is set for those,
those, the return value is meaningless. the return value is meaningless.
When computing values involving the current value of the frame pointer, When computing values involving the current value of the frame pointer,
the value zero is used, which results in a value relative to the frame the value zero is used, which results in a value relative to the frame
pointer, rather than the absolute value. This is what GDB wants pointer, rather than the absolute value. This is what GDB wants
anyway. anyway.
When the result is a register number, the global isreg flag is set, When the result is a register number, the isreg flag is set, otherwise
otherwise it is cleared. This is a kludge until we figure out a better it is cleared. This is a kludge until we figure out a better
way to handle the problem. Gdb's design does not mesh well with the way to handle the problem. Gdb's design does not mesh well with the
DWARF notion of a location computing interpreter, which is a shame DWARF notion of a location computing interpreter, which is a shame
because the flexibility goes unused. because the flexibility goes unused.
@ -2214,30 +2224,32 @@ NOTES
*/ */
static int static int
locval (loc) locval (dip)
char *loc; struct dieinfo *dip;
{ {
unsigned short nbytes; unsigned short nbytes;
unsigned short locsize; unsigned short locsize;
auto long stack[64]; auto long stack[64];
int stacki; int stacki;
char *loc;
char *end; char *end;
int loc_atom_code; int loc_atom_code;
int loc_value_size; int loc_value_size;
loc = dip -> at_location;
nbytes = attribute_size (AT_location); nbytes = attribute_size (AT_location);
locsize = target_to_host (loc, nbytes, GET_UNSIGNED, current_objfile); locsize = target_to_host (loc, nbytes, GET_UNSIGNED, current_objfile);
loc += nbytes; loc += nbytes;
end = loc + locsize; end = loc + locsize;
stacki = 0; stacki = 0;
stack[stacki] = 0; stack[stacki] = 0;
isreg = 0; dip -> isreg = 0;
offreg = 0; dip -> offreg = 0;
optimized_out = 1; dip -> optimized_out = 1;
loc_value_size = TARGET_FT_LONG_SIZE (current_objfile); loc_value_size = TARGET_FT_LONG_SIZE (current_objfile);
while (loc < end) while (loc < end)
{ {
optimized_out = 0; dip -> optimized_out = 0;
loc_atom_code = target_to_host (loc, SIZEOF_LOC_ATOM_CODE, GET_UNSIGNED, loc_atom_code = target_to_host (loc, SIZEOF_LOC_ATOM_CODE, GET_UNSIGNED,
current_objfile); current_objfile);
loc += SIZEOF_LOC_ATOM_CODE; loc += SIZEOF_LOC_ATOM_CODE;
@ -2254,15 +2266,15 @@ locval (loc)
GET_UNSIGNED, GET_UNSIGNED,
current_objfile)); current_objfile));
loc += loc_value_size; loc += loc_value_size;
isreg = 1; dip -> isreg = 1;
break; break;
case OP_BASEREG: case OP_BASEREG:
/* push value of register (number) */ /* push value of register (number) */
/* Actually, we compute the value as if register has 0, so the /* Actually, we compute the value as if register has 0, so the
value ends up being the offset from that register. */ value ends up being the offset from that register. */
offreg = 1; dip -> offreg = 1;
basereg = target_to_host (loc, loc_value_size, GET_UNSIGNED, dip -> basereg = target_to_host (loc, loc_value_size, GET_UNSIGNED,
current_objfile); current_objfile);
loc += loc_value_size; loc += loc_value_size;
stack[++stacki] = 0; stack[++stacki] = 0;
break; break;
@ -2972,7 +2984,7 @@ new_symbol (dip, objfile)
case TAG_global_variable: case TAG_global_variable:
if (dip -> at_location != NULL) if (dip -> at_location != NULL)
{ {
SYMBOL_VALUE_ADDRESS (sym) = locval (dip -> at_location); SYMBOL_VALUE_ADDRESS (sym) = locval (dip);
add_symbol_to_list (sym, &global_symbols); add_symbol_to_list (sym, &global_symbols);
SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE (sym) += baseaddr; SYMBOL_VALUE (sym) += baseaddr;
@ -2981,18 +2993,19 @@ new_symbol (dip, objfile)
case TAG_local_variable: case TAG_local_variable:
if (dip -> at_location != NULL) if (dip -> at_location != NULL)
{ {
if (optimized_out) int loc = locval (dip);
if (dip -> optimized_out)
{ {
SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
} }
else if (isreg) else if (dip -> isreg)
{ {
SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_CLASS (sym) = LOC_REGISTER;
} }
else if (offreg) else if (dip -> offreg)
{ {
SYMBOL_CLASS (sym) = LOC_BASEREG; SYMBOL_CLASS (sym) = LOC_BASEREG;
SYMBOL_BASEREG (sym) = basereg; SYMBOL_BASEREG (sym) = dip -> basereg;
} }
else else
{ {
@ -3003,11 +3016,11 @@ new_symbol (dip, objfile)
{ {
/* LOC_STATIC address class MUST use SYMBOL_VALUE_ADDRESS, /* LOC_STATIC address class MUST use SYMBOL_VALUE_ADDRESS,
which may store to a bigger location than SYMBOL_VALUE. */ which may store to a bigger location than SYMBOL_VALUE. */
SYMBOL_VALUE_ADDRESS (sym) = locval (dip -> at_location); SYMBOL_VALUE_ADDRESS (sym) = loc;
} }
else else
{ {
SYMBOL_VALUE (sym) = locval (dip -> at_location); SYMBOL_VALUE (sym) = loc;
} }
add_symbol_to_list (sym, list_in_scope); add_symbol_to_list (sym, list_in_scope);
} }
@ -3015,17 +3028,17 @@ new_symbol (dip, objfile)
case TAG_formal_parameter: case TAG_formal_parameter:
if (dip -> at_location != NULL) if (dip -> at_location != NULL)
{ {
SYMBOL_VALUE (sym) = locval (dip -> at_location); SYMBOL_VALUE (sym) = locval (dip);
} }
add_symbol_to_list (sym, list_in_scope); add_symbol_to_list (sym, list_in_scope);
if (isreg) if (dip -> isreg)
{ {
SYMBOL_CLASS (sym) = LOC_REGPARM; SYMBOL_CLASS (sym) = LOC_REGPARM;
} }
else if (offreg) else if (dip -> offreg)
{ {
SYMBOL_CLASS (sym) = LOC_BASEREG_ARG; SYMBOL_CLASS (sym) = LOC_BASEREG_ARG;
SYMBOL_BASEREG (sym) = basereg; SYMBOL_BASEREG (sym) = dip -> basereg;
} }
else else
{ {