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