aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-04-06 11:02:04 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-04-11 23:40:25 +0100
commit41077b6625d16cc6c0c4b404a177a8850300b8a0 (patch)
treee640c63cbf1e3d28841c1139c5b412782a8fb5a7 /gdb/testsuite
parent9f0272f8548164b024ff9fd151686b2b904a5d59 (diff)
downloadgdb-41077b6625d16cc6c0c4b404a177a8850300b8a0.zip
gdb-41077b6625d16cc6c0c4b404a177a8850300b8a0.tar.gz
gdb-41077b6625d16cc6c0c4b404a177a8850300b8a0.tar.bz2
gdb: Fix alignment computation for structs with only static fields
The current code in gdbtypes.c:type_align incorrectly returns 0 as the alignment for a structure containing only static fields. After this patch the correct value of 1 is returned. The gdb.base/align.exp test is extended to cover this case. gdb/ChangeLog: * gdbtypes.c (type_align): A struct with no non-static fields also has alignment of 1. gdb/testsuite/ChangeLog: * gdb.base/align.exp: Extend test to cover structures containing only static fields.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/align.exp24
2 files changed, 23 insertions, 6 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index dfbee85..3b952b8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-04-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.base/align.exp: Extend test to cover structures containing
+ only static fields.
+
2019-04-11 Tom de Vries <tdevries@suse.de>
* boards/cc-with-dwz-m.exp: New file.
diff --git a/gdb/testsuite/gdb.base/align.exp b/gdb/testsuite/gdb.base/align.exp
index 558625d..e3ca047 100644
--- a/gdb/testsuite/gdb.base/align.exp
+++ b/gdb/testsuite/gdb.base/align.exp
@@ -67,8 +67,10 @@ proc prepare_test_source_file { lang } {
puts -nonewline $outfile "#define DEF(T,U) struct align_pair_ ## T ## _x_ ## U "
puts $outfile "{ T one; U two; }"
if { $lang == "c++" } {
- puts -nonewline $outfile "#define DEF_WITH_STATIC(T,U) struct align_pair_static_ ## T ## _x_ ## U "
+ puts -nonewline $outfile "#define DEF_WITH_1_STATIC(T,U) struct align_pair_static_ ## T ## _x_ ## U "
puts $outfile "{ static T one; U two; }"
+ puts -nonewline $outfile "#define DEF_WITH_2_STATIC(T,U) struct align_pair_static_ ## T ## _x_static_ ## U "
+ puts $outfile "{ static T one; static U two; }"
}
if { $lang == "c" } {
puts $outfile "unsigned a_void = ${align_func} (void);"
@@ -99,11 +101,17 @@ proc prepare_test_source_file { lang } {
puts $outfile " = ${align_func} (struct align_pair_${joined});"
if { $lang == "c++" } {
- puts $outfile "DEF_WITH_STATIC ($utype, $uinner);"
- set joined "${utype}_x_${uinner}"
- puts $outfile "struct align_pair_static_$joined item_static_${joined};"
- puts $outfile "unsigned a_static_${joined}"
- puts $outfile " = ${align_func} (struct align_pair_static_${joined});"
+ puts $outfile "DEF_WITH_1_STATIC ($utype, $uinner);"
+ set joined "static_${utype}_x_${uinner}"
+ puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "unsigned a_${joined}"
+ puts $outfile " = ${align_func} (struct align_pair_${joined});"
+
+ puts $outfile "DEF_WITH_2_STATIC ($utype, $uinner);"
+ set joined "static_${utype}_x_static_${uinner}"
+ puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "unsigned a_${joined}"
+ puts $outfile " = ${align_func} (struct align_pair_${joined});"
}
}
}
@@ -160,6 +168,10 @@ proc run_alignment_test { lang } {
set expected [get_integer_valueof a_static_${utype}_x_${uinner} 0]
gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_${uinner})" \
" = $expected"
+
+ set expected [get_integer_valueof a_static_${utype}_x_static_${uinner} 0]
+ gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_static_${uinner})" \
+ " = $expected"
}
}
}