elf_backend_init_file_header
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
index ea6b36e6ed8b99942d2ef9aadb81db1906b926b4..c8ba0290a02eb548beaf29b68d1552ac23b359e5 100644 (file)
@@ -46,8 +46,6 @@
 #include "gdbsupport/underlying.h"
 #include "gdbsupport/byte-vector.h"
 
-extern int dwarf_always_disassemble;
-
 static struct value *dwarf2_evaluate_loc_desc_full (struct type *type,
                                                    struct frame_info *frame,
                                                    const gdb_byte *data,
@@ -2443,17 +2441,40 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
       {
        const struct dwarf2_property_baton *baton
          = (const struct dwarf2_property_baton *) prop->data.baton;
+       gdb_assert (baton->property_type != NULL);
 
        if (dwarf2_locexpr_baton_eval (&baton->locexpr, frame,
                                       addr_stack ? addr_stack->addr : 0,
                                       value))
          {
-           if (baton->referenced_type)
+           if (baton->locexpr.is_reference)
              {
-               struct value *val = value_at (baton->referenced_type, *value);
-
+               struct value *val = value_at (baton->property_type, *value);
                *value = value_as_address (val);
              }
+           else
+             {
+               gdb_assert (baton->property_type != NULL);
+
+               struct type *type = check_typedef (baton->property_type);
+               if (TYPE_LENGTH (type) < sizeof (CORE_ADDR)
+                   && !TYPE_UNSIGNED (type))
+                 {
+                   /* If we have a valid return candidate and it's value
+                      is signed, we have to sign-extend the value because
+                      CORE_ADDR on 64bit machine has 8 bytes but address
+                      size of an 32bit application is bytes.  */
+                   const int addr_size
+                     = (dwarf2_per_cu_addr_size (baton->locexpr.per_cu)
+                        * TARGET_CHAR_BIT);
+                   const CORE_ADDR neg_mask
+                     = (~((CORE_ADDR) 0) <<  (addr_size - 1));
+
+                   /* Check if signed bit is set and sign-extend values.  */
+                   if (*value & neg_mask)
+                     *value |= neg_mask;
+                 }
+             }
            return true;
          }
       }
@@ -2471,7 +2492,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
        data = dwarf2_find_location_expression (&baton->loclist, &size, pc);
        if (data != NULL)
          {
-           val = dwarf2_evaluate_loc_desc (baton->referenced_type, frame, data,
+           val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data,
                                            size, baton->loclist.per_cu);
            if (!value_optimized_out (val))
              {
@@ -2497,7 +2518,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
          {
            /* This approach lets us avoid checking the qualifiers.  */
            if (TYPE_MAIN_TYPE (pinfo->type)
-               == TYPE_MAIN_TYPE (baton->referenced_type))
+               == TYPE_MAIN_TYPE (baton->property_type))
              break;
          }
        if (pinfo == NULL)
This page took 0.02525 seconds and 4 git commands to generate.