* config/gdbserver.exp (gdbserver_gdb_load): Update argument list.
authorDaniel Jacobowitz <drow@false.org>
Tue, 27 Mar 2007 17:59:38 +0000 (17:59 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 27 Mar 2007 17:59:38 +0000 (17:59 +0000)
(gdb_load): Delete, replace with...
(gdb_reload): ...this.
* gdb.server/server-run.exp: Use gdb_load and gdbserver_run.
* gdb.server/server-mon.exp: Likewise.
* lib/gdb.exp (gdb_run_cmd): Use gdb_reload.
(gdb_start_cmd): New.
(gdb_file_cmd): Save the last loaded file.
(gdb_reload): New.
(gdb_gnu_strip_debug): Use transform.
* lib/gdbserver-support.exp (gdbserver_spawn): Move file download
support here.  Use new $last_loaded_file.  Check mtime.
(gdb_target_cmd): Handle ObjC failure case.
(infer_host_exec): Delete.
(gdbserver_load): Rename to...
(gdbserver_run): ...this.  Simplify.
* lib/mi-support.exp (mi_gdb_file_cmd): Set last_loaded_file.
(mi_gdb_load): Move most contents to a new function...
(mi_gdb_target_load): ...here.  Simplify call to gdbserver_gdb_load.
(mi_run_cmd): Use mi_gdb_target_load.
* gdb.base/break.exp, gdb.base/ending-run.exp, gdb.base/pending.exp,
gdb.base/sepdebug.exp, gdb.base/unload.exp, gdb.objc/objcdecode.exp:
Use gdb_run_cmd.
* gdb.base/charsign.exp: Remove incorrect comment.
* gdb.base/dbx.exp (gdb_file_cmd): Set last_loaded_file.
* gdb.ada/exec_changed.exp, gdb.ada/null_record.exp, gdb.ada/start.exp,
gdb.base/start.exp: Use gdb_start_cmd.

19 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/config/gdbserver.exp
gdb/testsuite/gdb.ada/exec_changed.exp
gdb/testsuite/gdb.ada/null_record.exp
gdb/testsuite/gdb.ada/start.exp
gdb/testsuite/gdb.base/break.exp
gdb/testsuite/gdb.base/charsign.exp
gdb/testsuite/gdb.base/dbx.exp
gdb/testsuite/gdb.base/ending-run.exp
gdb/testsuite/gdb.base/pending.exp
gdb/testsuite/gdb.base/sepdebug.exp
gdb/testsuite/gdb.base/start.exp
gdb/testsuite/gdb.base/unload.exp
gdb/testsuite/gdb.objc/objcdecode.exp
gdb/testsuite/gdb.server/server-mon.exp
gdb/testsuite/gdb.server/server-run.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/gdbserver-support.exp
gdb/testsuite/lib/mi-support.exp

index ec773407d412d030f3a8c9c2a8c3ff92575d0693..bc82912d630151d309781aa8aaf8e175e878ba13 100644 (file)
@@ -1,3 +1,33 @@
+2007-03-27  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * config/gdbserver.exp (gdbserver_gdb_load): Update argument list.
+       (gdb_load): Delete, replace with...
+       (gdb_reload): ...this.
+       * gdb.server/server-run.exp: Use gdb_load and gdbserver_run.
+       * gdb.server/server-mon.exp: Likewise.
+       * lib/gdb.exp (gdb_run_cmd): Use gdb_reload.
+       (gdb_start_cmd): New.
+       (gdb_file_cmd): Save the last loaded file.
+       (gdb_reload): New.
+       (gdb_gnu_strip_debug): Use transform.
+       * lib/gdbserver-support.exp (gdbserver_spawn): Move file download
+       support here.  Use new $last_loaded_file.  Check mtime.
+       (gdb_target_cmd): Handle ObjC failure case.
+       (infer_host_exec): Delete.
+       (gdbserver_load): Rename to...
+       (gdbserver_run): ...this.  Simplify.
+       * lib/mi-support.exp (mi_gdb_file_cmd): Set last_loaded_file.
+       (mi_gdb_load): Move most contents to a new function...
+       (mi_gdb_target_load): ...here.  Simplify call to gdbserver_gdb_load.
+       (mi_run_cmd): Use mi_gdb_target_load.
+       * gdb.base/break.exp, gdb.base/ending-run.exp, gdb.base/pending.exp,
+       gdb.base/sepdebug.exp, gdb.base/unload.exp, gdb.objc/objcdecode.exp:
+       Use gdb_run_cmd.
+       * gdb.base/charsign.exp: Remove incorrect comment.
+       * gdb.base/dbx.exp (gdb_file_cmd): Set last_loaded_file.
+       * gdb.ada/exec_changed.exp, gdb.ada/null_record.exp, gdb.ada/start.exp,
+       gdb.base/start.exp: Use gdb_start_cmd.
+
 2007-03-23  Nigel Stephens  <nigel@mips.com>
             Maciej W. Rozycki  <macro@mips.com>
 
index 9d32e5e79976fcb0dcffe58b8d821ba1ad8e0424..0e7e7b07c4f89a2773df45b2b8f7e2ee047314ee 100644 (file)
 
 load_lib gdbserver-support.exp
 
-proc gdbserver_gdb_load { arg } {
-    return [gdbserver_spawn $arg ""]
+proc gdbserver_gdb_load { } {
+    return [gdbserver_spawn ""]
 }
 
-proc gdb_load { arg } {
-    return [gdbserver_load $arg ""]
+proc gdb_reload { } {
+    return [gdbserver_run ""]
 }
index a4f4d9bda2c24de21c43e937f691ca690e141f1b..07f247680d491a60d3d39c27fecc8c66ac050257 100644 (file)
@@ -55,7 +55,12 @@ gdb_test "shell mv ${binfile1} ${binfile}" "" ""
 gdb_load ${binfile}
 
 # Start the program, we should land in the program main procedure
-gdb_test "start" \
+if { [gdb_start_cmd] < 0 } {
+    untested start
+    return -1
+}
+
+gdb_test "" \
          "first \\(\\) at .*first.adb.*" \
          "start first"
 
@@ -76,12 +81,10 @@ gdb_test "set confirm off" "" ""
 # Start the program a second time, GDB should land in procedure Second
 # this time.
 
-if [is_remote target] {
-    unsupported "start the program a second time ";
+if { [gdb_start_cmd] < 0 } {
+    fail "start second"
 } else {
-    # Start the program, we should land in the program main procedure
-    gdb_test "start" \
+    gdb_test "" \
              "second \\(\\) at .*second.adb.*" \
              "start second"
 }
-
index 8f5cb86cb97bac42d5c11bc65a2ec7bca03370c2..a403d4a518eec7f33ba9d36367c3917e60f0d149 100644 (file)
@@ -36,7 +36,12 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-gdb_test "start" \
+if { [gdb_start_cmd] < 0 } {
+    untested start
+    return -1
+}
+
+gdb_test "" \
          "null_record \\(\\) at .*null_record.adb.*" \
          "start"
 
index a658bd7cdfd32270426e291a0c036d874a9b880f..4e1da51079f135139c8c314da52109112fcfa097 100644 (file)
@@ -37,7 +37,11 @@ gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
 # Verify that "start" lands inside the right procedure.
-gdb_test "start" \
+if { [gdb_start_cmd] < 0 } {
+    untested start
+    return -1
+}
+
+gdb_test "" \
          "dummy \\(\\) at .*dummy.adb.*" \
          "start"
-
index aba80edf0c46431361f5b060cb5ba3e01a877ca8..16d05b758e0b3b76ea077f6987f507c17e8662e6 100644 (file)
@@ -202,27 +202,16 @@ if [istarget "mips-idt-*"] then {
 #
 # run until the breakpoint at main is hit. For non-stubs-using targets.
 #
-if ![target_info exists use_gdb_stub] {
-  if [istarget "*-*-vxworks*"] then {
-    send_gdb "run vxmain \"2\"\n"
-    set timeout 120
-    verbose "Timeout is now $timeout seconds" 2
-  } else {
-       send_gdb "run\n"
-  }
-  gdb_expect {
-    -re "The program .* has been started already.*y or n. $" {
-       send_gdb "y\n"
-       exp_continue
+gdb_run_cmd
+gdb_expect {
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" {
+       pass "run until function breakpoint"
     }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
-                           { pass "run until function breakpoint" }
-    -re ".*$gdb_prompt $"       { fail "run until function breakpoint" }
-    timeout                { fail "run until function breakpoint (timeout)" }
-  }
-} else {
-    if ![target_info exists gdb_stub] {
-       gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
+    -re "$gdb_prompt $" {
+       fail "run until function breakpoint"
+    }
+    timeout {
+       fail "run until function breakpoint (timeout)"
     }
 }
 
@@ -773,26 +762,14 @@ proc test_next_with_recursion {} {
     global decimal
     global binfile
 
-    if [target_info exists use_gdb_stub] {
-       # Reload the program.
-       delete_breakpoints
-       gdb_load ${binfile};
-    } else {
-       # FIXME: should be using runto
-       gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
-
-       delete_breakpoints
-    }
+    gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
+    delete_breakpoints
 
     gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
 
     # Run until we call factorial with 6
 
-    if [istarget "*-*-vxworks*"] then {
-       send_gdb "run vxmain \"6\"\n"
-    } else {
-       gdb_run_cmd
-    }
+    gdb_run_cmd
     gdb_expect {
        -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
        -re ".*$gdb_prompt $" {
@@ -916,29 +893,19 @@ gdb_test "break marker4" \
 #
 # run until the breakpoint at main is hit. For non-stubs-using targets.
 #
-if ![target_info exists use_gdb_stub] {
-  if [istarget "*-*-vxworks*"] then {
-    send_gdb "run vxmain \"2\"\n"
-    set timeout 120
-    verbose "Timeout is now $timeout seconds" 2
-  } else {
-       send_gdb "run\n"
-  }
-  gdb_expect {
-    -re "The program .* has been started already.*y or n. $" {
-       send_gdb "y\n"
-       exp_continue
+gdb_run_cmd
+gdb_expect {
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" {
+       pass "run until function breakpoint, optimized file"
     }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
-                           { pass "run until function breakpoint, optimized file" }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
-                           { pass "run until function breakpoint, optimized file (code motion)" }
-    -re ".*$gdb_prompt $"       { fail "run until function breakpoint, optimized file" }
-    timeout                { fail "run until function breakpoint, optimized file (timeout)" }
-  }
-} else {
-    if ![target_info exists gdb_stub] {
-       gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" {
+       pass "run until function breakpoint, optimized file (code motion)"
+    }
+    -re "$gdb_prompt $" {
+       fail "run until function breakpoint, optimized file"
+    }
+    timeout {
+       fail "run until function breakpoint, optimized file (timeout)"
     }
 }
 
index 7383fd672822a2d06beae895d33c067a689310ac..e3d4cd71c9596153276ca2ad26f8623909a40f24 100644 (file)
@@ -44,8 +44,6 @@ proc do_test { cflags } {
     gdb_reinitialize_dir $srcdir/$subdir
     gdb_load ${binfile}
 
-    # For C programs, "start" should stop in main().
-
     gdb_test "p n" \
             "= \"A\""
     gdb_test "p s" \
index 5c0610fa563e2d711d0ec1ae5d3295e2da1aea81..cd63c667fb692bbb31eaaf0888888f04f66834cd 100644 (file)
@@ -184,6 +184,9 @@ proc gdb_file_cmd {arg} {
     global gdb_prompt
     global spawn_id
     upvar timeout timeout
+    global last_loaded_file
+
+    set last_loaded_file $arg
 
     if [is_remote host] {
         set arg [remote_download host $arg];
index acf0d79173472f69d31803ca984a1f0a3c70986b..edf1181cf9aa4f0e460811852bfbf79acf1bc815 100644 (file)
@@ -67,11 +67,9 @@ gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
 # Expect to hit the bp at line "1", but symbolize this
 # as line "13".  Then try to clear it--this should work.
 #
-if [target_info exists use_gdb_stub] {
-  gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
-} else {
-  gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
-}
+gdb_run_cmd
+gdb_test "" ".*Breakpoint.*1.*callee.*13.*" "run"
+
 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
 send_gdb "i b\n"
 gdb_expect {
index c3351e68acf0bc83d30a53f38472cd53d64ffb80..3ba51767247f2a07c38f7452fae9dbb95443e494 100644 (file)
@@ -191,7 +191,8 @@ gdb_test "info break" \
 # Run to main which should resolve a pending breakpoint
 #
 
-gdb_test "run" \
+gdb_run_cmd
+gdb_test "" \
 "Breakpoint.*at.*
 Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
 Breakpoint.*, main.*$mainline.*" \
index 8911f51289227fad6399d563d126799c4954fc39..e0a36ac7cb8034d15d836b2a2815c923759019d9 100644 (file)
@@ -199,27 +199,16 @@ if [istarget "mips-idt-*"] then {
 #
 # run until the breakpoint at main is hit. For non-stubs-using targets.
 #
-if ![target_info exists use_gdb_stub] {
-  if [istarget "*-*-vxworks*"] then {
-    send_gdb "run vxmain \"2\"\n"
-    set timeout 120
-    verbose "Timeout is now $timeout seconds" 2
-  } else {
-       send_gdb "run\n"
-  }
-  gdb_expect {
-    -re "The program .* has been started already.*y or n. $" {
-       send_gdb "y\n"
-       exp_continue
+gdb_run_cmd
+gdb_expect {
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" {
+       pass "run until function breakpoint"
     }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
-                           { pass "run until function breakpoint" }
-    -re ".*$gdb_prompt $"       { fail "run until function breakpoint" }
-    timeout                { fail "run until function breakpoint (timeout)" }
-  }
-} else {
-    if ![target_info exists gdb_stub] {
-       gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
+    -re "$gdb_prompt $" {
+       fail "run until function breakpoint"
+    }
+    timeout {
+       fail "run until function breakpoint (timeout)"
     }
 }
 
@@ -759,26 +748,14 @@ proc test_next_with_recursion {} {
     global decimal
     global binfile
 
-    if [target_info exists use_gdb_stub] {
-       # Reload the program.
-       delete_breakpoints
-       gdb_load ${binfile};
-    } else {
-       # FIXME: should be using runto
-       gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
-
-       delete_breakpoints
-    }
+    gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
+    delete_breakpoints
 
     gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
 
     # Run until we call factorial with 6
 
-    if [istarget "*-*-vxworks*"] then {
-       send_gdb "run vxmain \"6\"\n"
-    } else {
-       gdb_run_cmd
-    }
+    gdb_run_cmd
     gdb_expect {
        -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
        -re ".*$gdb_prompt $" {
@@ -883,29 +860,19 @@ gdb_test "break marker4" \
 #
 # run until the breakpoint at main is hit. For non-stubs-using targets.
 #
-if ![target_info exists use_gdb_stub] {
-  if [istarget "*-*-vxworks*"] then {
-    send_gdb "run vxmain \"2\"\n"
-    set timeout 120
-    verbose "Timeout is now $timeout seconds" 2
-  } else {
-       send_gdb "run\n"
-  }
-  gdb_expect {
-    -re "The program .* has been started already.*y or n. $" {
-       send_gdb "y\n"
-       exp_continue
+gdb_run_cmd
+gdb_expect {
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" {
+       pass "run until function breakpoint, optimized file"
     }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
-                           { pass "run until function breakpoint, optimized file" }
-    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
-                           { pass "run until function breakpoint, optimized file (code motion)" }
-    -re ".*$gdb_prompt $"       { fail "run until function breakpoint, optimized file" }
-    timeout                { fail "run until function breakpoint, optimized file (timeout)" }
-  }
-} else {
-    if ![target_info exists gdb_stub] {
-       gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
+    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" {
+       pass "run until function breakpoint, optimized file (code motion)"
+    }
+    -re "$gdb_prompt $" {
+       fail "run until function breakpoint, optimized file"
+    }
+    timeout {
+       fail "run until function breakpoint, optimized file (timeout)"
     }
 }
 
index e8e21d6c826de01fde187039123010f048ca348b..27b2bde1ca95b44d1a4fb47c2ba0ec6d99849e22 100644 (file)
@@ -37,8 +37,12 @@ gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
 # For C programs, "start" should stop in main().
+if { [gdb_start_cmd] < 0 } {
+    untested start
+    return -1
+}
 
-gdb_test "start" \
+gdb_test "" \
          "main \\(\\) at .*start.c.*" \
          "start"
 
index 665cd06df4469d7232cfb9e7ebfd2541372a413b..105ddc40728d283a8ca0e1b2eff89e4f7a24597d 100644 (file)
@@ -90,26 +90,27 @@ gdb_test "info break" \
 
 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
 
-gdb_test "run" \
-"Starting program.*unload.*
-Breakpoint.*at.*
+gdb_run_cmd
+gdb_test "" \
+"Breakpoint.*at.*
 Pending breakpoint \"shrfunc1\" resolved.*
 Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
 "running program"
 
 gdb_test "continue" \
-"Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
+"Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
 "continuing to end of program"
 
 #
 # Try to rerun program and verify that shared breakpoint is reset properly
 #
 
-gdb_test "run" \
+gdb_run_cmd
+gdb_test "" \
 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
 "rerun to shared library breakpoint"
 
 gdb_test "continue" \
-"Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
+"Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
 "continuing to end of program second time"
 
index 0aee7859c948d31ee998bb1673c296480575b675..e860c4204dcfb1dad1a32ce9da9992cb005c5c96 100644 (file)
@@ -72,12 +72,13 @@ gdb_test_multiple "break multipleDef" $name \
 }
 
 set name "continue after break on multiply defined symbol"
-gdb_test_multiple "run" $name \
+gdb_run_cmd
+gdb_test_multiple "" $name \
 {
-    -re "Starting program.*Breakpoint \[0-9\]+, multipleDef \\\(\\\) at .*\r\n$gdb_prompt $" {
+    -re "Breakpoint \[0-9\]+, multipleDef \\\(\\\) at .*\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "Starting program.*\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" {
+    -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" {
        send_gdb "0\n"
        kfail "gdb/1238" $name
        # gdb is in a bad state here.
index 579c13ed37fedd940b9da3f5bbbbf9d35127b39b..d014a98eb62be2e324f94cac10bbf4bddb0f7ada 100644 (file)
@@ -34,10 +34,11 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 gdb_exit
 gdb_start
-
-gdbserver_load $binfile ""
+gdb_load $binfile
 gdb_reinitialize_dir $srcdir/$subdir
 
+gdbserver_run ""
+
 gdb_test_multiple "monitor help" "" {
     -re "Unknown monitor command.*$gdb_prompt $" {
        fail "monitor help"
index 039da5c32af5e0046eb483367160c32eb663c472..4cd8e62f3f3bfdafced65d1288952dc00ab8d9a7 100644 (file)
@@ -34,8 +34,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 gdb_exit
 gdb_start
+gdb_load $binfile
 
-gdbserver_load $binfile ""
+gdbserver_run ""
 gdb_reinitialize_dir $srcdir/$subdir
 
 gdb_breakpoint main
index 40f19b8a727ada1909f425ab1ebb839361828c47..4cf763dac94da04b6e7a144f22b2e4d38c6a5b38 100644 (file)
@@ -203,9 +203,7 @@ proc gdb_run_cmd {args} {
 
     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 { [gdb_load ""] != 0 } {
+           if { [gdb_reload] != 0 } {
                return;
            }
            send_gdb "continue\n";
@@ -250,7 +248,7 @@ proc gdb_run_cmd {args} {
                    send_gdb "y\n"
                }
                -re "The program is not being run.*$gdb_prompt $" {
-                   if { [gdb_load ""] != 0 } {
+                   if { [gdb_reload] != 0 } {
                        return;
                    }
                    send_gdb "jump *$start\n";
@@ -272,7 +270,7 @@ proc gdb_run_cmd {args} {
     }
 
     if [target_info exists gdb,do_reload_on_run] {
-       if { [gdb_load ""] != 0 } {
+       if { [gdb_reload] != 0 } {
            return;
        }
     }
@@ -289,6 +287,42 @@ proc gdb_run_cmd {args} {
     }
 }
 
+# Generic start command.  Return 0 if we could start the program, -1
+# if we could not.
+
+proc gdb_start_cmd {args} {
+    global gdb_prompt
+
+    if [target_info exists gdb_init_command] {
+       send_gdb "[target_info gdb_init_command]\n";
+       gdb_expect 30 {
+           -re "$gdb_prompt $" { }
+           default {
+               perror "gdb_init_command for target failed";
+               return;
+           }
+       }
+    }
+
+    if [target_info exists use_gdb_stub] {
+       return -1
+    }
+
+    send_gdb "start $args\n"
+    gdb_expect 60 {
+       -re "The program .* has been started already.*y or n. $" {
+           send_gdb "y\n"
+           exp_continue
+       }
+       # Use -notransfer here so that test cases (like chng-sym.exp)
+       # may test for additional start-up messages.
+       -notransfer -re "Starting program: \[^\r\n\]*" {
+           return 0
+       }
+    }
+    return -1
+}
+
 # Set a breakpoint at FUNCTION.  If there is an additional argument it is
 # a list of options; the only currently supported option is allow-pending.
 
@@ -1001,6 +1035,9 @@ proc gdb_file_cmd { arg } {
     global gdb_prompt
     global verbose
     global GDB
+    global last_loaded_file
+
+    set last_loaded_file $arg
 
     # Set whether debug info was found.
     # Default to "fail".
@@ -1937,6 +1974,18 @@ proc gdb_load { arg } {
     return [gdb_file_cmd $arg]
 }
 
+# gdb_reload -- load a file into the target.  Called before "running",
+# either the first time or after already starting the program once,
+# for remote targets.  Most files that override gdb_load should now
+# override this instead.
+
+proc gdb_reload { } {
+    # For the benefit of existing configurations, default to gdb_load.
+    # Specifying no file defaults to the executable currently being
+    # debugged.
+    return [gdb_load ""]
+}
+
 proc gdb_continue { function } {
     global decimal
 
@@ -2381,8 +2430,8 @@ proc gdb_gnu_strip_debug { dest args } {
     gdb_exit
 
     set debug_file [separate_debug_filename $dest]
-    set strip_to_file_program strip
-    set objcopy_program objcopy
+    set strip_to_file_program [transform strip]
+    set objcopy_program [transform objcopy]
 
     # Make sure the directory that will hold the separated debug
     # info actually exists.
index 12b14a299eaafa698a1736319e8bb1fb3056c860..3bf974d319b964b0b0fe88847f571b94a3e941b2 100644 (file)
@@ -80,6 +80,11 @@ proc gdb_target_cmd { targetname serialport } {
            -re "Timeout reading from remote system.*$gdb_prompt $" {
                verbose "Got timeout error from gdb."
            }
+           -notransfer -re "Remote debugging using .*\r\n> $" {
+               # We got an unexpected prompt while creating the target.
+               # Leave it there for the test to diagnose.
+               return 1
+           }
            timeout {
                send_gdb "\ 3"
                break
@@ -129,8 +134,40 @@ proc skip_gdbserver_tests { } {
 #
 # Returns the target protocol and socket to connect to.
 
-proc gdbserver_spawn { server_exec child_args } {
+proc gdbserver_spawn { child_args } {
     global portnum
+    global gdbserver_host_exec
+    global gdbserver_host_mtime
+    global gdbserver_server_exec
+    global last_loaded_file
+
+    set host_exec $last_loaded_file
+
+    # If we already downloaded a file to the target, see if we can reuse it.
+    set reuse 0
+    if { [info exists gdbserver_server_exec] } {
+       set reuse 1
+
+       # If the file has changed, we can not.
+       if { $host_exec != $gdbserver_host_exec } {
+           set reuse 0
+       }
+
+       # If the mtime has changed, we can not.
+       if { [file mtime $host_exec] != $gdbserver_host_mtime } {
+           set reuse 0
+       }
+    }
+
+    if { $reuse == 0 } {
+       set gdbserver_host_exec $host_exec
+       set gdbserver_host_mtime [file mtime $host_exec]
+       if [is_remote target] {
+           set gdbserver_server_exec [remote_download target $host_exec /tmp/[file tail $host_exec].[pid]]
+       } else {
+           set gdbserver_server_exec $host_exec
+       }
+    }
 
     # Port id -- either specified in baseboard file, or managed here.
     if [target_info exists gdb,socketport] {
@@ -162,7 +199,7 @@ proc gdbserver_spawn { server_exec child_args } {
     # Fire off the debug agent.  This flavour of gdbserver takes as
     # arguments the port information, the name of the executable file to
     # be debugged, and any arguments.
-    set gdbserver_command "$gdbserver :$portnum $server_exec"
+    set gdbserver_command "$gdbserver :$portnum $gdbserver_server_exec"
     if { $child_args != "" } {
        append gdbserver_command " $child_args"
     }
@@ -194,58 +231,13 @@ proc gdbserver_spawn { server_exec child_args } {
     return [list $protocol $gdbport]
 }
 
-proc infer_host_exec { } {
-    set host_exec ""
-
-    send_gdb "info files\n"
-    gdb_expect 30 {
-       -re "Symbols from \"(\[^\"\]+)\"" {
-           set host_exec $expect_out(1,string)
-           exp_continue
-       }
-       -re "Local exec file:\[\r\n\]+\[ \t\]*`(\[^'\]+)'," {
-           set host_exec $expect_out(1,string)
-           exp_continue
-       }
-       -re "$gdb_prompt $" { }
-    }
-
-    return $host_exec
-}
-
 # Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
 # to it.  Return 0 on success, or non-zero on failure.
 
-proc gdbserver_load { host_exec child_args } {
-    global gdbserver_host_exec
-    global gdbserver_server_exec
-
-    # If we weren't passed an explicit binary, try to reuse the current
-    # one.  If we were, be sure to redownload it.
-
-    if { $host_exec == "" && $gdbserver_host_exec == "" } {
-       set gdbserver_host_exec [infer_host_exec]
-    } elseif { $host_exec != "" } {
-       set gdbserver_host_exec $host_exec
-       if [info exists gdbserver_server_exec] { unset gdbserver_server_exec }
-    }
-
-    if { ! [info exists gdbserver_server_exec] } {
-       if [is_remote target] {
-           set gdbserver_server_exec [remote_download target $host_exec /tmp/[file tail $gdbserver_host_exec].[pid]]
-       } else {
-           set gdbserver_server_exec $gdbserver_host_exec
-       }
-    }
-
-    set res [gdbserver_spawn $gdbserver_server_exec $child_args]
+proc gdbserver_run { child_args } {
+    set res [gdbserver_spawn $child_args]
     set protocol [lindex $res 0]
     set gdbport [lindex $res 1]
 
-    if { $host_exec != "" } {
-       if [gdb_file_cmd $host_exec] {
-           return -1
-       }
-    }
-    gdb_target_cmd $protocol $gdbport
+    return [gdb_target_cmd $protocol $gdbport]
 }
index 111bc840a48e8509fd6de536a54d7432532f9529..d94d0d79c1bba1898ce509668b36fb8af1f86536 100644 (file)
@@ -379,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];
@@ -449,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
@@ -460,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]
 
@@ -544,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.
 #
@@ -786,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$" {}
This page took 0.047036 seconds and 4 git commands to generate.