/* Find a variable's value in memory, for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003 Free Software
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 Free Software
Foundation, Inc.
This file is part of GDB.
#include "floatformat.h"
#include "symfile.h" /* for overlay functions */
#include "regcache.h"
-#include "builtin-regs.h"
+#include "user-regs.h"
#include "block.h"
/* Basic byte-swapping routines. GDB has needed these for a long time...
char raw_buffer[MAX_REGISTER_SIZE];
enum lval_type lval;
- /* Builtin registers lie completly outside of the range of normal
+ /* User registers lie completely outside of the range of normal
registers. Catch them early so that the target never sees them. */
if (regnum >= NUM_REGS + NUM_PSEUDO_REGS)
- return value_of_builtin_reg (regnum, frame);
+ return value_of_user_reg (regnum, frame);
frame_register (frame, regnum, &optim, &lval, &addr, &realnum, raw_buffer);
reg_val = allocate_value (register_type (current_gdbarch, regnum));
- /* Convert raw data to virtual format if necessary. */
-
- if (DEPRECATED_REGISTER_CONVERTIBLE (regnum))
- {
- DEPRECATED_REGISTER_CONVERT_TO_VIRTUAL (regnum, register_type (current_gdbarch, regnum),
- raw_buffer, VALUE_CONTENTS_RAW (reg_val));
- }
- else if (REGISTER_RAW_SIZE (regnum) == REGISTER_VIRTUAL_SIZE (regnum))
- memcpy (VALUE_CONTENTS_RAW (reg_val), raw_buffer,
- REGISTER_RAW_SIZE (regnum));
- else
- internal_error (__FILE__, __LINE__,
- "Register \"%s\" (%d) has conflicting raw (%d) and virtual (%d) size",
- REGISTER_NAME (regnum),
- regnum,
- REGISTER_RAW_SIZE (regnum),
- REGISTER_VIRTUAL_SIZE (regnum));
+ memcpy (VALUE_CONTENTS_RAW (reg_val), raw_buffer,
+ register_size (current_gdbarch, regnum));
VALUE_LVAL (reg_val) = lval;
VALUE_ADDRESS (reg_val) = addr;
VALUE_REGNO (reg_val) = regnum;
we failed to consider one. */
case LOC_COMPUTED:
case LOC_COMPUTED_ARG:
- {
- struct location_funcs *symfuncs = SYMBOL_LOCATION_FUNCS (sym);
- return (symfuncs->read_needs_frame) (sym);
- }
- break;
+ /* FIXME: cagney/2004-01-26: It should be possible to
+ unconditionally call the SYMBOL_OPS method when available.
+ Unfortunately DWARF 2 stores the frame-base (instead of the
+ function) location in a function's symbol. Oops! For the
+ moment enable this when/where applicable. */
+ return SYMBOL_OPS (sym)->read_needs_frame (sym);
case LOC_REGISTER:
case LOC_ARG:
If FRAME is NULL, use the deprecated_selected_frame. */
struct value *
-read_var_value (register struct symbol *var, struct frame_info *frame)
+read_var_value (struct symbol *var, struct frame_info *frame)
{
- register struct value *v;
+ struct value *v;
struct type *type = SYMBOL_TYPE (var);
CORE_ADDR addr;
- register int len;
+ int len;
v = allocate_value (type);
VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */
len = TYPE_LENGTH (type);
+
+ /* FIXME drow/2003-09-06: this call to the selected frame should be
+ pushed upwards to the callers. */
if (frame == NULL)
- frame = deprecated_selected_frame;
+ frame = deprecated_safe_get_selected_frame ();
switch (SYMBOL_CLASS (var))
{
break;
}
- case LOC_THREAD_LOCAL_STATIC:
- {
- if (target_get_thread_local_address_p ())
- addr = target_get_thread_local_address (inferior_ptid,
- SYMBOL_OBJFILE (var),
- SYMBOL_VALUE_ADDRESS (var));
- /* It wouldn't be wrong here to try a gdbarch method, too;
- finding TLS is an ABI-specific thing. But we don't do that
- yet. */
- else
- error ("Cannot find thread-local variables on this target");
- break;
- }
-
case LOC_TYPEDEF:
error ("Cannot look up value of a typedef");
break;
case LOC_COMPUTED:
case LOC_COMPUTED_ARG:
- {
- struct location_funcs *funcs = SYMBOL_LOCATION_FUNCS (var);
-
- if (frame == 0 && (funcs->read_needs_frame) (var))
- return 0;
- return (funcs->read_variable) (var, frame);
-
- }
- break;
+ /* FIXME: cagney/2004-01-26: It should be possible to
+ unconditionally call the SYMBOL_OPS method when available.
+ Unfortunately DWARF 2 stores the frame-base (instead of the
+ function) location in a function's symbol. Oops! For the
+ moment enable this when/where applicable. */
+ if (frame == 0 && SYMBOL_OPS (var)->read_needs_frame (var))
+ return 0;
+ return SYMBOL_OPS (var)->read_variable (var, frame);
case LOC_UNRESOLVED:
{
struct value *v = allocate_value (type);
CHECK_TYPEDEF (type);
- if (CONVERT_REGISTER_P (regnum, type))
+ if (TYPE_LENGTH (type) == 0)
+ {
+ /* It doesn't matter much what we return for this: since the
+ length is zero, it could be anything. But if allowed to see
+ a zero-length type, the register-finding loop below will set
+ neither mem_stor nor reg_stor, and then report an internal
+ error.
+
+ Zero-length types can legitimately arise from declarations
+ like 'struct {}' (a GCC extension, not valid ISO C). GDB may
+ also create them when it finds bogus debugging information;
+ for example, in GCC 2.95.4 and binutils 2.11.93.0.2, the
+ STABS BINCL->EXCL compression process can create bad type
+ numbers. GDB reads these as TYPE_CODE_UNDEF types, with zero
+ length. (That bug is actually the only known way to get a
+ zero-length value allocated to a register --- which is what
+ it takes to make it here.)
+
+ We'll just attribute the value to the original register. */
+ VALUE_LVAL (v) = lval_register;
+ VALUE_ADDRESS (v) = regnum;
+ VALUE_REGNO (v) = regnum;
+ }
+ else if (CONVERT_REGISTER_P (regnum, type))
{
/* The ISA/ABI need to something weird when obtaining the
specified value from this register. It might need to
/* Copy all of the data out, whereever it may be. */
for (local_regnum = regnum, value_bytes_copied = 0;
value_bytes_copied < len;
- (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum),
+ (value_bytes_copied += register_size (current_gdbarch, local_regnum),
++local_regnum))
{
int realnum;
some fiddling with the last register copied here for little
endian machines. */
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
- && len < REGISTER_RAW_SIZE (regnum))
+ && len < register_size (current_gdbarch, regnum))
/* Big-endian, and we want less than full size. */
- VALUE_OFFSET (v) = REGISTER_RAW_SIZE (regnum) - len;
+ VALUE_OFFSET (v) = register_size (current_gdbarch, regnum) - len;
else
VALUE_OFFSET (v) = 0;
memcpy (VALUE_CONTENTS_RAW (v), value_bytes + VALUE_OFFSET (v), len);
address. */
struct value *
-locate_var_value (register struct symbol *var, struct frame_info *frame)
+locate_var_value (struct symbol *var, struct frame_info *frame)
{
CORE_ADDR addr = 0;
struct type *type = SYMBOL_TYPE (var);