* configure.ac (DEBUGDIR_RELOCATABLE): Define for debugdir inside
[deliverable/binutils-gdb.git] / gdb / findvar.c
index 51fa4089fe27147c4c7c2f86d003463fbe1f8811..72417248a3770b5195ff505c37f912e7d1553087 100644 (file)
@@ -1,8 +1,8 @@
 /* Find a variable's value in memory, for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
-   Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -599,20 +599,44 @@ addresses have not been bound by the dynamic loader. Try again when executable i
   return v;
 }
 
+/* Install default attributes for register values.  */
+
+struct value *
+default_value_from_register (struct type *type, int regnum,
+                            struct frame_info *frame)
+{
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  int len = TYPE_LENGTH (type);
+  struct value *value = allocate_value (type);
+
+  VALUE_LVAL (value) = lval_register;
+  VALUE_FRAME_ID (value) = get_frame_id (frame);
+  VALUE_REGNUM (value) = regnum;
+
+  /* Any structure stored in more than one register will always be
+     an integral number of registers.  Otherwise, you need to do
+     some fiddling with the last register copied here for little
+     endian machines.  */
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
+      && len < register_size (gdbarch, regnum))
+    /* Big-endian, and we want less than full size.  */
+    set_value_offset (value, register_size (gdbarch, regnum) - len);
+  else
+    set_value_offset (value, 0);
+
+  return value;
+}
+
 /* Return a value of type TYPE, stored in register REGNUM, in frame FRAME.  */
 
 struct value *
 value_from_register (struct type *type, int regnum, struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct value *v = allocate_value (type);
-  CHECK_TYPEDEF (type);
-
-  VALUE_LVAL (v) = lval_register;
-  VALUE_FRAME_ID (v) = get_frame_id (frame);
-  VALUE_REGNUM (v) = regnum;
-      
-  if (CONVERT_REGISTER_P (regnum, type))
+  struct type *type1 = check_typedef (type);
+  struct value *v;
+
+  if (CONVERT_REGISTER_P (regnum, type1))
     {
       /* The ISA/ABI need to something weird when obtaining the
          specified value from this register.  It might need to
@@ -621,22 +645,18 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
          the corresponding [integer] type (see Alpha).  The assumption
          is that REGISTER_TO_VALUE populates the entire value
          including the location.  */
-      REGISTER_TO_VALUE (frame, regnum, type, value_contents_raw (v));
+      v = allocate_value (type);
+      VALUE_LVAL (v) = lval_register;
+      VALUE_FRAME_ID (v) = get_frame_id (frame);
+      VALUE_REGNUM (v) = regnum;
+      REGISTER_TO_VALUE (frame, regnum, type1, value_contents_raw (v));
     }
   else
     {
       int len = TYPE_LENGTH (type);
 
-      /* Any structure stored in more than one register will always be
-         an integral number of registers.  Otherwise, you need to do
-         some fiddling with the last register copied here for little
-         endian machines.  */
-      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-         && len < register_size (gdbarch, regnum))
-       /* Big-endian, and we want less than full size.  */
-       set_value_offset (v, register_size (gdbarch, regnum) - len);
-      else
-       set_value_offset (v, 0);
+      /* Construct the value.  */
+      v = gdbarch_value_from_register (gdbarch, type, regnum, frame);
 
       /* Get the data.  */
       if (!get_frame_register_bytes (frame, regnum, value_offset (v), len,
This page took 0.024986 seconds and 4 git commands to generate.