1 proc gdb_emc_readvar { varname } {
5 send_gdb "print $varname\n"
7 -re "\[$\].*= (\[0-9\]+).*$gdb_prompt $" {
8 set result $expect_out(1,string);
10 -re "$gdb_prompt $" { }
16 proc gdb_emc_gettpnum { testname } {
19 if { $testname != "" } {
20 gdb_test "trace $testname" "" ""
22 return [gdb_emc_readvar "\$tpnum"];
25 proc gdb_emc_setactions { testname actionname args } {
30 send_gdb "actions $actionname\n";
31 set expected_result "";
33 -re "No tracepoint number .*$gdb_prompt $" {
37 -re "Enter actions for tracepoint $actionname.*>" {
38 if { [llength $args] > 0 } {
39 set lastcommand "[lindex $args $state]";
40 send_gdb "[lindex $args $state]\n";
42 set expected_result [lindex $args $state];
49 -re "\(.*\[\r\n\]+)\[ \t]*> $" {
50 if { $expected_result != "" } {
51 # Remove echoed command and its associated newline.
52 regsub "^\[^\r\n\]+\[\r\n\]+" "$expect_out(1,string)" "" out;
53 # Strip off any newlines at the end of the string.
54 regsub "\[\r\n\]+$" "$out" "" out;
55 verbose "expected '$expected_result', got '$out', expect_out is '$expect_out(1,string)'";
56 if ![regexp $expected_result $out] {
59 set expected_result "";
61 if { $state < [llength $args] } {
62 send_gdb "[lindex $args $state]\n";
64 set expected_result [lindex $args $state];
68 set expected_result "";
72 -re "\(.*\)$gdb_prompt $" {
73 if { $expected_result != "" } {
74 if ![regexp $expected_result $expect_out(1,string)] {
77 set expected_result "";
79 if { [llength $args] < $state } {
87 if { $testname != "" } {
90 if { $status == "pass" } then {
98 # test collect command
101 proc gdb_emc_tracetest_collect { arg1 msgstring } {
107 -re "Enter actions for tracepoint $decimal.*> $" {
108 send_gdb "collect $arg1\n"
113 if { $teststate == 1 } {
121 -re ".*$gdb_prompt $" {
122 if { $teststate == 2 } {
129 fail "$msgstring (default)";
132 regsub -all "(\[($@*+)\])" "collect $arg1" "\[\\1\]" arg1_regexp;
133 gdb_test "info tracepoints" ".*$arg1_regexp.*" "$msgstring info tracepoint"
136 proc gdb_delete_tracepoints { } {
139 send_gdb "delete tracepoints\n"
141 -re "Delete all tracepoints.*y or n.*$" {
145 -re "$gdb_prompt $" { }
146 timeout { fail "delete all tracepoints (timeout)" }
151 # Send each command in the list CMDLIST to gdb. If we see the string
152 # "error" or "warning" from gdb, we assume an error has occured and
153 # return a non-zero result. All of the commands in CMDLIST are always
154 # sent, even if an error occurs.
155 # If TESTNAME is non-null, we call pass or fail with the string in TESTNAME
156 # depending on whether or not an error/warning has occurred.
158 proc gdb_do_cmdlist { cmdlist testname } {
166 -re "\[Ee\]rror|\[Ww\]arning" {
170 -re "$gdb_prompt $" { }
171 -re "\[\r\n\]\[ \t\]*> *$" { }
174 if { $testname != "" } {
175 if { $status == 0 } {
185 # Given the file FILENAME, we read it as a list of commands and generate
186 # a list suitable for use by gdb_do_cmdlist. Lines beginning with # are
187 # ignored; blank lines are interpreted as empty lines to be sent to gdb.
189 proc gdb_process_cmdfile { filename } {
190 set id [open $filename "r"];
195 while { [gets $id line] >= 0 } {
196 if [regexp "^#" $line] {
199 set result [concat $result [list "$line"]];
205 # gdb_find_c_test_baseline
206 # returns -1 on failure (CALLER MUST CHECK RETURN!)
207 proc gdb_find_c_test_baseline { } {
210 set gdb_c_test_baseline -1;
212 send_gdb "list gdb_c_test\n"
214 -re "void.*p5,.*void.*p6.*\[\r\n\](\[0-9\]+)\[\t \]+\{.*$gdb_prompt $" {
215 set gdb_c_test_baseline $expect_out(1,string)
217 -re "$gdb_prompt $" { }
220 return $gdb_c_test_baseline;