Improve gdb_remote_download, remove gdb_download
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / mi-support.exp
index 20546f64bef844804246c24b8517fb21f5480571..cf3005d19ab890d12b4f82270d8d1a3981146b58 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Free Software Foundation, Inc.
+# Copyright 1999-2016 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
@@ -26,7 +26,6 @@ if ![info exists mi_gdb_prompt] then {
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
-global mi_inferior_spawn_id
 global mi_inferior_tty_name
 
 set MIFLAGS "-i=mi"
@@ -104,7 +103,7 @@ proc default_mi_gdb_start { args } {
     global gdb_prompt
     global mi_gdb_prompt
     global timeout
-    global gdb_spawn_id
+    global gdb_spawn_id inferior_spawn_id
     global MIFLAGS
 
     gdb_stop_suppressing_tests
@@ -138,15 +137,6 @@ proc default_mi_gdb_start { args } {
        }
     }
 
-    # Create the new PTY for the inferior process.
-    if { $separate_inferior_pty } {
-       spawn -pty
-       global mi_inferior_spawn_id
-       global mi_inferior_tty_name
-       set mi_inferior_spawn_id $spawn_id
-       set mi_inferior_tty_name $spawn_out(slave,name)
-    }
-
     set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host_info gdb_opts]"]
     if { $res < 0 || $res == "" } {
        perror "Spawning $GDB failed."
@@ -214,9 +204,14 @@ proc default_mi_gdb_start { args } {
            warning "Couldn't set the width to 0."
        }
     }
