# Test pointer arithmethic
# First, obtain the pointers
- gdb_test "print (void *) 2" "" ""
+ gdb_test "print (void *) 2" ".*" ""
gdb_test_no_output "python a = gdb.history (0)" ""
- gdb_test "print (void *) 5" "" ""
+ gdb_test "print (void *) 5" ".*" ""
gdb_test_no_output "python b = gdb.history (0)" ""
gdb_test "python print 'result = ' + str(a+5)" " = 0x7" "add pointer value with python integer"
}
+proc test_inferior_function_call {} {
+ global gdb_prompt hex decimal
+
+ # Correct inferior call without arguments.
+ gdb_test "p/x fp1" " = $hex.*"
+ gdb_py_test_silent_cmd "python fp1 = gdb.history (0)" "get value from history" 1
+ gdb_test "python fp1 = fp1.dereference()" ""
+ gdb_test "python result = fp1()" ""
+ gdb_test "python print result" "void"
+
+ # Correct inferior call with arguments.
+ gdb_test "p/x fp2" " = $hex.*"
+ gdb_py_test_silent_cmd "python fp2 = gdb.history (0)" "get value from history" 1
+ gdb_test "python fp2 = fp2.dereference()" ""
+ gdb_test "python result2 = fp2(10,20)" ""
+ gdb_test "python print result2" "30"
+
+ # Incorrect to call an int value.
+ gdb_test "p i" " = $decimal.*"
+ gdb_py_test_silent_cmd "python i = gdb.history (0)" "get value from history" 1
+ gdb_test "python result3 = i()" ".*Value is not callable.*"
+
+ # Incorrect number of arguments.
+ gdb_test "p/x fp2" " = $hex.*"
+ gdb_py_test_silent_cmd "python fp3 = gdb.history (0)" "get value from history" 1
+ gdb_test "python fp3 = fp3.dereference()" ""
+ gdb_test "python result2 = fp3(10)" ".*Too few arguments in function call.*"
+}
+
# A few objfile tests.
proc test_objfiles {} {
gdb_test "python\nok=False\nfor file in gdb.objfiles():\n if 'py-value' in file.filename:\n ok=True\nprint ok\nend" "True"
gdb_py_test_silent_cmd "python rptr = gdb.history(0)" \
"Obtains value from GDB" 1
gdb_test "python print rptr\[0\]" "2" "Check pointer passed as reference"
+
+ # Just the most basic test of dynamic_cast -- it is checked in
+ # the C++ tests.
+ gdb_test "python print bool(gdb.parse_and_eval('base').dynamic_cast(gdb.lookup_type('Derived').pointer()))" \
+ True
+
+ # Likewise.
+ gdb_test "python print gdb.parse_and_eval('base').dynamic_type" \
+ "Derived \[*\]"
+ # A static type case.
+ gdb_test "python print gdb.parse_and_eval('5').dynamic_type" \
+ "int"
}
gdb_breakpoint [gdb_get_line_number "break to inspect struct and union"]
}
test_value_in_inferior
+test_inferior_function_call
test_lazy_strings
test_value_after_death