aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-04-07 14:46:18 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-04-07 21:12:13 +0100
commit3fb842cea15503ed101c2d5adb77068206d3d684 (patch)
tree1c8fe5ae99f2e80bcd37a3b70d219a8be40f7d3c /gdb/testsuite
parent9be5d742dbe3d23f740bbeb5bd1337da8ece536e (diff)
downloadgdb-3fb842cea15503ed101c2d5adb77068206d3d684.zip
gdb-3fb842cea15503ed101c2d5adb77068206d3d684.tar.gz
gdb-3fb842cea15503ed101c2d5adb77068206d3d684.tar.bz2
gdb/fortran: fix fetching assumed rank array content
Commit: commit df7a7bdd9766adebc6b117c31bc617d81c1efd43 Date: Thu Mar 17 18:56:23 2022 +0000 gdb: add support for Fortran's ASSUMED RANK arrays Added support for Fortran assumed rank arrays. Unfortunately, this commit contained a bug that means though GDB can correctly calculate the rank of an assumed rank array, GDB can't fetch the contents of an assumed rank array. The history of this patch can be seen on the mailing list here: https://sourceware.org/pipermail/gdb-patches/2022-January/185306.html The patches that were finally committed can be found here: https://sourceware.org/pipermail/gdb-patches/2022-March/186906.html The original patches did support fetching the array contents, it was only the later series that introduced the regression. The problem is that when calculating the array rank the result is a count of the number of ranks, i.e. this is a 1 based result, 1, 2, 3, etc. In contrast, when computing the details of any particular rank the value passed to the DWARF expression evaluator should be a 0 based rank offset, i.e. a 0 based number, 0, 1, 2, etc. In the patches that were originally merged, this was not the case, and we were passing the 1 based rank number to the expression evaluator, e.g. passing 1 when we should pass 0, 2 when we should pass 1, etc. As a result the DWARF expression evaluator was reading the wrong (undefined) memory, and returning garbage results. In this commit I have extended the test case to cover checking the array contents, I've then ensured we make use of the correct rank value, and extended some comments, and added or adjusted some asserts as appropriate.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.fortran/assumedrank.exp29
-rw-r--r--gdb/testsuite/gdb.fortran/assumedrank.f905
2 files changed, 23 insertions, 11 deletions
diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.fortran/assumedrank.exp
index ac5159c..69cd168 100644
--- a/gdb/testsuite/gdb.fortran/assumedrank.exp
+++ b/gdb/testsuite/gdb.fortran/assumedrank.exp
@@ -62,21 +62,28 @@ while { $test_count < 500 } {
break
}
- # First grab the expected answer.
- set answer [get_valueof "" "rank(answer)" "**unknown**"]
-
- # Now move up a frame and figure out a command for us to run
- # as a test.
- set command ""
- gdb_test_multiple "up" "up" {
- -re -wrap "\r\n\[0-9\]+\[ \t\]+call test_rank (\[^\r\n\]+)" {
- set command $expect_out(1,string)
+ # First grab the information from the assumed rank array.
+ set answer_rank [get_valueof "" "rank(answer)" "**unknown**"]
+ set answer_content [get_valueof "" "answer" "**unknown**"]
+
+ # Now move up a frame and find the name of a non-assumed rank array
+ # which we can use to check the values we got above.
+ set test_array ""
+ gdb_test_multiple "up" "" {
+ -re -wrap "\r\n\[0-9\]+\[ \t\]+call test_rank \\((\[^\r\n\]+)\\)" {
+ set test_array $expect_out(1,string)
}
}
+ gdb_assert { ![string equal $test_array ""] } \
+ "found the name of a test array to check against"
- gdb_assert { ![string equal $command ""] } "found a command to run"
+ # Check we got the correct array rank.
+ gdb_test "p rank($test_array)" " = $answer_rank"
- gdb_test "p rank($command)" " = ($answer)"
+ # Check we got the correct array content.
+ set content [get_valueof "" "$test_array" "**unknown**"]
+ gdb_assert { [string equal $content $answer_content] } \
+ "answer array contains the expected contents"
}
}
diff --git a/gdb/testsuite/gdb.fortran/assumedrank.f90 b/gdb/testsuite/gdb.fortran/assumedrank.f90
index 16f2ee7..7f077c3 100644
--- a/gdb/testsuite/gdb.fortran/assumedrank.f90
+++ b/gdb/testsuite/gdb.fortran/assumedrank.f90
@@ -24,6 +24,11 @@ PROGRAM arank
REAL :: array3(3, 4, 5)
REAL :: array4(4, 5, 6, 7)
+ array1 = 1.0
+ array2 = 2.0
+ array3 = 3.0
+ array4 = 4.0
+
call test_rank (array1)
call test_rank (array2)
call test_rank (array3)