gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-value.exp
index 39a456f33b82bba4d463b3247cfda1b96e2b228d..0ecb57c66b06bbc4feafb450981fde749c7f7938 100644 (file)
@@ -122,9 +122,9 @@ proc test_value_numeric_ops {} {
   # 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"
@@ -276,6 +276,35 @@ proc test_lazy_strings {} {
 }
 
 
+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"
@@ -345,6 +374,18 @@ proc test_subscript_regression {lang} {
      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"]
@@ -435,6 +476,7 @@ if ![runto_main] then {
 }
 
 test_value_in_inferior
+test_inferior_function_call
 test_lazy_strings
 test_value_after_death
 
This page took 0.032917 seconds and 4 git commands to generate.