aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Heckel <bernhard.heckel@intel.com>2016-09-06 09:00:54 +0200
committerBernhard Heckel <bernhard.heckel@intel.com>2016-09-07 12:07:39 +0200
commitc632ec404b12ecdd3ed2c2d59d48d61883ebc1d6 (patch)
tree8d5830f67b0524a2de921d13714394644bc38fc1
parent36897971c8d022d5c28cc8af4b2f1df04a7e964f (diff)
downloadgdb-c632ec404b12ecdd3ed2c2d59d48d61883ebc1d6.zip
gdb-c632ec404b12ecdd3ed2c2d59d48d61883ebc1d6.tar.gz
gdb-c632ec404b12ecdd3ed2c2d59d48d61883ebc1d6.tar.bz2
Dwarf: Fix dynamic properties with neg. value.
Evaluating of neg. value of 32bit inferiours running on 64bit plattform causes issues because of the missing sign bits. Bernhard Heckel <bernhard.heckel@intel.com> gdb/Changelog * dwarf2loc.h: Declare * dwarf2loc.c (dwarf2_evaluate_property_signed): New. (dwarf2_evaluate_property): Delegate tasks to dwarf2_evaluate_property_signed. Change-Id: I3e8f67ecd0d78c579253f67cdf836bd8129a1a26
-rw-r--r--gdb/dwarf2loc.c46
-rw-r--r--gdb/dwarf2loc.h6
2 files changed, 44 insertions, 8 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 548e468..560e16f 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2601,11 +2601,14 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
/* See dwarf2loc.h. */
int
-dwarf2_evaluate_property (const struct dynamic_prop *prop,
+dwarf2_evaluate_property_signed (const struct dynamic_prop *prop,
struct frame_info *frame,
struct property_addr_info *addr_stack,
- CORE_ADDR *value)
+ CORE_ADDR *value,
+ int is_signed)
{
+ int rc = 0;
+
if (prop == NULL)
return 0;
@@ -2629,7 +2632,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
*value = value_as_address (val);
}
- return 1;
+ rc = 1;
}
}
break;
@@ -2651,7 +2654,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
if (!value_optimized_out (val))
{
*value = value_as_address (val);
- return 1;
+ rc = 1;
}
}
}
@@ -2659,8 +2662,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
case PROP_CONST:
*value = prop->data.const_val;
- return 1;
-
+ rc = 1;
+ break;
case PROP_ADDR_OFFSET:
{
struct dwarf2_property_baton *baton
@@ -2681,11 +2684,38 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
val = value_at (baton->offset_info.type,
pinfo->addr + baton->offset_info.offset);
*value = value_as_address (val);
- return 1;
+ rc = 1;
}
+ break;
}
- return 0;
+ if (rc == 1 && is_signed == 1)
+ {
+ /* 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 4 bytes. */
+ struct gdbarch * gdbarch = target_gdbarch ();
+ const int addr_bit = gdbarch_addr_bit (gdbarch);
+ const CORE_ADDR neg_mask = ((~0) << (addr_bit - 1));
+
+ /* Check if signed bit is set and sign-extend values. */
+ if (*value & (neg_mask))
+ *value |= (neg_mask );
+ }
+ return rc;
+}
+
+int
+dwarf2_evaluate_property (const struct dynamic_prop *prop,
+ struct frame_info *frame,
+ struct property_addr_info *addr_stack,
+ CORE_ADDR *value)
+{
+ return dwarf2_evaluate_property_signed (prop,
+ frame,
+ addr_stack,
+ value,
+ 0);
}
/* See dwarf2loc.h. */
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index fa83459..da6b9cd 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -138,6 +138,12 @@ int dwarf2_evaluate_property (const struct dynamic_prop *prop,
struct property_addr_info *addr_stack,
CORE_ADDR *value);
+int dwarf2_evaluate_property_signed (const struct dynamic_prop *prop,
+ struct frame_info *frame,
+ struct property_addr_info *addr_stack,
+ CORE_ADDR *value,
+ int is_signed);
+
/* A helper for the compiler interface that compiles a single dynamic
property to C code.