Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 |
e66408ed PA |
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 | ||
d5b4a7be YQ |
20 | if { ![support_displaced_stepping] } { |
21 | unsupported "displaced stepping" | |
22 | return -1 | |
23 | } | |
24 | ||
e66408ed PA |
25 | load_lib mi-support.exp |
26 | set MIFLAGS "-i=mi" | |
27 | ||
28 | gdb_exit | |
29 | if {[mi_gdb_start]} { | |
30 | continue | |
31 | } | |
32 | ||
33 | proc mi_nonstop_resume { command test } { | |
34 | if { [mi_send_resuming_command $command $test] != 0 } { | |
35 | # If a resume fails, assume non-stop is broken or unsupported | |
36 | # for this target. We have logged a FAIL or UNSUPPORTED; skip | |
37 | # the remaining tests to limit timeouts. | |
38 | return -code continue | |
39 | } | |
40 | } | |
41 | ||
42 | # | |
43 | # Start here | |
44 | # | |
45 | set testfile "ns-stale-regcache" | |
46 | set srcfile "$testfile.c" | |
47 | set binfile "$objdir/$subdir/mi-$testfile" | |
48 | ||
49 | set options [list debug incdir=$objdir] | |
50 | if {[gdb_compile "$srcdir/$subdir/$srcfile" \ | |
51 | $binfile executable $options] != "" } { | |
52 | return -1 | |
53 | } | |
54 | ||
55 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
56 | mi_gdb_load $binfile | |
57 | ||
e66408ed PA |
58 | mi_gdb_test "-gdb-set non-stop 1" ".*" |
59 | mi_gdb_test "-gdb-set target-async 1" ".*" | |
fcdfa280 | 60 | mi_detect_async |
e66408ed PA |
61 | |
62 | if { [mi_run_to_main] < 0 } { | |
e66408ed PA |
63 | continue |
64 | } | |
65 | ||
66 | # Check that register and stack info don't end up stale after resuming | |
67 | # a thread. | |
68 | mi_nonstop_resume "exec-continue" "resume thread" | |
69 | ||
70 | mi_gdb_test "-data-evaluate-expression \$pc" \ | |
71 | "\\^error,msg=\".*\"" "no stale register cache of resumed thread" | |
72 | ||
73 | mi_gdb_test "-stack-info-frame" \ | |
74 | "\\^error,msg=\".*\"" "no stale frame info of resumed thread" | |
75 | ||
76 | # Check that the thread is still running. If the above tests passed, | |
77 | # we want it to be for the right reasons. | |
78 | mi_check_thread_states {"running"} "main thread still running" | |
79 | ||
80 | mi_gdb_exit |