1# Copyright 2001, 2007 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@prep.ai.mit.edu 18 19# This file was written by Michael Snyder. (msnyder@redhat.com) 20 21if $tracelevel then { 22 strace $tracelevel 23} 24 25# 26# Test breakpoints at consecutive instruction addresses. 27# 28 29set prms_id 0 30set bug_id 0 31 32set testfile "consecutive" 33set srcfile ${testfile}.c 34set binfile ${objdir}/${subdir}/${testfile} 35 36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { 37 untested consecutive.exp 38 return -1 39} 40 41if [get_compiler_info ${binfile}] { 42 return -1 43} 44 45gdb_exit 46gdb_start 47gdb_reinitialize_dir $srcdir/$subdir 48gdb_load ${binfile} 49 50if [target_info exists gdb_stub] { 51 gdb_step_for_stub; 52} 53 54if ![runto_main] then { 55 perror "couldn't run to breakpoint" 56 continue 57} 58 59set nl "\[\r\n\]+" 60 61gdb_breakpoint foo 62gdb_test "continue" "Breakpoint $decimal, foo .*" \ 63 "continue to breakpoint in foo" 64 65set bp_addr 0 66set stop_addr 0 67 68send_gdb "x /2i \$pc\n" 69gdb_expect { 70 global hex 71 global nl 72 global bp_addr 73 global gdb_prompt 74 75 -re "$hex.*${nl}($hex).*$gdb_prompt $" { 76 set bp_addr $expect_out(1,string) 77 pass "get breakpoint address for foo" 78 } 79 -re ".*$gdb_prompt $" { 80 fail "get breakpoint address for foo" 81 return 0; 82 } 83 timeout { 84 fail "get breakpoint address for foo (timeout)" 85 return 0; 86 } 87} 88 89gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \ 90 "set bp, 2nd instr" 91 92send_gdb "step\n" 93gdb_expect { 94 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { 95 set stop_addr $expect_out(1,string) 96 if [eval expr "$bp_addr == $stop_addr"] then { 97 pass "stopped at bp, 2nd instr" 98 } else { 99 fail "stopped at bp, 2nd instr (wrong address)" 100 } 101 } 102 -re ".*$gdb_prompt $" { 103 fail "stopped at bp, 2nd instr" 104 } 105 timeout { 106 fail "stopped at bp, 2nd instr (timeout)" 107 108 } 109} 110 111