aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-05-21 21:13:13 +0000
committerTom Tromey <tromey@redhat.com>2010-05-21 21:13:13 +0000
commitd3b1e87423732a7e32fb495f8e7afde3faab88dc (patch)
tree6b1fb02cbe88204afa76f74657cbff9049f247ee /gdb/testsuite
parentcb82636715e384dc5e75f3c1a4fd436626ba8dcd (diff)
downloadgdb-d3b1e87423732a7e32fb495f8e7afde3faab88dc.zip
gdb-d3b1e87423732a7e32fb495f8e7afde3faab88dc.tar.gz
gdb-d3b1e87423732a7e32fb495f8e7afde3faab88dc.tar.bz2
gdb
* dwarf2loc.c (extract_bits_primitive): New function. (extract_bits): Likewise. (insert_bits): Likewise. (copy_bitwise): Likewise. (read_pieced_value): Do all operations in bits. (write_pieced_value): Likewise. * dwarf2expr.h (struct dwarf_expr_piece) <offset>: New field. * dwarf2expr.c (add_piece): New arguments bit_piece, offset. Always use xrealloc to resize piece array. (execute_stack_op) <DW_OP_reg0>: Handle DW_OP_bit_piece. <DW_OP_piece>: Update. <DW_OP_bit_piece>: New case. gdb/testsuite * gdb.dwarf2/pieces.exp (pieces_test_f3): New proc. Call it. * gdb.dwarf2/pieces.S: Update. * gdb.dwarf2/pieces.c (struct B): Remove initial field.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.dwarf2/pieces.S54
-rw-r--r--gdb/testsuite/gdb.dwarf2/pieces.c4
-rw-r--r--gdb/testsuite/gdb.dwarf2/pieces.exp20
4 files changed, 47 insertions, 38 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 97b1c72..6d34cd7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2010-05-21 Tom Tromey <tromey@redhat.com>
+ * gdb.dwarf2/pieces.exp (pieces_test_f3): New proc.
+ Call it.
+ * gdb.dwarf2/pieces.S: Update.
+ * gdb.dwarf2/pieces.c (struct B): Remove initial field.
+
+2010-05-21 Tom Tromey <tromey@redhat.com>
+
* gdb.dwarf2/pieces.exp (pieces_test_f6): New proc.
Call it.
* gdb.dwarf2/pieces.c (struct C): New.
diff --git a/gdb/testsuite/gdb.dwarf2/pieces.S b/gdb/testsuite/gdb.dwarf2/pieces.S
index 0ecdbb0..f08b53d 100644
--- a/gdb/testsuite/gdb.dwarf2/pieces.S
+++ b/gdb/testsuite/gdb.dwarf2/pieces.S
@@ -989,23 +989,18 @@ main:
.LLST6:
.long .LVL13-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL14-.Ltext0 # Location list end address (*.LLST6)
- .value 0xa # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x8 # Location expression size
.byte 0x34 # DW_OP_lit4
.byte 0x9f # DW_OP_stack_value
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x93 # DW_OP_piece
- .uleb128 0x2
- .long .LVL14-.Ltext0 # Location list begin address (*.LLST6)
- .long .LVL15-.Ltext0 # Location list end address (*.LLST6)
- .value 0x15 # Location expression size
.byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
+ .uleb128 0x14
.uleb128 0
+ .long .LVL14-.Ltext0 # Location list begin address (*.LLST6)
+ .long .LVL15-.Ltext0 # Location list end address (*.LLST6)
+ .value 0x11 # Location expression size
.byte 0x34 # DW_OP_lit4
.byte 0x9f # DW_OP_stack_value
.byte 0x9d # DW_OP_bit_piece
@@ -1021,15 +1016,11 @@ main:
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL15-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL16-1-.Ltext0 # Location list end address (*.LLST6)
- .value 0x14 # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x10 # Location expression size
.byte 0x52 # DW_OP_reg2
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
@@ -1044,15 +1035,11 @@ main:
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL16-1-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL17-.Ltext0 # Location list end address (*.LLST6)
- .value 0x14 # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x10 # Location expression size
.byte 0x56 # DW_OP_reg6
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
@@ -1067,14 +1054,14 @@ main:
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL17-.Ltext0 # Location list begin address (*.LLST6)
.long .LFE3-.Ltext0 # Location list end address (*.LLST6)
.value 0xf # Location expression size
- .byte 0x93 # DW_OP_piece
- .uleb128 0x2
+ .byte 0x9d # DW_OP_bit_piece
+ .uleb128 0xc
+ .uleb128 0
.byte 0x91 # DW_OP_fbreg
.sleb128 0
.byte 0x94 # DW_OP_deref_size
@@ -1085,9 +1072,8 @@ main:
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long 0 # Location list terminator begin (*.LLST6)
.long 0 # Location list terminator end (*.LLST6)
.LLST7:
@@ -1356,7 +1342,7 @@ main:
.long 0x48 # DW_AT_type
.byte 0x4 # DW_AT_byte_size
.byte 0xc # DW_AT_bit_size
- .byte 0x10 # DW_AT_bit_offset
+ .byte 0x14 # DW_AT_bit_offset
.byte 0x2 # DW_AT_data_member_location
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0
@@ -1367,7 +1353,7 @@ main:
.long 0x48 # DW_AT_type
.byte 0x4 # DW_AT_byte_size
.byte 0xc # DW_AT_bit_size
- .byte 0x4 # DW_AT_bit_offset
+ .byte 0x8 # DW_AT_bit_offset
.byte 0x2 # DW_AT_data_member_location
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0
diff --git a/gdb/testsuite/gdb.dwarf2/pieces.c b/gdb/testsuite/gdb.dwarf2/pieces.c
index 04ea8a2..29879f5 100644
--- a/gdb/testsuite/gdb.dwarf2/pieces.c
+++ b/gdb/testsuite/gdb.dwarf2/pieces.c
@@ -21,7 +21,7 @@
However, it is used to extract breakpoint line numbers. */
struct A { int i; int j; };
-struct B { int : 4; int i : 12; int j : 12; int : 4; };
+struct B { int i : 12; int j : 12; int : 4; };
struct C { int i; int j; int q; };
__attribute__((noinline)) void
@@ -89,7 +89,7 @@ __attribute__((noinline)) int
f6 (int k)
{
int z = 23;
- struct C a = { k, k, z};
+ struct C a = { k, k, z };
asm ("" : "+r" (a.i));
a.j++;
bar (a.i);
diff --git a/gdb/testsuite/gdb.dwarf2/pieces.exp b/gdb/testsuite/gdb.dwarf2/pieces.exp
index c7608cd..2e812b5 100644
--- a/gdb/testsuite/gdb.dwarf2/pieces.exp
+++ b/gdb/testsuite/gdb.dwarf2/pieces.exp
@@ -67,15 +67,30 @@ proc pieces_test_f2 {} {
gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
}
+# Function f3 tests DW_OP_bit_piece.
+proc pieces_test_f3 {} {
+ global csrcfile
+ set line [gdb_get_line_number "f3 breakpoint" $csrcfile]
+ gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
+ "set f3 breakpoint for pieces"
+ gdb_continue_to_breakpoint "continue to f3 breakpoint for pieces"
+ gdb_test "print a.i" " = 4" "print a.i in pieces:f3"
+ gdb_test "print a.j" " = 14" "print a.j in pieces:f3"
+ # Right now gdb says "value optimized out" here, but that is wrong.
+ setup_kfail "no bug yet" *-*-*
+ gdb_test "print a.i = 7" " = 7" "set a.i in pieces:f3"
+ gdb_test "print a.i" " = 7" "print new a.i in pieces:f3"
+}
+
# Function f6 tests for an empty DW_OP_piece.
proc pieces_test_f6 {} {
global csrcfile
set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
- gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
+ gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
"set f6 breakpoint for pieces"
gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
gdb_test "print a" \
- "warning: bytes .* in computed object were.* = {i = 7, j = 8, q = 0}" \
+ "warning: bits .* in computed object were.* = {i = 7, j = 8, q = 0}" \
"print a with optimized out piece"
# Note: no warning for this case.
gdb_test_multiple "print a.i" \
@@ -91,4 +106,5 @@ proc pieces_test_f6 {} {
pieces_test_f1
pieces_test_f2
+pieces_test_f3
pieces_test_f6