* alpha-opc.c (alpha_opcodes): Fix thinko in ret pseudo
[deliverable/binutils-gdb.git] / gdb / findvar.c
index 04456207c7d45220636caf946165b78bae4e9d87..3a160a3597b802336e808787ab17c348468f2dab 100644 (file)
 #include "inferior.h"
 #include "target.h"
 #include "gdb_string.h"
+#include "gdb_assert.h"
 #include "floatformat.h"
 #include "symfile.h"           /* for overlay functions */
 #include "regcache.h"
 
-/* This is used to indicate that we don't know the format of the floating point
-   number.  Typically, this is useful for native ports, where the actual format
-   is irrelevant, since no conversions will be taking place.  */
-
-const struct floatformat floatformat_unknown;
-
 /* Basic byte-swapping routines.  GDB has needed these for a long time...
    All extract a target-format integer at ADDR which is LEN bytes long.  */
 
@@ -65,7 +60,7 @@ That operation is not available on integers of more than %d bytes.",
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
-  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
       p = startaddr;
       /* Do the sign extension once at the start.  */
@@ -100,7 +95,7 @@ That operation is not available on integers of more than %d bytes.",
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
   retval = 0;
-  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
       for (p = startaddr; p < endaddr; ++p)
        retval = (retval << 8) | *p;
@@ -125,7 +120,7 @@ extract_long_unsigned_integer (void *addr, int orig_len, LONGEST *pval)
   int len;
 
   len = orig_len;
-  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
       for (p = (char *) addr;
           len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len;
@@ -209,7 +204,7 @@ store_signed_integer (void *addr, int len, LONGEST val)
 
   /* Start at the least significant end of the integer, and work towards
      the most significant.  */
-  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
       for (p = endaddr - 1; p >= startaddr; --p)
        {
@@ -236,7 +231,7 @@ store_unsigned_integer (void *addr, int len, ULONGEST val)
 
   /* Start at the least significant end of the integer, and work towards
      the most significant.  */
-  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
       for (p = endaddr - 1; p >= startaddr; --p)
        {
@@ -295,12 +290,12 @@ store_typed_address (void *buf, struct type *type, CORE_ADDR addr)
    NOTE: returns NULL if register value is not available.
    Caller will check return value or die!  */
 
-value_ptr
+struct value *
 value_of_register (int regnum)
 {
   CORE_ADDR addr;
   int optim;
-  register value_ptr reg_val;
+  struct value *reg_val;
   char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
   enum lval_type lval;
 
@@ -412,10 +407,10 @@ symbol_read_needs_frame (struct symbol *sym)
    If the variable cannot be found, return a zero pointer.
    If FRAME is NULL, use the selected_frame.  */
 
-value_ptr
+struct value *
 read_var_value (register struct symbol *var, struct frame_info *frame)
 {
-  register value_ptr v;
+  register struct value *v;
   struct type *type = SYMBOL_TYPE (var);
   CORE_ADDR addr;
   register int len;
@@ -484,7 +479,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i
 
        locaddr = SYMBOL_VALUE_ADDRESS (var);
        loc = value_at (lookup_pointer_type (type), locaddr, NULL);
-       addr = value_as_pointer (loc);
+       addr = value_as_address (loc);
       }
 
     case LOC_ARG:
@@ -507,7 +502,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i
          return 0;
        argref += SYMBOL_VALUE (var);
        ref = value_at (lookup_pointer_type (type), argref, NULL);
-       addr = value_as_pointer (ref);
+       addr = value_as_address (ref);
        break;
       }
 
@@ -523,13 +518,13 @@ addresses have not been bound by the dynamic loader. Try again when executable i
     case LOC_BASEREG_ARG:
     case LOC_THREAD_LOCAL_STATIC:
       {
-       value_ptr regval;
+       struct value *regval;
 
        regval = value_from_register (lookup_pointer_type (type),
                                      SYMBOL_BASEREG (var), frame);
        if (regval == NULL)
          error ("Value of base register not available.");
-       addr = value_as_pointer (regval);
+       addr = value_as_address (regval);
        addr += SYMBOL_VALUE (var);
        break;
       }
@@ -552,7 +547,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i
       {
        struct block *b;
        int regno = SYMBOL_VALUE (var);
-       value_ptr regval;
+       struct value *regval;
 
        if (frame == NULL)
          return 0;
@@ -567,7 +562,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i
            if (regval == NULL)
              error ("Value of register variable not available.");
 
-           addr = value_as_pointer (regval);
+           addr = value_as_address (regval);
            VALUE_LVAL (v) = lval_memory;
          }
        else
@@ -617,13 +612,13 @@ addresses have not been bound by the dynamic loader. Try again when executable i
    NOTE: returns NULL if register value is not available.
    Caller will check return value or die!  */
 
-value_ptr
+struct value *
 value_from_register (struct type *type, int regnum, struct frame_info *frame)
 {
   char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
   CORE_ADDR addr;
   int optim;
-  value_ptr v = allocate_value (type);
+  struct value *v = allocate_value (type);
   char *value_bytes = 0;
   int value_bytes_copied = 0;
   int num_storage_locs;
@@ -823,7 +818,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
     {
       /* Raw and virtual formats are the same for this register.  */
 
-      if (TARGET_BYTE_ORDER == BIG_ENDIAN && len < REGISTER_RAW_SIZE (regnum))
+      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG && len < REGISTER_RAW_SIZE (regnum))
        {
          /* Big-endian, and we want less than full size.  */
          VALUE_OFFSET (v) = REGISTER_RAW_SIZE (regnum) - len;
@@ -840,12 +835,12 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
    return a (pointer to a) struct value containing the properly typed
    address.  */
 
-value_ptr
+struct value *
 locate_var_value (register struct symbol *var, struct frame_info *frame)
 {
   CORE_ADDR addr = 0;
   struct type *type = SYMBOL_TYPE (var);
-  value_ptr lazy_value;
+  struct value *lazy_value;
 
   /* Evaluate it first; if the result is a memory address, we're fine.
      Lazy evaluation pays off here. */
@@ -857,7 +852,7 @@ locate_var_value (register struct symbol *var, struct frame_info *frame)
   if (VALUE_LAZY (lazy_value)
       || TYPE_CODE (type) == TYPE_CODE_FUNC)
     {
-      value_ptr val;
+      struct value *val;
 
       addr = VALUE_ADDRESS (lazy_value);
       val = value_from_pointer (lookup_pointer_type (type), addr);
@@ -869,9 +864,21 @@ locate_var_value (register struct symbol *var, struct frame_info *frame)
   switch (VALUE_LVAL (lazy_value))
     {
     case lval_register:
+       gdb_assert (REGISTER_NAME (VALUE_REGNO (lazy_value)) != NULL
+                   && *REGISTER_NAME (VALUE_REGNO (lazy_value)) != '\0');
+      error("Address requested for identifier "
+           "\"%s\" which is in register $%s",
+            SYMBOL_SOURCE_NAME (var), 
+           REGISTER_NAME (VALUE_REGNO (lazy_value)));
+      break;
+
     case lval_reg_frame_relative:
-      error ("Address requested for identifier \"%s\" which is in a register.",
-            SYMBOL_SOURCE_NAME (var));
+       gdb_assert (REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value)) != NULL
+                   && *REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value)) != '\0');
+      error("Address requested for identifier "
+           "\"%s\" which is in frame register $%s",
+            SYMBOL_SOURCE_NAME (var), 
+           REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value)));
       break;
 
     default:
This page took 0.026095 seconds and 4 git commands to generate.