* nto-tdep.h: Include osabi.h. Prototypes for generic Neutrino
[deliverable/binutils-gdb.git] / gdb / findvar.c
index b5929fa99fc1d9acadf1aeb75a7c8dcc204a07ae..cc7d7a5b65bcb3190705c7fee08877112c3cd7d3 100644 (file)
@@ -282,27 +282,13 @@ value_of_register (int regnum, struct frame_info *frame)
 
   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 (DEPRECATED_REGISTER_RAW_SIZE (regnum) == DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum))
-    memcpy (VALUE_CONTENTS_RAW (reg_val), raw_buffer,
-           DEPRECATED_REGISTER_RAW_SIZE (regnum));
-  else
-    internal_error (__FILE__, __LINE__,
-                   "Register \"%s\" (%d) has conflicting raw (%d) and virtual (%d) size",
-                   REGISTER_NAME (regnum),
-                   regnum,
-                   DEPRECATED_REGISTER_RAW_SIZE (regnum),
-                   DEPRECATED_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;
+  VALUE_REGNUM (reg_val) = regnum;
   VALUE_OPTIMIZED_OUT (reg_val) = optim;
+  VALUE_FRAME_ID (reg_val) = get_frame_id (frame);
   return reg_val;
 }
 
@@ -401,7 +387,6 @@ read_var_value (struct symbol *var, struct frame_info *frame)
 
   v = allocate_value (type);
   VALUE_LVAL (v) = lval_memory;        /* The most likely possibility.  */
-  VALUE_BFD_SECTION (v) = SYMBOL_BFD_SECTION (var);
 
   len = TYPE_LENGTH (type);
 
@@ -465,7 +450,7 @@ Attempt to access variable defined in different shared object or load module whe
 addresses have not been bound by the dynamic loader. Try again when executable is running.");
 
        locaddr = SYMBOL_VALUE_ADDRESS (var);
-       loc = value_at (lookup_pointer_type (type), locaddr, NULL);
+       loc = value_at (lookup_pointer_type (type), locaddr);
        addr = value_as_address (loc);
       }
 
@@ -488,7 +473,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i
        if (!argref)
          return 0;
        argref += SYMBOL_VALUE (var);
-       ref = value_at (lookup_pointer_type (type), argref, NULL);
+       ref = value_at (lookup_pointer_type (type), argref);
        addr = value_as_address (ref);
        break;
       }
@@ -617,7 +602,30 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
   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_REGNUM (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
@@ -627,9 +635,9 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
          is that REGISTER_TO_VALUE populates the entire value
          including the location.  */
       REGISTER_TO_VALUE (frame, regnum, type, VALUE_CONTENTS_RAW (v));
-      VALUE_LVAL (v) = lval_reg_frame_relative;
+      VALUE_LVAL (v) = lval_register;
       VALUE_FRAME_ID (v) = get_frame_id (frame);
-      VALUE_FRAME_REGNUM (v) = regnum;
+      VALUE_REGNUM (v) = regnum;
     }
   else
     {
@@ -647,7 +655,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
       /* 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 += DEPRECATED_REGISTER_RAW_SIZE (local_regnum),
+          (value_bytes_copied += register_size (current_gdbarch, local_regnum),
            ++local_regnum))
        {
          int realnum;
@@ -671,6 +679,9 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
            {
              mem_stor++;
              
+             /* FIXME: cagney/2004-11-12: I think this is trying to
+                check that the stored registers are adjacent in
+                memory.  It isn't doing a good job?  */
              mem_tracking = (mem_tracking
                              && (regnum == local_regnum
                                  || addr == last_addr));
@@ -678,33 +689,17 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
          last_addr = addr;
        }
       
-      /* FIXME: cagney/2003-06-04: Shouldn't this always use
-         lval_reg_frame_relative?  If it doesn't and the register's
-         location changes (say after a resume) then this value is
-         going to have wrong information.  */
-      if ((reg_stor && mem_stor)
-         || (mem_stor && !mem_tracking))
-       /* Mixed storage; all of the hassle we just went through was
-          for some good purpose.  */
-       {
-         VALUE_LVAL (v) = lval_reg_frame_relative;
-         VALUE_FRAME_ID (v) = get_frame_id (frame);
-         VALUE_FRAME_REGNUM (v) = regnum;
-       }
-      else if (mem_stor)
+      if (mem_tracking && mem_stor && !reg_stor)
        {
          VALUE_LVAL (v) = lval_memory;
          VALUE_ADDRESS (v) = first_addr;
        }
-      else if (reg_stor)
+      else
        {
          VALUE_LVAL (v) = lval_register;
-         VALUE_ADDRESS (v) = first_addr;
-         VALUE_REGNO (v) = first_realnum;
+         VALUE_FRAME_ID (v) = get_frame_id (frame);
+         VALUE_REGNUM (v) = regnum;
        }
-      else
-       internal_error (__FILE__, __LINE__,
-                       "value_from_register: Value not stored anywhere!");
       
       VALUE_OPTIMIZED_OUT (v) = optimized;
       
@@ -713,12 +708,12 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
          some fiddling with the last register copied here for little
          endian machines.  */
       if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-         && len < DEPRECATED_REGISTER_RAW_SIZE (regnum))
+         && len < register_size (current_gdbarch, regnum))
        /* Big-endian, and we want less than full size.  */
-       VALUE_OFFSET (v) = DEPRECATED_REGISTER_RAW_SIZE (regnum) - len;
+       v->offset = register_size (current_gdbarch, regnum) - len;
       else
-       VALUE_OFFSET (v) = 0;
-      memcpy (VALUE_CONTENTS_RAW (v), value_bytes + VALUE_OFFSET (v), len);
+       v->offset = 0;
+      memcpy (VALUE_CONTENTS_RAW (v), value_bytes + value_offset (v), len);
     }
   return v;
 }
@@ -750,7 +745,6 @@ locate_var_value (struct symbol *var, struct frame_info *frame)
 
       addr = VALUE_ADDRESS (lazy_value);
       val = value_from_pointer (lookup_pointer_type (type), addr);
-      VALUE_BFD_SECTION (val) = VALUE_BFD_SECTION (lazy_value);
       return val;
     }
 
@@ -758,21 +752,12 @@ locate_var_value (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');
+      gdb_assert (REGISTER_NAME (VALUE_REGNUM (lazy_value)) != NULL
+                 && *REGISTER_NAME (VALUE_REGNUM (lazy_value)) != '\0');
       error("Address requested for identifier "
            "\"%s\" which is in register $%s",
             SYMBOL_PRINT_NAME (var), 
-           REGISTER_NAME (VALUE_REGNO (lazy_value)));
-      break;
-
-    case lval_reg_frame_relative:
-       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_PRINT_NAME (var), 
-           REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value)));
+           REGISTER_NAME (VALUE_REGNUM (lazy_value)));
       break;
 
     default:
This page took 0.026378 seconds and 4 git commands to generate.