OSDN Git Service

Use datarootdir for locales.
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / chng-syms.exp
1 # Copyright 2004, 2007-2012 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 # Author: Paul N. Hilfinger (Hilfinger@gnat.com)
17
18 # Test that GDB cleans up properly after errors that result when a 
19 # breakpoint is reset. 
20
21
22 # IDT/SIM apparently doesn't have enough file descriptors to allow the
23 # problem checked by this test to occur.
24 if [istarget "mips-idt-*"] {
25     return 0;
26 }
27
28 set testfile "chng-syms"
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
33     untested chng-syms.exp
34     return -1
35 }
36
37 set oldtimeout $timeout
38 set timeout 10
39 verbose "Timeout is now 10 seconds" 2
40
41 proc expect_to_stop_here { ident } {
42     global gdb_prompt
43     global decimal
44
45     # the "at foo.c:36" output we get with -g.
46     # the "in func" output we get without -g.
47     gdb_expect {
48         -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" { 
49             return 1
50         }
51         -re "$gdb_prompt $" { 
52             fail "running to stop_here $ident"
53             return 0
54         }
55         timeout { 
56             fail "running to stop_here $ident (timeout)"
57             return 0
58         }
59     }
60     return 1
61 }
62
63 gdb_exit
64 gdb_start
65 gdb_reinitialize_dir $srcdir/$subdir
66 gdb_load ${binfile}
67
68 gdb_test "break stop_here if (var1 == 42)" \
69     "Breakpoint.*at.* file .*$srcfile, line.*" \
70     "setting conditional breakpoint on function"
71 gdb_run_cmd
72
73 expect_to_stop_here "first time"
74     
75 gdb_continue_to_end "breakpoint first time through"
76
77 # Now we recompile the executable, but without a variable named "var1", first
78 # waiting to insure that even on fast machines, the file modification times
79 # are distinct. This will force GDB to reload the file on the 
80 # next "run" command, causing an error when GDB tries to tries to reset 
81 # the breakpoint.
82
83 sleep 2
84 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } {
85
86 # Complication: Since GDB generally holds an open file descriptor on the 
87 # executable at this point, there are some systems in which the 
88 # re-compilation will fail. In such cases, we'll consider the test 
89 # (vacuously) passed providing that re-running it succeeds as before.
90
91     gdb_run_cmd
92     expect_to_stop_here "after re-compile fails"
93     gdb_continue_to_end "after re-compile fails"
94
95 } else {
96
97     gdb_run_cmd
98     gdb_expect {
99         -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
100             pass "running with invalidated bpt condition after executable changes" 
101         }
102         -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" {
103             pass "running with invalidated bpt condition after executable changes" 
104         }
105         -re "$gdb_prompt $" { 
106             fail "running with invalidated bpt condition after executable changes" 
107         }
108         timeout {
109             fail "(timeout) running with invalidated bpt condition after executable changes" 
110         }
111     }
112
113 }
114
115 set timeout $oldtimeout
116 verbose "Timeout is now $timeout seconds" 2
117 return 0