aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-value.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python/py-value.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-value.exp61
1 files changed, 55 insertions, 6 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 93985a9..087c8c2 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -297,9 +297,9 @@ proc test_value_in_inferior {} {
gdb_test "print argc" " = $argc_value" "sanity check argc"
gdb_test "python print (argc_lazy.is_lazy)" "\r\nTrue" \
"python print (argc_lazy.is_lazy) the second time"
- gdb_test_no_output "set argc=[expr $argc_value + 1]" "change argc"
+ gdb_test_no_output "set argc=[expr {$argc_value + 1}]" "change argc"
gdb_test "python print (argc_notlazy)" "\r\n$argc_value"
- gdb_test "python print (argc_lazy)" "\r\n[expr $argc_value + 1]"
+ gdb_test "python print (argc_lazy)" "\r\n[expr {$argc_value + 1}]"
gdb_test "python print (argc_lazy.is_lazy)" "False"
# Test string fetches, both partial and whole.
@@ -431,7 +431,8 @@ proc test_value_after_death {} {
proc test_subscript_regression {exefile lang} {
# Start with a fresh gdb.
- clean_restart ${exefile}
+ clean_restart
+ gdb_load $exefile
if {![runto_main]} {
return
@@ -457,6 +458,8 @@ proc test_subscript_regression {exefile lang} {
"Derived \[*\]"
gdb_test "python print (gdb.parse_and_eval('base_ref').dynamic_type)" \
"Derived \[&\]"
+ gdb_test "python print (gdb.parse_and_eval('pod').dynamic_type)" \
+ "str"
# A static type case.
gdb_test "python print (gdb.parse_and_eval('5').dynamic_type)" \
"int"
@@ -595,7 +598,7 @@ proc test_value_from_buffer {} {
gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0
gdb_test "python vabig=gdb.Value(b,atpbig)" \
"ValueError.*: Size of type is larger than that of buffer object\..*" \
- "attempt to construct large value with small buffer"
+ "attempt to construct large value with small buffer"
gdb_test "python v=gdb.Value(2048,tp)" \
"TypeError.*: Object must support the python buffer protocol\..*" \
"attempt to construct value from buffer with non-buffer object"
@@ -680,6 +683,7 @@ proc_with_prefix test_value_bytes { } {
"python" "" \
"def check_value_bytes(var_name):" "" \
" val = gdb.parse_and_eval(var_name)" "" \
+ " assert not val.is_unavailable" "" \
" addr = val.address" "" \
" len = val.type.sizeof" "" \
" mem = gdb.selected_inferior().read_memory(addr, len)" "" \
@@ -762,13 +766,45 @@ proc test_assign {} {
"cannot assign to integer"
}
+# Test Value.is_unavailable
+proc test_unavailable {} {
+ set elem_size [get_valueof "/d" "sizeof(long_array\[0\])" "UNKNOWN" \
+ "get size of long_array element"]
+ set max [expr {$elem_size * 10}]
+
+ with_set "print elements" 5 {
+ with_max_value_size $max {
+ gdb_test "p long_array"
+
+ gdb_test_no_output "set print elements 15"
+
+ gdb_test_no_output "python v = gdb.history(0)"
+
+ gdb_test "python print(v.is_unavailable)" "^True" \
+ "overall object shows as unavailable"
+ for { set i 0 } { $i < 10 } { incr i } {
+ gdb_test "python print(v\[$i\].is_unavailable)" "^False" \
+ "array element $i is available"
+ gdb_test "python print(v\[$i\])" "^$i" \
+ "array element $i has correct value"
+ }
+ for { set i 10 } { $i < 15 } { incr i } {
+ gdb_test "python print(v\[$i\].is_unavailable)" "^True" \
+ "array element $i is unavailable"
+ gdb_test "python print(v\[$i\])" "^<unavailable>" \
+ "array element $i shows as unavailable"
+ }
+ }
+ }
+}
+
# Build C version of executable. C++ is built later.
if { [build_inferior "${binfile}" "c"] < 0 } {
return -1
}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart ${::testfile}
test_history_count
test_value_creation
@@ -788,6 +824,7 @@ if {![runto_main]} {
return 0
}
+test_unavailable
test_value_in_inferior
test_value_from_buffer
test_value_sub_classes
@@ -797,7 +834,7 @@ test_assign
test_value_bytes
test_value_after_death
-# Test either C or C++ values.
+# Test either C or C++ values.
test_subscript_regression "${binfile}" "c"
@@ -809,3 +846,15 @@ if {[allow_cplus_tests]} {
test_subscript_regression "${binfile}-cxx" "c++"
}
}
+
+if {[allow_rust_tests]} {
+ gdb_test "set lang rust"
+
+ set cst 0x80000000000000000000000000000000
+ gdb_test "python print(int(gdb.parse_and_eval('${cst}u128')))" \
+ "170141183460469231731687303715884105728" \
+ "convert 128 bit unsigned constant to python int"
+ gdb_test "python print(int(gdb.parse_and_eval('${cst}i128')))" \
+ "-170141183460469231731687303715884105728" \
+ "convert 128 bit signed constant to python int"
+}