-# Copyright 1998-2015 Free Software Foundation, Inc.
+# Copyright 1998-2021 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
if {[build_executable $testfile.exp $testfile \
[list $srcfile $srcfile2] debug] == -1} {
- untested $testfile.exp
+ untested "failed to compile"
return -1
}
# start gdb -- start gdb running, default procedure
#
proc dbx_gdb_start { } {
- global verbose
- global GDB
- global INTERNAL_GDBFLAGS GDBFLAGS
global prompt
- global spawn_id
global timeout
- verbose "Spawning $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS"
+ global gdb_spawn_id
+
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -dbx"
- if { [which $GDB] == 0 } then {
- perror "$GDB does not exist."
- exit 1
+ set res [gdb_spawn]
+ if { $res != 0} {
+ return $res
+ }
}
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
- eval "spawn $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS"
gdb_expect {
-re ".*\r\n$gdb_prompt $" {
verbose "GDB initialized."
}
-re "$prompt $" {
perror "GDB never initialized."
+ unset gdb_spawn_id
return -1
}
timeout {
perror "(timeout) GDB never initialized."
+ unset gdb_spawn_id
return -1
}
}
# right sequence of events, allowing gdb_load to do its normal thing? This way
# remotes and simulators will work, too.
#
-# [drow 2002-03-30]: We can restore the old gdb_file_cmd afterwards, though.
-set old_gdb_file_cmd_args [info args gdb_file_cmd]
-set old_gdb_file_cmd_body [info body gdb_file_cmd]
-proc gdb_file_cmd {arg} {
- global verbose
+proc local_gdb_file_cmd {arg} {
global loadpath
global loadfile
global GDB
send_gdb "symbol-file $arg\n"
gdb_expect {
- -re "Detected 64-bit symbol file.\r\nInvoking.*gdb64.*$gdb_prompt $" {
- verbose "\t\tLoaded $arg into the $GDB"
- send_gdb "exec-file $arg\n"
- gdb_expect {
- -re ".*$gdb_prompt $" {
- verbose "\t\tLoaded $arg with new symbol table into $GDB"
- return 0
- }
- timeout {
- perror "(timeout) Couldn't load $arg"
- return -1
- }
- }
- return 0
- }
- -re "Reading symbols from.*done.*$gdb_prompt $" {
+ -re "Reading symbols from.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into the $GDB"
send_gdb "exec-file $arg\n"
gdb_expect {
set stop_line [gdb_get_line_number "stop-at-call"]
gdb_test "stop at average.c:$stop_line" "Breakpoint.*at.*: file.*average\.c, line $stop_line.*"
gdb_test "stop in average.c:$stop_line" "Usage: stop in <function . address>"
- gdb_test "stop at main" "Usage: stop at <line>"
+ gdb_test "stop at main" "Usage: stop at LINE"
}
#
#test_whereis
#
proc test_whereis { } {
- gdb_test "whereis my_list" "All variables matching regular expression \"my_list\":\r\n\r\nFile.*average\.c:\r\nstatic int my_list\\\[10\\\];"
+ gdb_test "whereis my_list" "All variables matching regular expression \"my_list\":\r\n\r\nFile.*average\.c:\r\n.*\tstatic int my_list\\\[10\\\];"
}
#
global srcfile2
gdb_test "cont" ".*" "cont 1"
gdb_test "step" ".*"
- # This always fails, but it's not clear why. -sts 1999-08-17
- setup_xfail "*-*-*"
gdb_test "func sum" "'sum' not within current stack frame\."
set stop_line [gdb_get_line_number "stop-in-sum" $srcfile2]
gdb_test "stop in sum" "Breakpoint.*at.*: file.*sum\.c, line $stop_line\."
gdb_test "cont" ".*" "cont 2"
- # This always fails, but it's not clear why. -sts 1999-08-17
- setup_xfail "*-*-*"
- gdb_test "func print_average" ".*in print_average.*\\(list=.*, low=0, high=6\\).*at.*average\.c:${decimal}\r\n\${decimal}\[ \t\]+total = sum\\(list, low, high\\);"
+ gdb_test "func print_average" ".*in print_average.*\\(list=.*, low=0, high=6\\).*at.*average\.c:${decimal}\r\n${decimal}\[ \t\]+total = sum\\(list, low, high\\);"
}
# Start with a fresh gdb.
gdb_exit
-global GDBFLAGS
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS --dbx"
-gdb_start
-dbx_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+with_override gdb_file_cmd local_gdb_file_cmd {
+ save_vars GDBFLAGS {
+ set GDBFLAGS "$GDBFLAGS --dbx"
-test_breakpoints
-test_assign
-test_whereis
-gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
-test_func
+ gdb_start
+ dbx_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
-#exit and cleanup
-gdb_exit
+ test_breakpoints
+ test_assign
+ test_whereis
+ gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
+ test_func
-set GDBFLAGS $saved_gdbflags
-eval proc gdb_file_cmd {$old_gdb_file_cmd_args} {$old_gdb_file_cmd_body}
+ #exit and cleanup
+ gdb_exit
+ }
+}
return 0