Commit | Line | Data |
---|---|---|
e66408ed PA |
1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
2 | # Free Software Foundation, Inc. | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # Regression test for PR11557. Make sure we don't end up with a stale | |
18 | # register cache just after resuming a thread. | |
19 | ||
20 | load_lib mi-support.exp | |
21 | set MIFLAGS "-i=mi" | |
22 | ||
23 | gdb_exit | |
24 | if {[mi_gdb_start]} { | |
25 | continue | |
26 | } | |
27 | ||
28 | proc mi_nonstop_resume { command test } { | |
29 | if { [mi_send_resuming_command $command $test] != 0 } { | |
30 | # If a resume fails, assume non-stop is broken or unsupported | |
31 | # for this target. We have logged a FAIL or UNSUPPORTED; skip | |
32 | # the remaining tests to limit timeouts. | |
33 | return -code continue | |
34 | } | |
35 | } | |
36 | ||
37 | # | |
38 | # Start here | |
39 | # | |
40 | set testfile "ns-stale-regcache" | |
41 | set srcfile "$testfile.c" | |
42 | set binfile "$objdir/$subdir/mi-$testfile" | |
43 | ||
44 | set options [list debug incdir=$objdir] | |
45 | if {[gdb_compile "$srcdir/$subdir/$srcfile" \ | |
46 | $binfile executable $options] != "" } { | |
47 | return -1 | |
48 | } | |
49 | ||
50 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
51 | mi_gdb_load $binfile | |
52 | ||
53 | set supported 0 | |
ec9f1212 | 54 | gdb_test_multiple "-gdb-show non-stop" "" { |
e66408ed PA |
55 | -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" { |
56 | if { $expect_out(1,string) == "1" } { | |
57 | set supported 1 | |
58 | } | |
59 | } | |
ec9f1212 | 60 | -re ".*$mi_gdb_prompt$" { |
e66408ed PA |
61 | } |
62 | } | |
63 | ||
64 | mi_gdb_test "-gdb-set non-stop 1" ".*" | |
65 | mi_gdb_test "-gdb-set target-async 1" ".*" | |
66 | detect_async | |
67 | ||
68 | if { [mi_run_to_main] < 0 } { | |
69 | perror "mi-ns-stale-regcache.exp tests suppressed" | |
70 | continue | |
71 | } | |
72 | ||
73 | # Check that register and stack info don't end up stale after resuming | |
74 | # a thread. | |
75 | mi_nonstop_resume "exec-continue" "resume thread" | |
76 | ||
77 | mi_gdb_test "-data-evaluate-expression \$pc" \ | |
78 | "\\^error,msg=\".*\"" "no stale register cache of resumed thread" | |
79 | ||
80 | mi_gdb_test "-stack-info-frame" \ | |
81 | "\\^error,msg=\".*\"" "no stale frame info of resumed thread" | |
82 | ||
83 | # Check that the thread is still running. If the above tests passed, | |
84 | # we want it to be for the right reasons. | |
85 | mi_check_thread_states {"running"} "main thread still running" | |
86 | ||
87 | mi_gdb_exit |