* config/m68k/monitor.mt (TDEPFILE): Add remote-es.o.
[deliverable/binutils-gdb.git] / gdb / values.c
index 8890c8eaad063c46512177d53b48987e8267a251..451cf51e962db7d34b24abee252d99250db7c8b7 100644 (file)
@@ -255,6 +255,14 @@ record_latest_value (val)
     }
 
   value_history_chain->values[i] = val;
+
+  /* We don't want this value to have anything to do with the inferior anymore.
+     In particular, "set $1 = 50" should not affect the variable from which
+     the value was taken, and fast watchpoints should be able to assume that
+     a value on the value history never changes.  */
+  if (VALUE_LAZY (val))
+    value_fetch_lazy (val);
+  VALUE_LVAL (val) = not_lval;
   release_value (val);
 
   /* Now we regard value_history_count as origin-one
@@ -352,7 +360,7 @@ show_values (num_exp, from_tty)
     {
       val = access_value_history (i);
       printf_filtered ("$%d = ", i);
-      value_print (val, stdout, 0, Val_pretty_default);
+      value_print (val, gdb_stdout, 0, Val_pretty_default);
       printf_filtered ("\n");
     }
 
@@ -504,11 +512,11 @@ show_convenience (ignore, from_tty)
          varseen = 1;
        }
       printf_filtered ("$%s = ", var->name);
-      value_print (var->value, stdout, 0, Val_pretty_default);
+      value_print (var->value, gdb_stdout, 0, Val_pretty_default);
       printf_filtered ("\n");
     }
   if (!varseen)
-    printf ("No debugger convenience variables now defined.\n\
+    printf_unfiltered ("No debugger convenience variables now defined.\n\
 Convenience variables have names starting with \"$\";\n\
 use \"set\" as in \"set $foo = 5\" to define them.\n");
 }
@@ -586,49 +594,33 @@ unpack_long (type, valaddr)
   register int len = TYPE_LENGTH (type);
   register int nosign = TYPE_UNSIGNED (type);
 
-  if (code == TYPE_CODE_ENUM || code == TYPE_CODE_BOOL)
-    code = TYPE_CODE_INT;
-  if (code == TYPE_CODE_FLT)
+  switch (code)
     {
-      if (len == sizeof (float))
-       {
-         float retval;
-         memcpy (&retval, valaddr, sizeof (retval));
-         SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
-         return retval;
-       }
-
-      if (len == sizeof (double))
-       {
-         double retval;
-         memcpy (&retval, valaddr, sizeof (retval));
-         SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
-         return retval;
-       }
+    case TYPE_CODE_ENUM:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_INT:
+    case TYPE_CODE_CHAR:
+      if (nosign)
+       return extract_unsigned_integer (valaddr, len);
       else
-       {
-         error ("Unexpected type of floating point number.");
-       }
-    }
-  else if ((code == TYPE_CODE_INT || code == TYPE_CODE_CHAR) && nosign)
-    {
-      return extract_unsigned_integer (valaddr, len);
-    }
-  else if (code == TYPE_CODE_INT || code == TYPE_CODE_CHAR)
-    {
-      return extract_signed_integer (valaddr, len);
-    }
-  /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
-     whether we want this to be true eventually.  */
-  else if (code == TYPE_CODE_PTR || code == TYPE_CODE_REF)
-    {
+       return extract_signed_integer (valaddr, len);
+
+    case TYPE_CODE_FLT:
+      return extract_floating (valaddr, len);
+
+    case TYPE_CODE_PTR:
+    case TYPE_CODE_REF:
+      /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
+        whether we want this to be true eventually.  */
       return extract_address (valaddr, len);
-    }
-  else if (code == TYPE_CODE_MEMBER)
-    error ("not implemented: member types in unpack_long");
 
