From 61e635a444088acc4dc68794257a291f16e3fe6d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 5 Jan 1999 21:58:18 +0000 Subject: [PATCH] hp merge changes; mostly new files. scope.exp, langs.exp, list.exp -- compile one file at a time, then link. default.exp -- change expected messages for catch and info catch tests to reflect hp merge changes. --- gdb/testsuite/gdb.base/default.exp | 4 +- .../gdb.base/enable-disable-break.exp | 525 ++++++++++++++++++ gdb/testsuite/gdb.base/pointers2.exp | 288 ++++++++++ gdb/testsuite/gdb.base/shlib-call2.exp | 240 ++++++++ 4 files changed, 1055 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.base/enable-disable-break.exp create mode 100644 gdb/testsuite/gdb.base/pointers2.exp create mode 100644 gdb/testsuite/gdb.base/shlib-call2.exp diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 7dd9166c269..bc03c1ca781 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -92,7 +92,7 @@ gdb_test "call" "The history is empty..*" "call" #test catch -gdb_test "catch" "No selected frame..*" "catch" +gdb_test "catch" "Catch requires an event name..*" "catch" #test cd gdb_test "cd" "Argument required .new working directory.*" "cd" @@ -273,7 +273,7 @@ gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\" #test info breakpoints gdb_test "info breakpoints" "No breakpoints or watchpoints." "info breakpoints" #test info catch -gdb_test "info catch" "No frame selected." "info catch" +gdb_test "info catch" "You can't do that without a process to debug." "info catch" #test info copying # FIXME -- doesn't work worth a shit #send_gdb "info copying" diff --git a/gdb/testsuite/gdb.base/enable-disable-break.exp b/gdb/testsuite/gdb.base/enable-disable-break.exp new file mode 100644 index 00000000000..6593d824294 --- /dev/null +++ b/gdb/testsuite/gdb.base/enable-disable-break.exp @@ -0,0 +1,525 @@ +# Copyright (C) 1997, 1998 Free Software Foundation, Inc. + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +if $tracelevel then { + strace $tracelevel + } + +global usestubs + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "break" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +# Verify that we can set a breakpoint (the location is irrelevant), +# then enable it (yes, it's already enabled by default), then hit it. +# +send_gdb "break marker1\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\ + {pass "break marker1"} + -re "$gdb_prompt $"\ + {fail "break marker1"} + timeout {fail "(timeout) break marker1"} +} + +send_gdb "enable $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "enable break marker1"} + timeout {fail "(timeout) enable break marker1"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\ + {pass "info break marker1"} + -re "$gdb_prompt $"\ + {fail "info break marker1"} + timeout {fail "(timeout) info break marker1"} +} + +send_gdb "continue\n" +gdb_expect { + -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ + {pass "continue to break marker1"} + -re "$gdb_prompt $"\ + {fail "continue to break marker1"} + timeout {fail "(timeout) continue to break marker1"} +} + +send_gdb "delete $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "delete break marker1"} + timeout {fail "(timeout) delete break marker1"} +} + +# Verify that we can set a breakpoint to be self-disabling after +# the first time it triggers. +# +send_gdb "break marker2\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 42.*$gdb_prompt $"\ + {pass "break marker2"} + -re "$gdb_prompt $"\ + {fail "break marker2"} + timeout {fail "(timeout) break marker2"} +} + +send_gdb "enable once $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "enable once break marker2"} + timeout {fail "(timeout) enable once break marker2"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\ + {pass "info auto-disabled break marker2"} + -re "$gdb_prompt $"\ + {fail "info auto-disabled break marker2"} + timeout {fail "(timeout) info auto-disabled break marker2"} +} + +send_gdb "continue\n" +gdb_expect { + -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\ + {pass "continue to auto-disabled break marker2"} + -re "$gdb_prompt $"\ + {fail "continue to auto-disabled break marker2"} + timeout {fail "(timeout) continue to auto-disabled break marker2"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\ + {pass "info auto-disabled break marker2"} + -re "$gdb_prompt $"\ + {fail "info auto-disabled break marker2"} + timeout {fail "(timeout) info auto-disabled break marker2"} +} + +# Verify that we don't stop at a disabled breakpoint. +# +send_gdb "continue\n" +gdb_expect { + -re ".*Program exited normally.*$gdb_prompt $"\ + {pass "no stop"} + -re "$gdb_prompt $"\ + {fail "no stop"} + timeout {fail "(timeout) no stop"} +} + +send_gdb "run\n" +gdb_expect { + -re "Starting program.*$gdb_prompt $"\ + {pass "rerun to main"} + -re "$gdb_prompt $"\ + {fail "rerun to main"} + timeout {fail "(timeout) rerun to main"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*Program exited normally.*$gdb_prompt $"\ + {pass "no stop at auto-disabled break marker2"} + -re "$gdb_prompt $"\ + {fail "no stop at auto-disabled break marker2"} + timeout {fail "(timeout) no stop at auto-disabled break marker2"} +} + +# Verify that we can set a breakpoint to be self-deleting after +# the first time it triggers. +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +send_gdb "break marker3\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 43.*$gdb_prompt $"\ + {pass "break marker3"} + -re "$gdb_prompt $"\ + {fail "break marker3"} + timeout {fail "(timeout) break marker3"} +} + +send_gdb "enable del $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "enable del break marker3"} + timeout {fail "(timeout) enable del break marker3"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\ + {pass "info auto-deleted break marker2"} + -re "$gdb_prompt $"\ + {fail "info auto-deleted break marker2"} + timeout {fail "(timeout) info auto-deleted break marker2"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*marker3 .*:43.*$gdb_prompt $"\ + {pass "continue to auto-deleted break marker3"} + -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\ + {fail "continue to auto-deleted break marker3"} + -re "$gdb_prompt $"\ + {fail "continue to auto-deleted break marker3"} + timeout {fail "(timeout) continue to break marker3"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\ + {pass "info auto-deleted break marker3"} + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\ + {fail "info auto-deleted break marker3"} + -re "$gdb_prompt $"\ + {fail "info auto-deleted break marker3"} + timeout {fail "(timeout) info auto-deleted break marker3"} +} + +# Verify that we can set a breakpoint and manually disable it (we've +# already proven that disabled bp's don't trigger). +# +send_gdb "break marker4\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 44.*$gdb_prompt $"\ + {pass "break marker4"} + -re "$gdb_prompt $"\ + {fail "break marker4"} + timeout {fail "(timeout) break marker4"} +} + +send_gdb "disable $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "disable break marker4"} + timeout {fail "(timeout) disable break marker4"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\ + {pass "info break marker4"} + -re "$gdb_prompt $"\ + {fail "info break marker4"} + timeout {fail "(timeout) info break marker4"} +} + +# Verify that we can set a breakpoint with an ignore count N, which +# should cause the next N triggers of the bp to be ignored. (This is +# a flavor of enablement/disablement, after all.) +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +send_gdb "break marker1\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\ + {pass "break marker1"} + -re "$gdb_prompt $"\ + {fail "break marker1"} + timeout {fail "(timeout) break marker1"} +} + +# Verify that an ignore of a non-existent breakpoint is gracefully +# handled. +# +send_gdb "ignore 999 2\n" +gdb_expect { + -re "No breakpoint number 999..*$gdb_prompt $"\ + {pass "ignore non-existent break"} + -re "$gdb_prompt $"\ + {fail "ignore non-existent break"} + timeout {fail "(timeout) ignore non-existent break"} +} + +# Verify that a missing ignore count is gracefully handled. +# +send_gdb "ignore $expect_out(1,string) \n" +gdb_expect { + -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\ + {pass "ignore break with missing ignore count"} + -re "$gdb_prompt $"\ + {fail "ignore break with missing ignore count"} + timeout {fail "(timeout) ignore break with missing ignore count"} +} + +# Verify that a negative or zero ignore count is handled gracefully +# (they both are treated the same). +# +send_gdb "ignore $expect_out(1,string) -1\n" +gdb_expect { + -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\ + {pass "ignore break marker1 -1"} + -re "$gdb_prompt $"\ + {fail "ignore break marker1 -1"} + timeout {fail "(timeout) ignore break marker1 -1"} +} + +send_gdb "ignore $expect_out(1,string) 0\n" +gdb_expect { + -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\ + {pass "ignore break marker1 0"} + -re "$gdb_prompt $"\ + {fail "ignore break marker1 0"} + timeout {fail "(timeout) ignore break marker1 0"} +} + +send_gdb "ignore $expect_out(1,string) 1\n" +gdb_expect { + -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "ignore break marker1"} + -re "$gdb_prompt $"\ + {fail "ignore break marker1"} + timeout {fail "(timeout) ignore break marker1"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\ + {pass "info ignored break marker1"} + -re "$gdb_prompt $"\ + {fail "info ignored break marker1"} + timeout {fail "(timeout) info ignored break marker1"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*Program exited normally.*$gdb_prompt $"\ + {pass "no stop at ignored break marker1"} + -re "$gdb_prompt $"\ + {fail "no stop at ignored break marker1"} + timeout {fail "(timeout) no stop at ignored break marker1"} +} + +send_gdb "run\n" +gdb_expect { + -re "Starting program.*$gdb_prompt $"\ + {pass "rerun to main"} + -re "$gdb_prompt $"\ + {fail "rerun to main"} + timeout {fail "(timeout) rerun to main"} +} + +send_gdb "continue\n" +gdb_expect { + -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ + {pass "continue to break marker1"} + -re "$gdb_prompt $"\ + {fail "continue to break marker1"} + timeout {fail "(timeout) continue to break marker1"} +} + +# Verify that we can specify both an ignore count and an auto-delete. +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +send_gdb "break marker1\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\ + {pass "break marker1"} + -re "$gdb_prompt $"\ + {fail "break marker1"} + timeout {fail "(timeout) break marker1"} +} + +send_gdb "ignore $expect_out(1,string) 1\n" +gdb_expect { + -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "ignore break marker1"} + -re "$gdb_prompt $"\ + {fail "ignore break marker1"} + timeout {fail "(timeout) ignore break marker1"} +} + +send_gdb "enable del $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "enable del break marker1"} + timeout {fail "(timeout) enable del break marker1"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\ + {pass "info break marker1"} + -re "$gdb_prompt $"\ + {fail "info break marker1"} + timeout {fail "(timeout) info break marker2"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*Program exited normally.*$gdb_prompt $"\ + {pass "no stop at ignored & auto-deleted break marker1"} + -re "$gdb_prompt $"\ + {fail "no stop at ignored & auto-deleted break marker1"} + timeout {fail "(timeout) no stop at ignored & auto-deleted break marker1"} +} + +send_gdb "run\n" +gdb_expect { + -re "Starting program.*$gdb_prompt $"\ + {pass "rerun to main"} + -re "$gdb_prompt $"\ + {fail "rerun to main"} + timeout {fail "(timeout) rerun to main"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*marker1 .*:41.*$gdb_prompt $"\ + {pass "continue to ignored & auto-deleted break marker1"} + -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ + {fail "continue to ignored & auto-deleted break marker1"} + -re "$gdb_prompt $"\ + {fail "continue to ignored & auto-deleted break marker1"} + timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"} +} + +# Verify that a disabled breakpoint's ignore count isn't updated when +# the bp is encountered. +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +send_gdb "break marker1\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\ + {pass "break marker1"} + -re "$gdb_prompt $"\ + {fail "break marker1"} + timeout {fail "(timeout) break marker1"} +} + +send_gdb "ignore $expect_out(1,string) 10\n" +gdb_expect { + -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "ignore break marker1"} + -re "$gdb_prompt $"\ + {fail "ignore break marker1"} + timeout {fail "(timeout) ignore break marker1"} +} + +send_gdb "disable $expect_out(1,string)\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "disable break marker1"} + timeout {fail "(timeout) disable break marker1"} +} + +send_gdb "continue\n" +gdb_expect { + -re ".*Program exited normally.*$gdb_prompt $"\ + {pass "no stop at ignored & disabled break marker1"} + -re "$gdb_prompt $"\ + {fail "no stop at ignored & disabled break marker1"} + timeout {fail "(timeout) no stop at ignored & disabled break marker1"} +} + +send_gdb "run\n" +gdb_expect { + -re "Starting program.*$gdb_prompt $"\ + {pass "rerun to main"} + -re "$gdb_prompt $"\ + {fail "rerun to main"} + timeout {fail "(timeout) rerun to main"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\ + {pass "info ignored & disabled break marker1"} + -re "$gdb_prompt $"\ + {fail "info ignored & disabled break marker1"} + timeout {fail "(timeout) info ignored & disabled break marker1"} +} + +# Verify that GDB correctly handles the "continue" command with an argument, +# which is an ignore count to set on the currently stopped-at breakpoint. +# (Also verify that GDB gracefully handles the case where the inferior +# isn't stopped at a breakpoint.) +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +send_gdb "break 64\n" +gdb_expect { + -re "Breakpoint \[0-9\]*.*, line 64.*$gdb_prompt $"\ + {pass "prepare to continue with ignore count"} + -re "$gdb_prompt $"\ + {fail "prepare to continue with ignore count"} + timeout {fail "(timeout) prepare to continue with ignore count"} +} +send_gdb "continue 2\n" +gdb_expect { + -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\ + {pass "continue with ignore count"} + -re "$gdb_prompt $"\ + {fail "continue with ignore count"} + timeout {fail "(timeout) continue with ignore count"} +} + +send_gdb "next\n" +gdb_expect { + -re ".*66\[ \t\]*marker1.*$gdb_prompt $"\ + {pass "step after continue with ignore count"} + -re "$gdb_prompt $"\ + {fail "step after continue with ignore count"} + timeout {fail "(timeout) step after continue with ignore count"} +} + +# ??rehrauer: Huh. This appears to be an actual bug. (No big +# surprise, since this feature hasn't been tested...) Looks like +# GDB is currently trying to set the ignore count of bp # -1! +# +setup_xfail hppa_*_* +send_gdb "continue 2\n" +gdb_expect { + -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\ + {pass "continue with ignore count, not stopped at bpt"} + -re "No breakpoint number -1.*$gdb_prompt $"\ + {xfail "(DTS'd) continue with ignore count, not stopped at bpt"} + -re "$gdb_prompt $"\ + {fail "continue with ignore count, not stopped at bpt"} + timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"} +} + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.base/pointers2.exp b/gdb/testsuite/gdb.base/pointers2.exp new file mode 100644 index 00000000000..e44e110e038 --- /dev/null +++ b/gdb/testsuite/gdb.base/pointers2.exp @@ -0,0 +1,288 @@ +# Copyright (C) 1997, 1998 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Elena Zannoni. (ezannoni@cygnus.com) + + +# This file is part of the gdb testsuite +# +# tests for pointers +# with elementary type variables and pointers. +# + + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "pointers2" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" + + send_gdb "cont\n" + gdb_expect { + -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { + send_gdb "up\n" + gdb_expect { + -re ".*$gdb_prompt $" {} + timeout { fail "up from marker1" } + } + } + -re "$gdb_prompt $" { fail "continue to marker1" } + timeout { fail "(timeout) continue to marker1" } + } + + +send_gdb "print *pUC\n" +gdb_expect { + -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" { + pass "print value of *pUC" + } + -re ".*$gdb_prompt $" { fail "print value of *pUC" } + timeout { fail "(timeout) print value of *pUC" } + } + + +send_gdb "ptype pUC\n" +gdb_expect { + -re "type = unsigned char \\*.*$gdb_prompt $" { pass "ptype pUC" } + -re ".*$gdb_prompt $" { fail "ptype pUC" } + timeout { fail "(timeout) ptype pUC" } +} + +send_gdb "print *pS\n" +gdb_expect { + -re ".\[0-9\]* = -14.*$gdb_prompt $" { + pass "print value of *pS" + } + -re ".*$gdb_prompt $" { fail "print value of *pS" } + timeout { fail "(timeout) print value of *pS" } + } + + +send_gdb "ptype pS\n" +gdb_expect { + -re "type = short \\*.*$gdb_prompt $" { pass "ptype pS" } + -re "type = short int \\*.*$gdb_prompt $" { pass "ptype pS" } + -re ".*$gdb_prompt $" { fail "ptype pS" } + timeout { fail "(timeout) ptype pS" } +} + +send_gdb "print *pUS\n" +gdb_expect { + -re ".\[0-9\]* = 7.*$gdb_prompt $" { + pass "print value of *pUS" + } + -re ".*$gdb_prompt $" { fail "print value of *pUS" } + timeout { fail "(timeout) print value of *pUS" } + } + + +send_gdb "ptype pUS\n" +gdb_expect { + -re "type = unsigned short \\*.*$gdb_prompt $" { pass "ptype pUS" } + -re "type = short unsigned int \\*.*$gdb_prompt $" { pass "ptype pUS" } + -re ".*$gdb_prompt $" { fail "ptype pUS" } + timeout { fail "(timeout) ptype pUS" } +} + +send_gdb "print *pI\n" +gdb_expect { + -re ".\[0-9\]* = 102.*$gdb_prompt $" { + pass "print value of *pI" + } + -re ".*$gdb_prompt $" { fail "print value of *pI" } + timeout { fail "(timeout) print value of *pI" } + } + + +send_gdb "ptype pI\n" +gdb_expect { + -re "type = int \\*.*$gdb_prompt $" { pass "ptype pI" } + -re ".*$gdb_prompt $" { fail "ptype pI" } + timeout { fail "(timeout) ptype pI" } +} + +send_gdb "print *pUI\n" +gdb_expect { + -re ".\[0-9\]* = 1002.*$gdb_prompt $" { + pass "print value of *pUI" + } + -re ".*$gdb_prompt $" { fail "print value of *pUI" } + timeout { fail "(timeout) print value of *pUI" } + } + + +send_gdb "ptype pUI\n" +gdb_expect { + -re "type = unsigned int \\*.*$gdb_prompt $" { pass "ptype pUI" } + -re ".*$gdb_prompt $" { fail "ptype pUI" } + timeout { fail "(timeout) ptype pUI" } +} + +send_gdb "print *pL\n" +gdb_expect { + -re ".\[0-9\]* = -234.*$gdb_prompt $" { + pass "print value of *pL" + } + -re ".*$gdb_prompt $" { fail "print value of *pL" } + timeout { fail "(timeout) print value of *pL" } + } + + +send_gdb "ptype pL\n" +gdb_expect { + -re "type = long \\*.*$gdb_prompt $" { pass "ptype pL" } + -re "type = long int \\*.*$gdb_prompt $" { pass "ptype pL" } + -re ".*$gdb_prompt $" { fail "ptype pL" } + timeout { fail "(timeout) ptype pL" } +} + +send_gdb "print *pUL\n" +gdb_expect { + -re ".\[0-9\]* = 234.*$gdb_prompt $" { + pass "print value of *pUL" + } + -re ".*$gdb_prompt $" { fail "print value of *pUL" } + timeout { fail "(timeout) print value of *pUL" } + } + + +send_gdb "ptype pUL\n" +gdb_expect { + -re "type = unsigned long \\*.*$gdb_prompt $" { pass "ptype pUL" } + -re "type = long unsigned int \\*.*$gdb_prompt $" { pass "ptype pUL" } + -re ".*$gdb_prompt $" { fail "ptype pUL" } + timeout { fail "(timeout) ptype pUL" } +} + +send_gdb "print *pF\n" +gdb_expect { + -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" { + pass "print value of *pF" + } + -re ".*$gdb_prompt $" { fail "print value of *pF" } + timeout { fail "(timeout) print value of *pF" } + } + + +send_gdb "ptype pF\n" +gdb_expect { + -re "type = float \\*.*$gdb_prompt $" { pass "ptype pF" } + -re ".*$gdb_prompt $" { fail "ptype pF" } + timeout { fail "(timeout) ptype pF" } +} + +send_gdb "print *pD\n" +gdb_expect { + -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" { + pass "print value of *pD" + } + -re ".*$gdb_prompt $" { fail "print value of *pD" } + timeout { fail "(timeout) print value of *pD" } + } + + +send_gdb "ptype pD\n" +gdb_expect { + -re "type = double \\*.*$gdb_prompt $" { pass "ptype pD" } + -re ".*$gdb_prompt $" { fail "ptype pD" } + timeout { fail "(timeout) ptype pD" } +} + +send_gdb "print ******ppppppC\n" +gdb_expect { + -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" { + pass "print value of ******ppppppC" + } + -re ".*$gdb_prompt $" { fail "print value of ******ppppppC" } + timeout { fail "(timeout) print value of ******ppppppC" } + } + + +send_gdb "ptype pC\n" +gdb_expect { + -re "type = char \\*.*$gdb_prompt $" { pass "ptype pC" } + -re ".*$gdb_prompt $" { fail "ptype pC" } + timeout { fail "(timeout) ptype pC" } +} + +send_gdb "ptype ppC\n" +gdb_expect { + -re "type = char \\*\\*.*$gdb_prompt $" { pass "ptype ppC" } + -re ".*$gdb_prompt $" { fail "ptype ppC" } + timeout { fail "(timeout) ptype ppC" } +} + +send_gdb "ptype pppC\n" +gdb_expect { + -re "type = char \\*\\*\\*.*$gdb_prompt $" { pass "ptype pppC" } + -re ".*$gdb_prompt $" { fail "ptype pppC" } + timeout { fail "(timeout) ptype pppC" } +} + +send_gdb "ptype ppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppC" } + -re ".*$gdb_prompt $" { fail "ptype ppppC" } + timeout { fail "(timeout) ptype ppppC" } +} + +send_gdb "ptype pppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype pppppC" } + -re ".*$gdb_prompt $" { fail "ptype pppppC" } + timeout { fail "(timeout) ptype pppppC" } +} + +send_gdb "ptype ppppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppppC" } + -re ".*$gdb_prompt $" { fail "ptype ppppppC" } + timeout { fail "(timeout) ptype ppppppC" } +} + diff --git a/gdb/testsuite/gdb.base/shlib-call2.exp b/gdb/testsuite/gdb.base/shlib-call2.exp new file mode 100644 index 00000000000..f6929b88614 --- /dev/null +++ b/gdb/testsuite/gdb.base/shlib-call2.exp @@ -0,0 +1,240 @@ +# Copyright (C) 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# file to test calls into shared libraries +# the source files for this test are: +# +# shmain.c +# shr1.c (shared lib) +# shr2.c (shared lib) +# ss.h (header for shr2.c) +# +# file written by Elena Zannoni: elz@ch.apollo.com +# + +#debug shmain +#prop lib shr1.sl +#prop lib shr2.sl + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# are we on a target board? +if ![isnative] then { + return 0 +} + +set testfile "shmain" +set libfile "shr" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +# build the first test case +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +# Build the shared libraries this test case needs. +# + +if {$gcc_compiled == 0} { + if [istarget "hppa*-hp-hpux*"] then { + set additional_flags "additional_flags=+z" + } else { + # don't know what the compiler is... + set additional_flags "" + } +} else { + set additional_flags "additional_flags=-fpic" +} + +if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if {[gdb_compile "${srcdir}/${subdir}/${libfile}2.c" "${objdir}/${subdir}/${libfile}2.o" object [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [istarget "hppa*-*-hpux*"] { + remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl" + remote_exec build "ld -b ${objdir}/${subdir}/${libfile}2.o -o ${objdir}/${subdir}/${libfile}2.sl" +} else { + set additional_flags "additional_flags=-shared" + if {[gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } + if {[gdb_compile "${objdir}/${subdir}/${libfile}2.o" "${objdir}/${subdir}/${libfile}2.sl" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } +} +if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}1.sl ${objdir}/${subdir}/${libfile}2.sl" "${binfile}" executable {debug}] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" +send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" + + +if ![runto_main] then { + perror "C function calling tests suppressed" +} + + +#step -over + + send_gdb "next\n" + gdb_expect { + -re ".*g = shr1\\(g\\).*$gdb_prompt $" {pass "next to shr2"} + -re ".*$gdb_prompt $" { fail "next to shr2" } + timeout { fail "next to shr2 (timeout)" } + } + + + +#print g + +send_gdb "print g\n" +gdb_expect { + -re ".*\[0-9\]* = 1.*$gdb_prompt $" { + pass "print g" + } + -re ".*$gdb_prompt $" { fail "print g" } + timeout { fail "(timeout) print g" } + } + + +#step -over + send_gdb "next\n" + gdb_expect { + -re ".*address of sgs is $hex.*g = shr2\\(g\\).*$gdb_prompt $" { + pass "next over shr1" } + -re ".*$gdb_prompt $" { fail "next over shr1" } + timeout { fail "next over shr1 (timeout)" } + } + +#print g +send_gdb "print g\n" +gdb_expect { + -re ".*\[0-9\]* = 2.*$gdb_prompt $" { + pass "print g" } + -re ".*$gdb_prompt $" { fail "print g" } + timeout { fail "(timeout) print g" } + } + +#print shr1(1) +send_gdb "print shr1(1)\n" +gdb_expect { + -re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" { + pass "print shr1(1)" } + -re ".*$gdb_prompt $" { fail "print shr1(1)" } + timeout { fail "(timeout) print shr1(1)" } + } + +#print shr1(g) +send_gdb "print shr1(g)\n" +gdb_expect { + -re ".*address of sgs is $hex.*\[0-9\]* = 4.*$gdb_prompt $" { + pass "print shr1(g)" } + -re ".*$gdb_prompt $" { fail "print shr1(g)" } + timeout { fail "(timeout) print shr1(g)" } + } + +#break shr2 +#go +gdb_test "break shr2" \ + "Breakpoint.*file.*shr2.c, line.*" \ + "breakpoint function shr2" + +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, shr2 \\(.*\\) at.*shr2\\.c:3.*3.*return 2.x;" \ +"run until breakpoint set at a function" + + +#print shr1(1) +send_gdb "print shr1(1)\n" +gdb_expect { + -re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" { + pass "print shr1(1)" + } + -re ".*$gdb_prompt $" { fail "print shr1(1)" } + timeout { fail "(timeout) print shr1(1)" } + } + +#print mainshr1(1) +send_gdb "print mainshr1(1)\n" +gdb_expect { + -re ".*\[0-9\]* = 2.*$gdb_prompt $" { + pass "print mainshr1(1) from shlib func" + } + -re ".*$gdb_prompt $" { fail "print mainshr1(1) from shlib func" } + timeout { fail "(timeout) print mainshr1(1) from shlib func" } + } + +#step -return + send_gdb "step\n" + gdb_expect { + -re ".*\\\}.*$gdb_prompt $" { pass "step inside shr2 (shlib func)"} + -re ".*$gdb_prompt $" { fail "step inside shr2 (shlib func)" } + timeout { fail "step inside shr2 (shlib func) (timeout)" } + } + + send_gdb "step\n" + gdb_expect { + -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" { pass "step out of shr2 to main"} + -re ".*$gdb_prompt $" { fail "step out of shr2 to main" } + timeout { fail "step out of shr2 to main (timeout)" } + } + +#print mainshr1(1) +send_gdb "print mainshr1(1)\n" +gdb_expect { + -re ".*\[0-9\]* = 2.*$gdb_prompt $" { + pass "print mainshr1(1)" + } + -re ".*$gdb_prompt $" { fail "print mainshr1(1) from main" } + timeout { fail "(timeout) print mainshr1(1) from main" } + } + +#step + send_gdb "step\n" + gdb_expect { + -re ".*mainshr1 \\(g=4\\) at.*return 2.g;.*$gdb_prompt $" { pass "step into mainshr1"} + -re ".*$gdb_prompt $" { fail "step into mainshr1" } + timeout { fail "step into mainshr1 (timeout)" } + } + +return 0 -- 2.30.2