Commit | Line | Data |
---|---|---|
8cb5cc78 YQ |
1 | # Copyright 2013 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 | load_lib trace-support.exp | |
17 | ||
18 | standard_testfile trace-unavailable.c | |
19 | ||
20 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] } { | |
21 | return -1 | |
22 | } | |
23 | ||
24 | if ![runto_main] { | |
25 | fail "Can't run to main to check for trace support" | |
26 | return -1 | |
27 | } | |
28 | ||
29 | if ![gdb_target_supports_trace] { | |
30 | unsupported "Current target does not support trace" | |
31 | return -1 | |
32 | } | |
33 | ||
34 | gdb_exit | |
35 | ||
36 | load_lib mi-support.exp | |
37 | set MIFLAGS "-i=mi" | |
38 | ||
39 | if [mi_gdb_start] { | |
40 | return | |
41 | } | |
42 | mi_run_to_main | |
43 | ||
44 | mi_gdb_test "-break-insert marker" \ | |
45 | "\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \ | |
46 | "insert tracepoint on marker" | |
47 | mi_gdb_test "-break-insert -a bar" \ | |
48 | "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \ | |
49 | "insert tracepoint on bar" | |
50 | ||
51 | # Define an action. | |
52 | mi_gdb_test "-break-commands 3 \"collect array\" \"collect j\" \"end\" " \ | |
53 | {\^done} "set action" | |
54 | ||
55 | mi_gdb_test "-trace-start" {.*\^done} "trace start" | |
56 | mi_send_resuming_command "exec-continue" "continuing to marker" | |
57 | mi_expect_stop \ | |
58 | "breakpoint-hit" "marker" ".*" ".*" ".*" {"" "disp=\"keep\""} \ | |
59 | "stop at marker" | |
60 | mi_gdb_test "-trace-stop" {.*} "trace stop" | |
61 | ||
62 | # Save trace frames to tfile. | |
63 | set tracefile [standard_output_file ${testfile}] | |
64 | mi_gdb_test "-trace-save ${tracefile}.tf" ".*\\^done" \ | |
65 | "save tfile trace file" | |
66 | # Save trace frames to ctf. | |
67 | mi_gdb_test "-trace-save -ctf ${tracefile}.ctf" ".*\\^done" \ | |
68 | "save ctf trace file" | |
69 | ||
70 | mi_gdb_test "-gdb-set print entry-values no" {\^done} \ | |
71 | "-gdb-set print entry-values no" | |
72 | ||
73 | proc test_trace_unavailable { data_source } { | |
74 | global decimal | |
75 | ||
76 | with_test_prefix "$data_source" { | |
77 | ||
78 | # Test MI commands '-stack-list-locals', '-stack-list-arguments', | |
79 | # and '-stack-list-variables'. | |
80 | mi_gdb_test "-trace-find frame-number 0" \ | |
81 | ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ | |
82 | "-trace-find frame-number 0" | |
83 | ||
84 | # Test MI command '-stack-list-locals'. | |
85 | mi_gdb_test "-stack-list-locals --simple-values" \ | |
86 | ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \ | |
87 | "-stack-list-locals --simple-values" | |
88 | ||
89 | # Test MI command '-stack-list-arguments'. | |
90 | mi_gdb_test "-stack-list-arguments --simple-values" \ | |
91 | ".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\},\{name=\"s\",type=\"char \\\*\",value=\"<unavailable>\"\}\\\]\},.*\}.*" \ | |
92 | "-stack-list-arguments --simple-values" | |
93 | ||
94 | # Test MI command '-stack-list-variables'. | |
95 | mi_gdb_test "-stack-list-variables --simple-values" \ | |
96 | ".*\\^done,variables=\\\[\{name=\"j\",arg=\"1\",type=\"int\",value=\"4\"\},\{name=\"s\",arg=\"1\",type=\"char \\\*\",value=\"<unavailable>\"\},\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \ | |
97 | "-stack-list-variables --simple-values" | |
98 | ||
99 | # Don't issue command '-trace-find none' to return from | |
100 | # tfind mode (examining trace frames) on purpose, in order | |
101 | # to test that GDB is able to clear its tracing-related local state | |
102 | # in the next -target-select. | |
103 | # mi_gdb_test "-trace-find none" ".*\\^done,found=\"0\".*" "-trace-find none" | |
104 | } | |
105 | } | |
106 | ||
107 | test_trace_unavailable "live" | |
108 | ||
109 | # Change target to ctf if GDB supports it. | |
110 | set msg "-target-select ctf" | |
111 | send_gdb "-target-select ctf ${tracefile}.ctf\n" | |
112 | gdb_expect { | |
113 | -re ".*\\^connected.*${mi_gdb_prompt}$" { | |
114 | # GDB supports ctf, do the test. | |
115 | test_trace_unavailable "ctf" | |
116 | } | |
117 | -re ".*\\^error,msg=\"Undefined target command.*${mi_gdb_prompt}$" { | |
118 | # GDB doesn't support ctf, skip the test. | |
119 | unsupported "gdb does not support ctf target" | |
120 | } | |
121 | -re ".*$mi_gdb_prompt$" { | |
122 | fail "$msg" | |
123 | } | |
124 | timeout { | |
125 | fail "$msg (timeout)" | |
126 | } | |
127 | } | |
128 | ||
129 | # Change target to tfile. | |
130 | mi_gdb_test "-target-select tfile ${tracefile}.tf" ".*\\^connected.*" \ | |
131 | "-target-select tfile" | |
132 | test_trace_unavailable "tfile" | |
133 | ||
134 | mi_gdb_exit |