1# Copyright (C) 1992, 1994, 1995 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# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 16 17# Please email any bugs, comments, and/or additions to this file to: 18# bug-gdb@prep.ai.mit.edu 19 20# This file was written by Fred Fish. (fnf@cygnus.com) 21 22if $tracelevel then { 23 strace $tracelevel 24 } 25 26if { [skip_hp_tests] } then { continue } 27 28global message 29 30# 31# test running programs 32# 33set prms_id 0 34set bug_id 0 35 36set testfile "xdb" 37set binfile ${objdir}/${subdir}/${testfile} 38 39if { [gdb_compile "${srcdir}/${subdir}/xdb0.c" "${binfile}0.o" object {debug}] != "" } { 40 perror "Couldn't compile ${testfile}0.c to object" 41 return -1 42} 43 44if { [gdb_compile "${srcdir}/${subdir}/xdb1.c" "${binfile}1.o" object {debug}] != "" } { 45 perror "Couldn't compile ${testfile}1.c to object" 46 return -1 47} 48 49if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { 50 perror "Couldn't link ${testfile}." 51 return -1 52} 53 54if [get_compiler_info ${binfile}] { 55 return -1; 56} 57 58if { $gcc_compiled } then { continue } 59 60global GDBFLAGS 61set saved_gdbflags $GDBFLAGS 62set GDBFLAGS "$GDBFLAGS --xdb" 63 64gdb_exit 65gdb_start 66gdb_reinitialize_dir $srcdir/$subdir 67gdb_load ${binfile} 68gdb_test "break main" "" 69gdb_test "run" "" 70gdb_test "go +2" "Breakpoint.*at.*file.*xdb0\.c, line 12\.\r\nContinuing at.*\r\nmain \\(\\) at.*xdb0\.c:12\r\n12\[ \t\]+foo \\(x\\+\\+\\);" 71gdb_test "go -2" "Note: breakpoint.*also set at pc.*\.\r\nBreakpoint.*at.*file.*xdb0\.c, line 10\.\r\nContinuing at.*\.\r\n\r\nBreakpoint.*, main \\(\\) at.*xdb0\.c:10.*" 72gdb_test "go 16" "Breakpoint.*at.*file.*xdb0\.c, line 16\.\r\nContinuing at.*\.\r\nmain \\(\\) at.*xdb0\.c:16\r\n16\[ \t\]+foo \\(x\\+\\+\\);" 73 74send_gdb "go bar\n" 75 gdb_expect { 76 -re ".*Line 5 is not in .main.. Jump anyway.*y or n. $" { 77 send_gdb "y\n" 78 gdb_expect { 79 -re "$gdb_prompt $"\ 80 {pass "go bar"} 81 timeout {fail "(timeout) go bar"} 82 } 83 } 84 -re "Continuing at.*\.\r\nbar \\(x=0\\) at.*xdb1\.c:5" {} 85 timeout { perror "(timeout) go bar" ; return } 86 } 87 88# Verify that GDB responds gracefully to a "go" command without 89# an argument. 90# 91gdb_test "go" "Usage: go <location>" 92 93gdb_exit 94gdb_start 95gdb_reinitialize_dir $srcdir/$subdir 96gdb_load ${binfile} 97 98gdb_test "break bar" "" 99gdb_test "run" "" 100gdb_test "backtrace full" ".*bar \\(x=0\\) at.*xdb1\.c:5\r\nNo locals\.\r\n.1.* in foo \\(x=1\\) at.*xdb0\.h:8\r\nNo locals\.\r\n.2.* in main \\(\\) at.*xdb0\.c:11\r\n.*x = 1" 101gdb_test "bt 1 full" ".*bar \\(x=0\\) at.*xdb1\.c:5\r\nNo locals\.\r\n\\(More stack frames follow\.\.\.\\)" 102gdb_test "bt full 2" ".*bar \\(x=0\\) at.*xdb1\.c:5\r\nNo locals\.\r\n.1.* in foo \\(x=1\\) at.*xdb0\.h:8\r\nNo locals\.\r\n\\(More stack frames follow\.\.\.\\)" 103 104set GDBFLAGS $saved_gdbflags 105return 0 106