xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.arch/gdb1558.exp (revision 796c32c94f6e154afc9de0f63da35c91bb739b45)
1# Copyright 2004-2016 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 3 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, see <http://www.gnu.org/licenses/>.
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@gnu.org
18
19# This file is part of the gdb testsuite.
20
21# Tests for PR:1558.  Hits breakpoint at main after function called
22# from main.
23
24
25if ![istarget "sh-*-*"] then {
26    verbose "Skipping SH breakpoint test."
27    return
28}
29
30set testfile "gdb1558"
31set srcfile ${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33# Note we have to compile WITH optimization and WITHOUT debugging information to expose the bug.
34if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"additional_flags=-O2"}] != "" } {
35    untested gdb1558.exp
36    return -1
37}
38
39gdb_exit
40gdb_start
41gdb_reinitialize_dir $srcdir/$subdir
42gdb_load ${binfile}
43
44gdb_test "b main" "Breakpoint 1.*" "set breakpoint at main"
45gdb_test "b sub1" "Breakpoint 2.*" "set breakpoint at sub1"
46gdb_test "b sub2" "Breakpoint 3.*" "set breakpoint at sub2"
47
48# We can't use "runto_main" because that is exactly the problem
49# we are trying to detect, stopping somewhere before main.
50
51gdb_run_cmd
52
53set test "Hits breakpoint at main after function called from main"
54gdb_test_multiple "" $test {
55    -re "Breakpoint 1.*main .*$gdb_prompt $" {
56	pass $test
57    }
58    -re "Breakpoint 2.*sub1 .*$gdb_prompt $" {
59	kfail "gdb/1558" $test
60    }
61}
62