-  error ("Value not integer or pointer.");
-  return 0;    /* For lint -- never reached */
+    case TYPE_CODE_MEMBER:
+      error ("not implemented: member types in unpack_long");
+
+    default:
+      error ("Value can't be converted to integer.");
+    }
+  return 0; /* Placate lint.  */
 }
 
 /* Return a double value from the specified type and address.
@@ -655,35 +647,18 @@ unpack_double (type, valaddr, invp)
          *invp = 1;
          return 1.234567891011121314;
        }
-
-      if (len == sizeof (float))
-       {
-         float retval;
-         memcpy (&retval, valaddr, sizeof (retval));
-         SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
-         return retval;
-       }
-
-      if (len == sizeof (double))
-       {
-         double retval;
-         memcpy (&retval, valaddr, sizeof (retval));
-         SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
-         return retval;
-       }
-      else
-       {
-         error ("Unexpected type of floating point number.");
-         return 0; /* Placate lint.  */
-       }
+      return extract_floating (valaddr, len);
+    }
+  else if (nosign)
+    {
+      /* Unsigned -- be sure we compensate for signed LONGEST.  */
+      return (unsigned LONGEST) unpack_long (type, valaddr);
+    }
+  else
+    {
+      /* Signed -- we are OK with unpack_long.  */
+      return unpack_long (type, valaddr);
     }
-  else if (nosign) {
-   /* Unsigned -- be sure we compensate for signed LONGEST.  */
-   return (unsigned LONGEST) unpack_long (type, valaddr);
-  } else {
-    /* Signed -- we are OK with unpack_long.  */
-    return unpack_long (type, valaddr);
-  }
 }
 
 /* Unpack raw data (copied from debugee, target byte order) at VALADDR
@@ -790,8 +765,12 @@ value_fn_field (arg1p, f, j, type, offset)
 
   sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
                       0, VAR_NAMESPACE, 0, NULL);
-  if (! sym) error ("Internal error: could not find physical method named %s",
+  if (! sym) 
+       return (value)NULL;
+/*
+       error ("Internal error: could not find physical method named %s",
                    TYPE_FN_FIELD_PHYSNAME (f, j));
+*/
   
   v = allocate_value (ftype);
   VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
@@ -803,8 +782,9 @@ value_fn_field (arg1p, f, j, type, offset)
       *arg1p = value_ind (value_cast (lookup_pointer_type (type),
                                      value_addr (*arg1p)));
 
-    /* Move the `this' pointer according to the offset. */
+    /* Move the `this' pointer according to the offset. 
     VALUE_OFFSET (*arg1p) += offset;
+    */
     }
 
   return v;
@@ -868,8 +848,9 @@ value_virtual_fn_field (arg1p, f, j, type, offset)
      a virtual function.  */
   entry = value_subscript (vtbl, vi);
 
-  /* Move the `this' pointer according to the virtual function table.  */
-  VALUE_OFFSET (arg1) += value_as_long (value_field (entry, 0)) + offset;
+  /* Move the `this' pointer according to the virtual function table. */ 
+  VALUE_OFFSET (arg1) += value_as_long (value_field (entry, 0))/* + offset*/;
+
   if (! VALUE_LAZY (arg1))
     {
       VALUE_LAZY (arg1) = 1;
@@ -1331,20 +1312,11 @@ value_from_double (type, num)
 
   if (code == TYPE_CODE_FLT)
     {
-      if (len == sizeof (float))
-       * (float *) VALUE_CONTENTS_RAW (val) = num;
-      else if (len == sizeof (double))
-       * (double *) VALUE_CONTENTS_RAW (val) = num;
-      else
-       error ("Floating type encountered with unexpected data length.");
+      store_floating (VALUE_CONTENTS_RAW (val), len, num);
     }
   else
     error ("Unexpected type encountered for floating constant.");
 
-  /* num was in host byte order.  So now put the value's contents
-     into target byte order.  */
-  SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (val), len);
-
   return val;
 }
 \f
This page took 0.024842 seconds and 4 git commands to generate.