1*b725ae77Skettenis# Copyright 2004 Free Software Foundation, Inc. 2*b725ae77Skettenis 3*b725ae77Skettenis# This program is free software; you can redistribute it and/or modify 4*b725ae77Skettenis# it under the terms of the GNU General Public License as published by 5*b725ae77Skettenis# the Free Software Foundation; either version 2 of the License, or 6*b725ae77Skettenis# (at your option) any later version. 7*b725ae77Skettenis# 8*b725ae77Skettenis# This program is distributed in the hope that it will be useful, 9*b725ae77Skettenis# but WITHOUT ANY WARRANTY; without even the implied warranty of 10*b725ae77Skettenis# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11*b725ae77Skettenis# GNU General Public License for more details. 12*b725ae77Skettenis# 13*b725ae77Skettenis# You should have received a copy of the GNU General Public License 14*b725ae77Skettenis# along with this program; if not, write to the Free Software 15*b725ae77Skettenis# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16*b725ae77Skettenis 17*b725ae77Skettenis# Please email any bugs, comments, and/or additions to this file to: 18*b725ae77Skettenis# bug-gdb@gnu.org 19*b725ae77Skettenis 20*b725ae77Skettenis# This file is part of the gdb testsuite. 21*b725ae77Skettenis 22*b725ae77Skettenis# Tests for PR:1558. Hits breakpoint at main after function called 23*b725ae77Skettenis# from main. 24*b725ae77Skettenis 25*b725ae77Skettenisif $tracelevel { 26*b725ae77Skettenis strace $tracelevel 27*b725ae77Skettenis} 28*b725ae77Skettenis 29*b725ae77Skettenisset prms_id 0 30*b725ae77Skettenisset bug_id 0 31*b725ae77Skettenis 32*b725ae77Skettenisif ![istarget "sh-*-*"] then { 33*b725ae77Skettenis verbose "Skipping SH breakpoint test." 34*b725ae77Skettenis return 35*b725ae77Skettenis} 36*b725ae77Skettenis 37*b725ae77Skettenisset testfile "gdb1558" 38*b725ae77Skettenisset srcfile ${testfile}.c 39*b725ae77Skettenisset binfile ${objdir}/${subdir}/${testfile} 40*b725ae77Skettenis# Note we have to compile WITH optimization and WITHOUT debugging information to expose the bug. 41*b725ae77Skettenisif { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"additional_flags=-O2"}] != "" } { 42*b725ae77Skettenis gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." 43*b725ae77Skettenis} 44*b725ae77Skettenis 45*b725ae77Skettenisgdb_exit 46*b725ae77Skettenisgdb_start 47*b725ae77Skettenisgdb_reinitialize_dir $srcdir/$subdir 48*b725ae77Skettenisgdb_load ${binfile} 49*b725ae77Skettenis 50*b725ae77Skettenisgdb_test "b main" "Breakpoint 1.*" "set breakpoint at main" 51*b725ae77Skettenisgdb_test "b sub1" "Breakpoint 2.*" "set breakpoint at sub1" 52*b725ae77Skettenisgdb_test "b sub2" "Breakpoint 3.*" "set breakpoint at sub2" 53*b725ae77Skettenis 54*b725ae77Skettenis# We can't use "runto_main" because that is exactly the problem 55*b725ae77Skettenis# we are trying to detect, stopping somewhere before main. 56*b725ae77Skettenis 57*b725ae77Skettenisgdb_run_cmd 58*b725ae77Skettenis 59*b725ae77Skettenisgdb_expect 30 { 60*b725ae77Skettenis -re "Breakpoint 1.*main .*$gdb_prompt $" { 61*b725ae77Skettenis pass "Hits breakpoint at main after function called from main" 62*b725ae77Skettenis } 63*b725ae77Skettenis -re "Breakpoint 2.*sub1 .*$gdb_prompt $" { 64*b725ae77Skettenis kfail "gdb/1558" "Hits breakpoint at main after function called from main" 65*b725ae77Skettenis } 66*b725ae77Skettenis -re "$gdb_prompt $" { 67*b725ae77Skettenis fail "Hits breakpoint at main after function called from main" 68*b725ae77Skettenis } 69*b725ae77Skettenis timeout { 70*b725ae77Skettenis fail "Hits breakpoint at main after function called from main (timeout)" 71*b725ae77Skettenis } 72*b725ae77Skettenis} 73