Allow gdb to find debug symbols file by build-id for PE file format also
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / mi-support.exp
index afe13e83b105f6c996ef610de1d0547a7c672f5d..6827ef9cb64635fa1cdc72dc48f445cd2173655b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2014 Free Software Foundation, Inc.
+# Copyright 1999-2015 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
@@ -17,6 +17,8 @@
 
 # Test setup routines that work with the MI interpreter.
 
+load_lib gdb-utils.exp
+
 # The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt.
 # Set it if it is not already set.
 global mi_gdb_prompt
@@ -189,7 +191,7 @@ proc default_mi_gdb_start { args } {
            return -1
        }
     }
-    set gdb_spawn_id -1
+    set gdb_spawn_id $res
 
     # FIXME: mi output does not go through pagers, so these can be removed.
     # force the height to "unlimited", so no pagers get used
@@ -475,7 +477,10 @@ proc mi_gdb_target_load { } {
 
     if { [info procs gdbserver_gdb_load] != "" } {
        mi_gdb_test "kill" ".*" ""
-       set res [gdbserver_gdb_load]
+       if { [catch gdbserver_gdb_load res] == 1 } {
+           perror $res
+           return -1
+       }
        set protocol [lindex $res 0]
        set gdbport [lindex $res 1]
 
@@ -799,6 +804,30 @@ proc mi_gdb_test { args } {
     return $result
 }
 
+# Collect output sent to the console output stream until UNTIL is
+# seen.  UNTIL is a regular expression.  MESSAGE is the message to be
+# printed in case of timeout.
+
+proc mi_gdb_expect_cli_output {until message} {
+
+    set output ""
+    gdb_expect {
+       -re "~\"(\[^\r\n\]+)\"\r\n" {
+           append output $expect_out(1,string)
+           exp_continue
+       }
+       -notransfer -re "$until" {
+           # Done
+       }
+       timeout {
+           fail "$message (timeout)"
+           return ""
+       }
+    }
+
+    return $output
+}
+
 #
 # MI run command.  (A modified version of gdb_run_cmd)
 #
@@ -806,6 +835,18 @@ proc mi_gdb_test { args } {
 # In patterns, the newline sequence ``\r\n'' is matched explicitly as
 # ``.*$'' could swallow up output that we attempt to match elsewhere.
 
+# Send the command to run the test program.
+#
+# If USE_MI_COMMAND is true, the "-exec-run" command is used.
+# Otherwise, the "run" (CLI) command is used.  If the global USE_GDB_STUB is
+# true, -exec-continue and continue are used instead of their run counterparts.
+#
+# ARGS is passed as argument to the command used to run the test program.
+# Beware that arguments to "-exec-run" do not have the same semantics as
+# arguments to the "run" command, so USE_MI_COMMAND influences the meaning
+# of ARGS.  If USE_MI_COMMAND is true, they are arguments to -exec-run.
+# If USE_MI_COMMAND is false, they are effectively arguments passed
+# to the test program.  If the global USE_GDB_STUB is true, ARGS is not used.
 proc mi_run_cmd_full {use_mi_command args} {
     global suppress_flag
     if { $suppress_flag } {
@@ -818,15 +859,13 @@ proc mi_run_cmd_full {use_mi_command args} {
     if {$use_mi_command} {
        set run_prefix "220-exec-"
        set run_match "220"
-       set set_args_cmd "-exec-arguments"
     } else {
        set run_prefix ""
        set run_match ""
-       set set_args_cmd "set args"
     }
 
-    if [target_info exists gdb_init_command] {
-       send_gdb "[target_info gdb_init_command]\n"
+    foreach command [gdb_init_commands] {
+       send_gdb "$command\n"
        gdb_expect 30 {
            -re "$mi_gdb_prompt$" { }
            default {
@@ -864,16 +903,7 @@ proc mi_run_cmd_full {use_mi_command args} {
        return 0
     }
 
-    send_gdb "${set_args_cmd} $args\n"
-    gdb_expect {
-       -re "$mi_gdb_prompt$" { }
-       default {
-           perror "settings args failed"
-           return -1
-       }
-    }
-
-    send_gdb "${run_prefix}run\n"
+    send_gdb "${run_prefix}run $args\n"
     gdb_expect {
        -re "${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" {
        }
@@ -989,10 +1019,10 @@ proc mi_detect_async {} {
     global async
     global mi_gdb_prompt
 
-    send_gdb "show target-async\n"
+    send_gdb "show mi-async\n"
 
     gdb_expect {
-       -re ".*Controlling the inferior in asynchronous mode is on...*$mi_gdb_prompt$" {
+       -re "asynchronous mode is on...*$mi_gdb_prompt$" {
            set async 1
        }
        -re ".*$mi_gdb_prompt$" {
@@ -1165,8 +1195,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
This page took 0.026556 seconds and 4 git commands to generate.