* gdb.mi/mi-var-child.c
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / mi-support.exp
index ad968ce25fece718a17a10ca8f788adef8a7ac2e..d4236368f17f2ddb6b74a633862b94ff0505123d 100644 (file)
@@ -1,4 +1,5 @@
-# Copyright 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2007
+# Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -378,18 +379,10 @@ proc mi_gdb_file_cmd { arg } {
     global loadfile
     global GDB
     global mi_gdb_prompt
-    global last_mi_gdb_file
-    global last_mi_remote_file
+    global last_loaded_file
     upvar timeout timeout
 
-    if { $arg == "" } {
-       set arg $last_mi_gdb_file;
-    } else {
-       set last_mi_gdb_file $arg
-       if { [ info exists last_mi_remote_file ] } {
-           unset last_mi_remote_file
-       }
-    }
+    set last_loaded_file $arg
 
     if [is_remote host] {
        set arg [remote_download host $arg];
@@ -448,10 +441,10 @@ proc mi_gdb_file_cmd { arg } {
 }
 
 #
-# load a file into the debugger.
+# connect to the target and download a file, if necessary.
 # return a -1 if anything goes wrong.
 #
-proc mi_gdb_load { arg } {
+proc mi_gdb_target_load { } {
     global verbose
     global loadpath
     global loadfile
@@ -459,25 +452,8 @@ proc mi_gdb_load { arg } {
     global mi_gdb_prompt
     upvar timeout timeout
 
-    # ``gdb_unload''
-    if { $arg != "" } {
-       mi_gdb_file_cmd $arg
-    }
-
-    # ``load''
     if { [info procs gdbserver_gdb_load] != "" } {
-       global last_mi_gdb_file
-       global last_mi_remote_file
-
-       if { ! [info exists last_mi_remote_file] } {
-           if [is_remote target] {
-               set last_mi_remote_file [remote_download target $arg /tmp/[file tail $arg].[pid]]
-           } else {
-               set last_mi_remote_file $last_mi_gdb_file
-           }
-       }
-
-       set res [gdbserver_gdb_load $last_mi_remote_file]
+       set res [gdbserver_gdb_load]
        set protocol [lindex $res 0]
        set gdbport [lindex $res 1]
 
@@ -543,6 +519,17 @@ proc mi_gdb_load { arg } {
     return 0
 }
 
+#
+# load a file into the debugger.
+# return a -1 if anything goes wrong.
+#
+proc mi_gdb_load { arg } {
+    if { $arg != "" } {
+       return [mi_gdb_file_cmd $arg]
+    }
+    return 0
+}
+
 # mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb; 
 #   test the result.
 #
@@ -785,13 +772,12 @@ proc mi_run_cmd {args} {
        }
     }
 
+    if { [mi_gdb_target_load] < 0 } {
+       return
+    }
+
     if [target_info exists use_gdb_stub] {
        if [target_info exists gdb,do_reload_on_run] {
-           # Specifying no file, defaults to the executable
-           # currently being debugged.
-           if { [mi_gdb_load ""] < 0 } {
-               return;
-           }
            send_gdb "000-exec-continue\n";
            gdb_expect 60 {
                -re "000\\^running\[\r\n\]+$mi_gdb_prompt$" {}
@@ -880,8 +866,17 @@ proc mi_runto_helper {func run_or_continue} {
   if {$run_or_continue == "run"} {
       mi_run_cmd
   } else {
-    send_gdb "000-exec-continue\n"
+      send_gdb "000-exec-continue\n"
+      gdb_expect {
+         -re "000\\^running\r\n${mi_gdb_prompt}" {
+         }
+         timeout {
+           fail "$test"
+           return -1
+         }
+      }
   }
+
   gdb_expect {
     -re ".*000\\*stopped,thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" {
       pass "$test"
@@ -1009,7 +1004,14 @@ proc mi0_continue_to { bkptno func args file line test } {
 # Name cannot be "-".
 proc mi_create_varobj { name expression testname } {
     mi_gdb_test "-var-create $name * $expression" \
-        "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",type=.*" \
+        "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*" \
+        $testname
+}
+
+# Deletes the specified NAME. 
+proc mi_delete_varobj { name testname } {
+    mi_gdb_test "-var-delete $name" \
+        "\\^done,ndeleted=.*" \
         $testname
 }
 
@@ -1222,11 +1224,11 @@ proc mi_send_resuming_command {command test} {
 # be determined.
 # Does not check that the line is the same as requested.
 # The caller can check itself if required.
-proc mi_continue_to_line {location command} {
+proc mi_continue_to_line {location test} {
 
     mi_tbreak $location   
     mi_send_resuming_command "exec-continue" "run to $location (exec-continue)"
-    return [mi_wait_for_stop]
+    return [mi_wait_for_stop $test]
 }
 
 # Wait until gdb prints the current line.
This page took 0.02535 seconds and 4 git commands to generate.