aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-06-18 18:11:19 +0000
committerTom Tromey <tromey@redhat.com>2013-06-18 18:11:19 +0000
commit5bd1ef568c63cbcf6ed99a083eeb18cf940871dd (patch)
tree053e51b5c75e50567212a6b7edb5094b3a8dc555 /gdb/utils.c
parent92fac8075afdfdd75ab752de80c1e7b0cbcc5303 (diff)
downloadgdb-5bd1ef568c63cbcf6ed99a083eeb18cf940871dd.zip
gdb-5bd1ef568c63cbcf6ed99a083eeb18cf940871dd.tar.gz
gdb-5bd1ef568c63cbcf6ed99a083eeb18cf940871dd.tar.bz2
Fix PR symtab/15391
PR symtab/15391 is a failure with the DW_OP_GNU_implicit_pointer feature. I tracked it down to a logic error in read_pieced_value. The code truncates this_size_bits according to the type size and offset too early -- it should do it after taking bits_to_skip into account. This patch fixes the bug. While testing this, I also tripped across a latent bug because indirect_pieced_value does not sign-extend where needed. This patch fixes this bug as well. Finally, Pedro pointed out that a previous version implemented sign extension incorrectly. This version introduces a new gdb_sign_extend function for this. A couple of notes on this function: * It has the gdb_ prefix to avoid clashes with various libraries that felt free to avoid proper namespacing. There is a "sign_extend" function in a Tile GX header, in an SOM-related BFD header (and in sh64-tdep.c and as a macro in arm-wince-tdep.c, but those are ours...) * I looked at all the sign extensions in gdb and didn't see ones that I felt comfortable converting to use this function; in large part because I don't have a good way to test the conversion. Built and regtested on x86-64 Fedora 18. New test cases included; this required a minor addition to the DWARF assembler. Note that the DWARF CU made by implptrpiece.exp uses a funny pointer size in order to show the sign-extension bug on all platforms. * dwarf2loc.c (read_pieced_value): Truncate this_size_bits after taking bits_to_skip into account. Sign extend byte_offset. * utils.h (gdb_sign_extend): Declare. * utils.c (gdb_sign_extend): New function. * gdb.dwarf2/implptrpiece.exp: New file. * gdb.dwarf2/implptrconst.exp (d): New variable. Print d. * lib/dwarf2.exp (Dwarf::_location): Handle DW_OP_piece.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 18ee9bb..f5c1339 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3234,6 +3234,23 @@ align_down (ULONGEST v, int n)
return (v & -n);
}
+/* See utils.h. */
+
+LONGEST
+gdb_sign_extend (LONGEST value, int bit)
+{
+ gdb_assert (bit >= 1 && bit <= 8 * sizeof (LONGEST));
+
+ if (((value >> (bit - 1)) & 1) != 0)
+ {
+ LONGEST signbit = ((LONGEST) 1) << (bit - 1);
+
+ value = (value ^ signbit) - signbit;
+ }
+
+ return value;
+}
+
/* Allocation function for the libiberty hash table which uses an
obstack. The obstack is passed as DATA. */