xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.reverse/break-precsave.exp (revision 479d8f7d843cc1b22d497efdf1f27a50ee8418d4)
1#   Copyright 2008-2015 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# This file is part of the GDB testsuite.  It tests reverse debugging
17# with breakpoints in a process record logfile.
18
19# This test suitable only for process record-replay
20if ![supports_process_record] {
21    return
22}
23
24standard_testfile break-reverse.c
25set precsave [standard_output_file break.precsave]
26
27if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
28    return -1
29}
30
31set foo_location  [gdb_get_line_number "break in foo" ]
32set bar_location  [gdb_get_line_number "break in bar" ]
33set main_location [gdb_get_line_number "break in main"]
34set end_location  [gdb_get_line_number "end of main"  ]
35
36proc precsave_tests {} {
37    global foo_location bar_location main_location end_location
38    global decimal srcfile precsave gdb_prompt
39
40    runto main
41
42    if [supports_process_record] {
43	# Activate process record/replay
44	gdb_test_no_output "record" "Turn on process record"
45    }
46
47    gdb_test "break $end_location" \
48	"Breakpoint $decimal at .*$srcfile, line $end_location\." \
49	"BP at end of main"
50
51    gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
52
53    gdb_test "record save $precsave" \
54	"Saved core file $precsave with execution log\."  \
55	"save process recfile"
56
57    gdb_test "kill" "" "Kill process, prepare to debug log file" \
58	"Kill the program being debugged\\? \\(y or n\\) " "y"
59
60    gdb_test "record restore $precsave" \
61	"Restored records from core file .*" \
62	"reload precord save file"
63
64    gdb_test "break foo" \
65	"Breakpoint $decimal at .* line $foo_location\." \
66	"set breakpoint on foo"
67
68    gdb_test "break bar" \
69	"Breakpoint $decimal at .* line $bar_location\." \
70	"set breakpoint on bar"
71
72    gdb_continue_to_breakpoint "foo" ".*$srcfile:$foo_location.*"
73    gdb_continue_to_breakpoint "bar" ".*$srcfile:$bar_location.*"
74    gdb_test_multiple "continue" "go to end of main forward" {
75	-re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $"  {
76	    pass "go to end of main forward"
77	}
78	-re "No more reverse-execution history.* end of main .*$gdb_prompt $" {
79	    pass "go to end of main forward"
80	}
81    }
82
83    gdb_test_no_output "set exec-direction reverse" "set reverse"
84
85    gdb_continue_to_breakpoint "bar backward"  ".*$srcfile:$bar_location.*"
86    gdb_continue_to_breakpoint "foo backward"  ".*$srcfile:$foo_location.*"
87
88    gdb_test_multiple "continue" "main backward" {
89	-re ".*Breakpoint $decimal,.*$srcfile:$main_location.*$gdb_prompt $" {
90	    pass "main backward"
91	}
92	-re "No more reverse-execution history.* break in main .*$gdb_prompt $" {
93	    pass "main backward"
94	}
95    }
96
97    gdb_test_no_output "set exec-direction forward" "set forward"
98
99    gdb_continue_to_breakpoint "foo" ".*$srcfile:$foo_location.*"
100    gdb_continue_to_breakpoint "bar" ".*$srcfile:$bar_location.*"
101
102    gdb_test_multiple "continue" "end of record log" {
103	-re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
104	    pass "end of record log"
105	}
106	-re "No more reverse-execution history.* end of main .*$gdb_prompt $" {
107	    pass "end of record log"
108	}
109    }
110}
111
112precsave_tests
113