]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/value-history-unavailable.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / value-history-unavailable.exp
1 # Copyright (C) 2023-2024 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # Test GDB's value availability ranges.
17
18 standard_testfile
19
20 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
21 return -1
22 }
23
24 if ![runto_main] then {
25 perror "couldn't run to breakpoint"
26 continue
27 }
28
29 set target_char_mask [get_valueof "/u" "a.x\[0]" "255" "get target char mask"]
30 set target_char_bit 0
31 for {set i $target_char_mask} {$i > 0} {set i [expr $i >> 1]} {
32 incr target_char_bit
33 }
34 set target_char_rank -1
35 for {set i $target_char_bit} {$i > 0} {set i [expr $i >> 1]} {
36 incr target_char_rank
37 }
38
39 # Verify accesses to original inferior data.
40 gdb_test "print a.a" "\\\$2 = '\\\\000' <repeats 1023 times>"
41 gdb_test "print a.a\[-1\]" "\\\$3 = 0 '\\\\000'"
42 gdb_test "print a.a\[1024\]" "\\\$4 = 0 '\\\\000'"
43
44 # Verify in-range value history accesses.
45 gdb_test "print \$2" "\\\$5 = '\\\\000' <repeats 1023 times>"
46 gdb_test "print \$2\[0\]" "\\\$6 = 0 '\\\\000'"
47 gdb_test "print \$2\[1023\]" "\\\$7 = 0 '\\\\000'"
48
49 # Values outside the array recorded will have not been retrieved.
50 gdb_test "print \$2\[-1\]" "\\\$8 = <unavailable>"
51 gdb_test "print \$2\[1024\]" "\\\$9 = <unavailable>"
52 gdb_test "print \$2\[-1LL << 63 - $target_char_rank\]" \
53 "\\\$10 = <unavailable>"
54 gdb_test "print \$2\[(1LL << 63 - $target_char_rank) - 1\]" \
55 "\\\$11 = <unavailable>"
56
57 # Accesses through pointers in history go straight to the inferior though.
58 gdb_test "print \$2\[0\]@1" "\\\$12 = \"\""
59 gdb_test "print \$2\[-1\]@1" "\\\$13 = \"\""
60 gdb_test "print \$2\[1024\]@1" "\\\$14 = \"\""
61
62 # Verify out-of-range value history accesses.
63 gdb_test "print \$2\[(-1LL << 63 - $target_char_rank) - 1\]" \
64 "Integer overflow in data location calculation"
65 gdb_test "print \$2\[(1LL << 63 - $target_char_rank)\]" \
66 "Integer overflow in data location calculation"
67 gdb_test "print \$2\[-1LL << 63\]" \
68 "Integer overflow in data location calculation"
69 gdb_test "print \$2\[(1ULL << 63) - 1\]" \
70 "Integer overflow in data location calculation"
71
72 # Sanity-check a copy of an unavailable value.
73 gdb_test "print \$11" "\\\$15 = <unavailable>"