home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / testsuite / gdb.t17 / callfuncs.exp next >
Encoding:
Text File  |  1993-05-12  |  5.8 KB  |  173 lines

  1. # Copyright (C) 1992 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 2 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  14.  
  15. # Please email any bugs, comments, and/or additions to this file to:
  16. # bug-gdb@prep.ai.mit.edu
  17.  
  18. # This file was written by Fred Fish. (fnf@cygnus.com)
  19.  
  20. if $tracelevel then {
  21.     strace $tracelevel
  22. }
  23.  
  24. set prms_id 0
  25. set bug_id 0
  26.  
  27. set binfile "gdbme"
  28. set srcfile $binfile.c
  29.  
  30. if ![file exists $objdir/$subdir/$binfile] then {
  31.     error "$objdir/$subdir/$binfile does not exist"
  32.     continue
  33. }
  34.  
  35. # The a29k can't call functions, so don't even bother with this test.
  36. if [istarget "a29k-*-udi"] then {
  37.     setup_xfail "a29k-*-udi" 2416
  38.     fail "a29k-*-udi can not call functions"
  39.     continue
  40. }
  41.  
  42. # Set the current language to C.  This counts as a test.  If it
  43. # fails, then we skip the other tests.
  44.  
  45. proc set_lang_c {} {
  46.     global prompt
  47.  
  48.     send "set language c\n"
  49.     expect {
  50.     -re ".*$prompt $" {}
  51.     timeout { fail "set language c (timeout)" ; return 0 }
  52.     }
  53.  
  54.     send "show language\n"
  55.     expect {
  56.     -re ".* source language is \"c\".*$prompt $" {
  57.         pass "set language to \"c\""
  58.         return 1
  59.     }
  60.     -re ".*$prompt $" {
  61.         fail "setting language to \"c\""
  62.         return 0
  63.     }
  64.     timeout {
  65.         fail "can't show language (timeout)"
  66.         return 0
  67.     }
  68.     }
  69. }
  70.  
  71. # FIXME:  Before calling this proc, we should probably verify that
  72. # we can call inferior functions and get a valid integral value
  73. # returned.
  74. # Note that it is OK to check for 0 or 1 as the returned values, because C
  75. # specifies that the numeric value of a relational or logical expression
  76. # (computed in the inferior) is 1 for true and 0 for false.
  77.  
  78. proc do_function_calls {} {
  79.  
  80.     gdb_test "p t_char_values(0,0)" " = 0"
  81.     gdb_test "p t_char_values('a','b')" " = 1"
  82.     gdb_test "p t_char_values(char_val1,char_val2)" " = 1"
  83.     gdb_test "p t_char_values('a',char_val2)" " = 1"
  84.     gdb_test "p t_char_values(char_val1,'b')" " = 1"
  85.  
  86.     gdb_test "p t_short_values(0,0)" " = 0"
  87.     gdb_test "p t_short_values(10,-23)" " = 1"
  88.     gdb_test "p t_short_values(short_val1,short_val2)" " = 1"
  89.     gdb_test "p t_short_values(10,short_val2)" " = 1"
  90.     gdb_test "p t_short_values(short_val1,-23)" " = 1"
  91.  
  92.     gdb_test "p t_int_values(0,0)" " = 0"
  93.     gdb_test "p t_int_values(87,-26)" " = 1"
  94.     gdb_test "p t_int_values(int_val1,int_val2)" " = 1"
  95.     gdb_test "p t_int_values(87,int_val2)" " = 1"
  96.     gdb_test "p t_int_values(int_val1,-26)" " = 1"
  97.  
  98.     gdb_test "p t_long_values(0,0)" " = 0"
  99.     gdb_test "p t_long_values(789,-321)" " = 1"
  100.     gdb_test "p t_long_values(long_val1,long_val2)" " = 1"
  101.     gdb_test "p t_long_values(789,long_val2)" " = 1"
  102.     gdb_test "p t_long_values(long_val1,-321)" " = 1"
  103.  
  104.     gdb_test "p t_float_values(0.0,0.0)" " = 0"
  105.     gdb_test "p t_float_values(3.14159,-2.3765)" " = 1"
  106.     gdb_test "p t_float_values(float_val1,float_val2)" " = 1"
  107.     gdb_test "p t_float_values(3.14159,float_val2)" " = 1"
  108.     gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
  109.  
  110.     gdb_test "p t_double_values(0.0,0.0)" " = 0"
  111.     gdb_test "p t_double_values(45.654,-67.66)" " = 1"
  112.     gdb_test "p t_double_values(double_val1,double_val2)" " = 1"
  113.     gdb_test "p t_double_values(45.654,double_val2)" " = 1"
  114.     gdb_test "p t_double_values(double_val1,-67.66)" " = 1"
  115.  
  116.     gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
  117.     gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
  118.     gdb_test "p t_string_values(\\\"string 1\\\",\\\"string 2\\\")" " = 1"
  119.     gdb_test "p t_string_values(\\\"string 1\\\",string_val2)" " = 1"
  120.     gdb_test "p t_string_values(string_val1,\\\"string 2\\\")" " = 1"
  121.  
  122.     gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
  123.     gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
  124.     gdb_test "p t_char_array_values(\\\"carray 1\\\",\\\"carray 2\\\")" " = 1"
  125.     gdb_test "p t_char_array_values(\\\"carray 1\\\",char_array_val2)" " = 1"
  126.     gdb_test "p t_char_array_values(char_array_val1,\\\"carray 2\\\")" " = 1"
  127.  
  128.     gdb_test "p doubleit(4)" " = 8"
  129.     gdb_test "p add(4,5)" " = 9"
  130.     gdb_test "p t_func_values(func_val2,func_val1)" " = 0"
  131.     gdb_test "p t_func_values(func_val1,func_val2)" " = 1"
  132.     gdb_test "p t_func_values(add,func_val2)" " = 1"
  133.     gdb_test "p t_func_values(func_val1,doubleit)" " = 1"
  134.     gdb_test "p t_call_add(func_val1,3,4)" " = 7"
  135.     gdb_test "p t_call_add(add,3,4)" " = 7"
  136.  
  137.     gdb_test "p t_enum_value1(enumval1)" " = 1"
  138.     gdb_test "p t_enum_value1(enum_val1)" " = 1"
  139.     gdb_test "p t_enum_value1(enum_val2)" " = 0"
  140.  
  141.     gdb_test "p t_enum_value2(enumval2)" " = 1"
  142.     gdb_test "p t_enum_value2(enum_val2)" " = 1"
  143.     gdb_test "p t_enum_value2(enum_val1)" " = 0"
  144.  
  145.     gdb_test "p sum_args(1,{2})" " = 2"
  146.     gdb_test "p sum_args(2,{2,3})" " = 5"
  147.     gdb_test "p sum_args(3,{2,3,4})" " = 9"
  148.     gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
  149. }
  150.  
  151. # Start with a fresh gdb.
  152.  
  153. gdb_exit
  154. gdb_start
  155. gdb_reinitialize_dir $srcdir/$subdir
  156. gdb_load $objdir/$subdir/$binfile
  157.  
  158. send "set print sevenbit-strings\n" ; expect -re "$prompt $"
  159. send "set print address off\n" ; expect -re "$prompt $"
  160. send "set width 0\n" ; expect -re "$prompt $"
  161.  
  162. if [set_lang_c] then {
  163.     if [runto main] then {
  164.     do_function_calls
  165.     } else {
  166.     fail "C function calling tests suppressed"
  167.     }
  168. } else {
  169.     fail "C function calling tests suppressed"
  170. }
  171.