| # 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 |
| |
| # smoke.exp -- Expect script to test gdb before checkins |
| |
| # use this to debug: |
| # |
| #log_user 1 |
| |
| if $tracelevel then { |
| strace $tracelevel |
| } |
| |
| set testfile smoke |
| set testfile1 smoke1 |
| set c_srcfile ${srcdir}/${subdir}/${testfile}.c |
| set cpp_srcfile ${srcdir}/${subdir}/${testfile}.cc |
| set binfile ${objdir}/${subdir}/${testfile} |
| set binfile1 ${objdir}/${subdir}/${testfile1} |
| |
| #remote_exec build "rm -f ${binfile}" |
| remote_exec build "rm -f core" |
| |
| # "C" section, using source copied from "step-test.c" from "gdb.base" |
| # |
| if { [gdb_compile "${c_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} |
| |
| # Some basic tests |
| # |
| gdb_test "tb main" ".*Breakpoint 1 at.*line 15.*" "temp breakpoint" |
| gdb_test "b callee" ".*Breakpoint 2 at.*line 6.*" "breakpoint" |
| gdb_test "l 10" ".*10.*int main.*11.*int w,x,y,z;.*12.*int a.*" "list" |
| gdb_test "c" ".*The program is not being run.*" "catch error" |
| gdb_test "r" ".*Starting program.*main.*15.*" "hit bp" |
| gdb_test "hel r" ".*Start debugged program.*without arguments.*" "help" |
| gdb_test "n" ".*x = 1;.*" "next" |
| gdb_test "s" ".*y = 2;.*" "step" |
| gdb_test "p/t x" ".* = 1.*" "print x in binary" |
| gdb_test "p 1+2*3+4" ".* = 11.*" "calculate" |
| gdb_test "p/t 1+2*3+4" ".* = 1011.*" "binary" |
| |
| # Note: accept either "Watchpoint" or "Hardware watchpoint"; |
| # 10.20 can't do the hardware watch. The hardware kind |
| # triggers one line earlier than the regular kind. |
| # |
| gdb_test "wat y" ".*atchpoint.*y.*" "set watch" |
| gdb_test "c" ".*atchpoint.*Old.*= .*New.*= 2.*1\[78\].*" "continue, hit watch" |
| |
| gdb_test "set glob=999" ".*.*" "set" |
| gdb_test "p glob" ".*= 999.*.*" "print glob" |
| gdb_test "p/x glob" ".*= 0x3e7.*" "hex" |
| gdb_test "c" ".*atchpoint.*Old.*= 2.*New.*= 6.*2\[12\].*" "continue, 2nd hit watch" |
| gdb_test "d 5" "No breakpoint number 5." "del non existing watch" |
| gdb_test "c" ".*Breakpoint.*callee.*6.*" "hit bp" |
| gdb_test "bt" ".*callee.*6.*main.*25.*" "bt" |
| gdb_test "fin" ".*Run till exit.*callee.*Value returned.*0.*" "finish" |
| gdb_test "c" ".*Breakpoint.*callee.*6.*" "hit bp again" |
| gdb_test "cle" ".*Deleted breakpoint.*" "clear" |
| gdb_test "wat glob" ".*atchpoint.*glob.*" "set 2nd watch" |
| gdb_test "i wat" ".*" "" |
| gdb_test "whe" ".*" "" |
| |
| # ??rehrauer: We're now disabling watchpoints while an interactive |
| # call is "in flight". When/if we can teach gdb how to unwind through |
| # the call dummy frame, we can then allow watches during calls, and |
| # also then restore this testpoint to the original, commented-out form. |
| # |
| gdb_test "call callee()" ".*\[0-9\]* = 0.*" "call, didn't hit watch" |
| #gdb_test "call callee()" ".*atchpoint.*Old.*= 1000.*New.*= 1001.*\[67\].*being debug.*is done.*" "call, hit watch" |
| |
| gdb_test "d 4" ".*" "del watch 2" |
| gdb_test "d 3" ".*" "del watch 1" |
| gdb_test "info break" "No breakpoints or watchpoints." |
| # since we have deleted all the watchpoints this test is useless |
| #gdb_test "c" ".*Continuing.*" "end call" |
| gdb_test "c" ".*Program exited normally.*" "pgm exit" |
| |
| # Check for production of a core file |
| # |
| #set exec_output [execute_anywhere "ls core"] |
| set exec_output [remote_exec build "ls core"] |
| |
| if [ regexp "core not found" $exec_output] { |
| pass "No core dumped on quit" |
| } else { |
| if [ regexp "No such file or directory" $exec_output] { |
| pass "ls: core: No core dumped on quit" |
| } else { |
| remote_exec build "rm -f core" |
| fail "Core dumped on quit" |
| } |
| } |
| |
| |
| #======================================== |
| # |
| # "C++" section, using source copied from "misc.cc" from "gdb.c++" |
| # |
| |
| # |
| #remote_exec build "rm -f ${binfile}" |
| #remote_exec build "CC -g -o ${binfile} ${cpp_srcfile}" |
| if {[gdb_compile "${cpp_srcfile}" "${binfile1}" executable {c++ 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 ${binfile1} |
| |
| # Tests, some copied from misc.exp. |
| # |
| |
| # See what language gdb thinks main() is, prior to reading full symbols. |
| # I think this fails for COFF targets. |
| setup_xfail "a29k-*-udi" |
| send_gdb "show language\n" |
| gdb_expect { |
| -re ".* source language is \"auto; currently c\\+\\+\".*$gdb_prompt $" { |
| pass "deduced language is C++, before full symbols" |
| } |
| -re ".*$gdb_prompt $" { fail "source language not correct for C++ (psymtabs only)"} |
| return |
| |
| timeout { fail "can't show language (timeout)"} |
| return |
| } |
| |
| gdb_test "b main" ".*Breakpoint 1 at.*" "" |
| gdb_test "r" ".*Starting program.*Breakpoint 1.*" "run to main" |
| gdb_test "ptype Foo" ".*type = class Foo.*static int st;.*int operator.*" "ptype" |
| gdb_test "step" ".*inheritance1.*" "step" |
| gdb_test "ptype g_anon_union" ".*anon_union.*union.*int a;.*" "anon" |
| gdb_test "p g_E" ".*class D.*class B.*class A.*class C.*class A.*x = 0.*" "print inherited class " |
| gdb_test "p g_E.x = 99" ".*warn.*x ambiguous; using E::x. Use a cast to disambig.*99.*" "set via print" |
| gdb_test "c" ".*Program exited.*" "run to end" |
| |
| gdb_exit |
| |
| # Check for production of a core file |
| # |
| #set exec_output [execute_anywhere "ls core"] |
| set exec_output [remote_exec build "ls core"] |
| if [ regexp "core not found" $exec_output] { |
| pass "No core dumped on quit" |
| } else { |
| if [ regexp "No such file or directory" $exec_output] { |
| pass "ls: core: No core dumped on quit" |
| } else { |
| remote_exec build "rm -f core" |
| fail "Core dumped on quit" |
| } |
| } |
| |
| # execute_anywhere "rm -f ${binfile1}" |
| # |
| return 0 |