|
|
0a406a |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
0a406a |
From: Simon Marchi <simon.marchi@efficios.com>
|
|
|
0a406a |
Date: Tue, 4 May 2021 11:20:09 -0400
|
|
|
0a406a |
Subject: gdb-flexible-array-member-expected-pattern.patch
|
|
|
0a406a |
|
|
|
0a406a |
;; Backport "adjust gdb.python/flexible-array-member.exp expected pattern"
|
|
|
0a406a |
;; (Simon Marchi)
|
|
|
0a406a |
|
|
|
0a406a |
The `Type.range ()` tests in gdb.python/flexible-array-member.exp pass
|
|
|
0a406a |
when the test is compiled with gcc 9 or later, but not with gcc 8 or
|
|
|
0a406a |
earlier:
|
|
|
0a406a |
|
|
|
0a406a |
$ make check TESTS="gdb.python/flexible-array-member.exp" RUNTESTFLAGS="CC_FOR_TARGET='gcc-8'"
|
|
|
0a406a |
|
|
|
0a406a |
python print(zs['items'].type.range())^M
|
|
|
0a406a |
(0, 0)^M
|
|
|
0a406a |
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zs['items'].type.range())
|
|
|
0a406a |
python print(zso['items'].type.range())^M
|
|
|
0a406a |
(0, 0)^M
|
|
|
0a406a |
(gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zso['items'].type.range())
|
|
|
0a406a |
|
|
|
0a406a |
The value that we get for the upper bound of a flexible array member
|
|
|
0a406a |
declared with a "0" size is 0 with gcc <= 8 and is -1 for gcc >= 9.
|
|
|
0a406a |
This is due to different debug info. For this member, gcc 8 does:
|
|
|
0a406a |
|
|
|
0a406a |
0x000000d5: DW_TAG_array_type
|
|
|
0a406a |
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
|
|
|
0a406a |
DW_AT_sibling [DW_FORM_ref4] (0x000000e4)
|
|
|
0a406a |
|
|
|
0a406a |
0x000000de: DW_TAG_subrange_type
|
|
|
0a406a |
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
|
|
|
0a406a |
|
|
|
0a406a |
For the same type, gcc 9 does:
|
|
|
0a406a |
|
|
|
0a406a |
0x000000d5: DW_TAG_array_type
|
|
|
0a406a |
DW_AT_type [DW_FORM_ref4] (0x00000034 "int")
|
|
|
0a406a |
DW_AT_sibling [DW_FORM_ref4] (0x000000e5)
|
|
|
0a406a |
|
|
|
0a406a |
0x000000de: DW_TAG_subrange_type
|
|
|
0a406a |
DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int")
|
|
|
0a406a |
DW_AT_count [DW_FORM_data1] (0x00)
|
|
|
0a406a |
|
|
|
0a406a |
Ideally, GDB would present a consistent and documented value for an
|
|
|
0a406a |
array member declared with size 0, regardless of how the debug info
|
|
|
0a406a |
looks like. But for now, just change the test to accept the two
|
|
|
0a406a |
values, to get rid of the failure and make the test in sync
|
|
|
0a406a |
|
|
|
0a406a |
I also realized (by looking at the py-type.exp test) that calling the
|
|
|
0a406a |
fields method on an array type yields one field representing the "index"
|
|
|
0a406a |
of the array. The type of that field is of type range
|
|
|
0a406a |
(gdb.TYPE_CODE_RANGE). When calling `.range()` on that range type, it
|
|
|
0a406a |
yields the same range tuple as when calling `.range()` on the array type
|
|
|
0a406a |
itself. For completeness, add some tests to access the range tuple
|
|
|
0a406a |
through that range type as well.
|
|
|
0a406a |
|
|
|
0a406a |
gdb/testsuite/ChangeLog:
|
|
|
0a406a |
|
|
|
0a406a |
* gdb.python/flexible-array-member.exp: Adjust expected range
|
|
|
0a406a |
value for member declared with 0 size. Test accessing range
|
|
|
0a406a |
tuple through range type.
|
|
|
0a406a |
|
|
|
0a406a |
Change-Id: Ie4e06d99fe9315527f04577888f48284d649ca4c
|
|
|
0a406a |
|
|
|
0a406a |
diff --git a/gdb/testsuite/gdb.python/flexible-array-member.exp b/gdb/testsuite/gdb.python/flexible-array-member.exp
|
|
|
0a406a |
--- a/gdb/testsuite/gdb.python/flexible-array-member.exp
|
|
|
0a406a |
+++ b/gdb/testsuite/gdb.python/flexible-array-member.exp
|
|
|
0a406a |
@@ -76,9 +76,17 @@ gdb_test "python print(zso\['items'\] == zso\['items'\]\[0\].address)" "True"
|
|
|
0a406a |
gdb_test "python print(zso\['items'\]\[0\].address + 1 == zso\['items'\]\[1\].address)" "True"
|
|
|
0a406a |
|
|
|
0a406a |
# Verify the range attribute. It looks a bit inconsistent that the high bound
|
|
|
0a406a |
-# is sometimes 0, sometimes -1, but that's what GDB produces today, so that's
|
|
|
0a406a |
-# what we test.
|
|
|
0a406a |
+# is sometimes 0, sometimes -1. It depends on the way the flexible array
|
|
|
0a406a |
+# member is specified and on the compiler version (the debug info is
|
|
|
0a406a |
+# different). But that's what GDB produces today, so that's what we test.
|
|
|
0a406a |
|
|
|
0a406a |
gdb_test "python print(ns\['items'\].type.range())" "\\(0, 0\\)"
|
|
|
0a406a |
-gdb_test "python print(zs\['items'\].type.range())" "\\(0, -1\\)"
|
|
|
0a406a |
-gdb_test "python print(zso\['items'\].type.range())" "\\(0, -1\\)"
|
|
|
0a406a |
+gdb_test "python print(zs\['items'\].type.range())" "\\(0, (0|-1)\\)"
|
|
|
0a406a |
+gdb_test "python print(zso\['items'\].type.range())" "\\(0, (0|-1)\\)"
|
|
|
0a406a |
+
|
|
|
0a406a |
+# Test the same thing, but going explicitly through the array index's range
|
|
|
0a406a |
+# type.
|
|
|
0a406a |
+
|
|
|
0a406a |
+gdb_test "python print(ns\['items'\].type.fields()\[0\].type.range())" "\\(0, 0\\)"
|
|
|
0a406a |
+gdb_test "python print(zs\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"
|
|
|
0a406a |
+gdb_test "python print(zso\['items'\].type.fields()\[0\].type.range())" "\\(0, (0|-1)\\)"
|