-    # If allowing the inferior to have its own PTY then assign the inferior
-    # its own terminal device here.
+
+    # Create the new PTY for the inferior process.
     if { $separate_inferior_pty } {
+       spawn -pty
+       global mi_inferior_tty_name
+       set inferior_spawn_id $spawn_id
+       set mi_inferior_tty_name $spawn_out(slave,name)
+
        send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
        gdb_expect 10 {
            -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
@@ -228,6 +223,10 @@ proc default_mi_gdb_start { args } {
        }
     }
 
+    if {![info exists inferior_spawn_id]} {
+       set inferior_spawn_id $gdb_spawn_id
+    }
+
     mi_detect_async
 
     return 0
@@ -770,29 +769,16 @@ proc mi_gdb_test { args } {
     if { $result == 0 } {
        if [ info exists ipattern ] {
            if { ![target_info exists gdb,noinferiorio] } {
-               if { [target_info gdb_protocol] == "remote"
-                   || [target_info gdb_protocol] == "extended-remote"
-                   || [target_info protocol] == "sim"} {
-
-                   gdb_expect {
-                       -re "$ipattern" {
-                           pass "$message inferior output"
-                       }
-                       timeout {
-                           fail "$message inferior output (timeout)"
-                           set result 1
-                       }
+               global gdb_spawn_id inferior_spawn_id
+
+               set sid "$inferior_spawn_id $gdb_spawn_id"
+               gdb_expect {
+                   -i "$sid" -re "$ipattern" {
+                       pass "$message inferior output"
                    }
-               } else {
-                   global mi_inferior_spawn_id
-                   expect {
-                       -i $mi_inferior_spawn_id -re "$ipattern" {
-                           pass "$message inferior output"
-                       }
-                       timeout {
-                           fail "$message inferior output (timeout)"
-                           set result 1
-                       }
+                   timeout {
+                       fail "$message inferior output (timeout)"
+                       set result 1
                    }
                }
            } else {
@@ -900,6 +886,9 @@ proc mi_run_cmd_full {use_mi_command args} {
        # to better handle RUN.
        send_gdb  "jump *$start\n"
        warning "Using CLI jump command, expect run-to-main FAIL"
+       gdb_expect {
+           -re "${run_match}&\"jump \\*${start}\\n\"\[\r\n\]+~\"Continuing at 0x\[0-9A-Fa-f\]+\\n.\"\[\r\n\]+\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n${mi_gdb_prompt}" {}
+       }
        return 0
     }
 
@@ -1195,8 +1184,9 @@ proc mi_expect_interrupt { test } {
        set prompt_re "$mi_gdb_prompt$"
     }
 
-    set r "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\""
-
+    set r_nonstop "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\""
+    set r_allstop "reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\""
+    set r "(${r_nonstop}|${r_allstop})"
     set any "\[^\n\]*"
 
     # A signal can land anywhere, just ignore the location
@@ -1970,7 +1960,7 @@ proc mi_load_shlibs { args } {
     }
 
     foreach file $args {
-       gdb_download [shlib_target_file $file]
+       gdb_remote_download target [shlib_target_file $file]
     }
 
     # Even if the target supplies full paths for shared libraries,
@@ -1978,19 +1968,8 @@ proc mi_load_shlibs { args } {
     mi_gdb_test "set solib-search-path [file dirname [lindex $args 0]]" "\^done" ""
 }
 
-proc mi_reverse_list { list } {
-    if { [llength $list] <= 1 } {
-       return $list
-    }
-    set tail [lrange $list 1 [llength $list]]
-    set rtail [mi_reverse_list $tail]
-    lappend rtail [lindex $list 0]
-    return $rtail
-}
-
-proc mi_check_thread_states { xstates test } {
+proc mi_check_thread_states { states test } {
     global expect_out
-    set states [mi_reverse_list $xstates]
     set pattern ".*\\^done,threads=\\\["
     foreach s $states {
        set pattern "${pattern}(.*)state=\"$s\""
@@ -2408,7 +2387,8 @@ proc mi_build_kv_pairs {attr_list {joiner ,}} {
 #
 # All arguments for the breakpoint may be specified using the options
 # number, type, disp, enabled, addr, func, file, fullanme, line,
-# thread-groups, times, ignore, script, and original-location.
+# thread-groups, cond, evaluated-by, times, ignore, script,
+# and original-location.
 #
 # Only if -script and -ignore are given will they appear in the output.
 # Otherwise, this procedure will skip them using ".*".
@@ -2423,17 +2403,36 @@ proc mi_make_breakpoint {args} {
     parse_args {{number .*} {type .*} {disp .*} {enabled .*} {addr .*}
        {func .*} {file .*} {fullname .*} {line .*}
        {thread-groups \\\[.*\\\]} {times .*} {ignore 0}
-       {script ""} {original-location .*}}
+       {script ""} {original-location .*} {cond ""} {evaluated-by ""}}
 
     set attr_list {}
     foreach attr [list number type disp enabled addr func file \
-                     fullname line thread-groups times] {
+                     fullname line thread-groups] {
        lappend attr_list $attr [set $attr]
     }
 
     set result "bkpt={[mi_build_kv_pairs $attr_list]"
 
     # There are always exceptions.
+
+    # If COND is not preset, do not output it.
+    if {[string length $cond] > 0} {
+       append result ","
+       append result [mi_build_kv_pairs [list "cond" $cond]]
+
+       # When running on a remote, GDB may output who is evaluating
+       # breakpoint conditions.
+       if {[string length ${evaluated-by}] > 0} {
+           append result [mi_build_kv_pairs \
+                              [list "evaluated-by" ${evaluated-by}]]
+       } else {
+           append result {(,evaluated-by=".*")?}
+       }
+    }
+
+    append result ","
+    append result [mi_build_kv_pairs [list "times" $times]]
+
     # If SCRIPT and IGNORE are not present, do not output them.
     if {$ignore != 0} {
        append result ","
@@ -2494,3 +2493,21 @@ proc mi_make_breakpoint_table {bp_list} {
     # Assemble the final regexp.
     return "BreakpointTable={nr_rows=\"$nr\",nr_cols=\"$nc\",$header,$body}"
 }
+
+# Return a 1 for configurations that do not support Python scripting.
+# Note: This also sets various globals that specify which version of Python
+# is in use.  See skip_python_tests_prompt.
+
+proc mi_skip_python_tests {} {
+    global mi_gdb_prompt
+    return [skip_python_tests_prompt "$mi_gdb_prompt$"]
+}
+
+# Check whether we're testing with the remote or extended-remote
+# targets.
+
+proc mi_is_target_remote {} {
+    global mi_gdb_prompt
+
+    return [gdb_is_target_remote_prompt "$mi_gdb_prompt"]
+}
This page took 0.026199 seconds and 4 git commands to generate.