@@ -16,9 +16,7 @@
# Regression test for expression evaluation of address space qualifiers
# in C and C++.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
gdb_test_no_output "set language c"
@@ -14,9 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
# Helper to test the -a option to alias.
# Aliases that are abbreviations of commands (e.g. r -> run)
@@ -495,10 +495,7 @@ proc thread_test {} {
if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load ${binfile}
+ clean_restart $binfile
if {![runto_main]} {
return
}
@@ -28,10 +28,7 @@
#
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
+clean_restart
gdb_test "print !1" ".\[0-9\]* = 0" "print value of !1"
@@ -393,11 +393,9 @@ proc test_ld {file ifmain trynosym displacement} {
# First test normal `file'-command loaded $FILE with symbols.
- gdb_exit
- gdb_start
+ clean_restart
# Clear it to never find any separate debug infos in $debug_root.
gdb_test_no_output "set debug-file-directory"
- gdb_reinitialize_dir $srcdir/$subdir
gdb_load $file
# Print the "PIE (Position Independent Executable) displacement" message.
@@ -479,11 +477,9 @@ proc test_ld {file ifmain trynosym displacement} {
# without symbols. SYMBOL_OBJFILE is not available and only
# EXEC_BFD must be used.
- gdb_exit
- gdb_start
+ clean_restart
# Clear it to never find any separate debug infos in $debug_root.
gdb_test_no_output "set debug-file-directory"
- gdb_reinitialize_dir $srcdir/$subdir
# Print the "PIE (Position Independent Executable)
# displacement" message.
@@ -290,10 +290,7 @@ gdb_test "restart 10" "Not found.*" "no more checkpoint 10"
# Now let's try setting a large number of checkpoints (>600)
#
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
runto_main
gdb_breakpoint $break1_loc
@@ -34,9 +34,7 @@ if {$result == 1} {
return
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
set testname "file [file tail $ofile]"
if {[gdb_file_cmd $ofile] == 0} {
pass $testname
@@ -21,10 +21,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
gdb_test_no_output "set listsize 1"
# initial sal should be first statement in main
@@ -42,11 +42,7 @@ proc do_detach_tests {} {
gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass"
}
-# Start with a fresh gdb
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
global pass
set pass "one"
@@ -191,11 +191,7 @@ proc test_dfp_conversions {} {
gdb_test "p (_Decimal32) 4" " = 4"
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
test_dfp_literals_accepted
test_dfp_arithmetic_expressions
@@ -52,10 +52,7 @@ if !$use_gdb_stub {
gdb_test "kill" ".*" "kill again"
gdb_test "detach" ".*" "detach again"
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load ${binfile}
+ clean_restart $binfile
}
# Ok, on to real life
@@ -31,18 +31,14 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
}
with_test_prefix "without format" {
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
gdb_test "dprintf pendfunc" "Format string required" "missing ,FMT"
gdb_test "dprintf pendfunc," "Format string required" "missing FMT"
}
with_test_prefix "without symbols" {
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
gdb_test \
"dprintf pendfunc1, \"x=%d\\n\", x" \
@@ -52,11 +52,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${op
return -1
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart $binfile
gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
"inaccessible memory is reported"
@@ -479,9 +475,7 @@ foreach_with_prefix format $formats {
# Now start a fresh gdb session, and reload the saved value files.
-gdb_exit
-gdb_start
-gdb_file_cmd ${binfile}
+clean_restart $binfile
# Now fix the endianness at the correct state.
@@ -45,12 +45,7 @@ system "rm -rf [standard_output_file *.fileio.test]"
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
@@ -32,12 +32,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_load_shlib ${lib_sl}
if {![runto_main]} {
@@ -379,9 +379,6 @@ proc do_exec_tests {} {
}
}
-# Start with a fresh gdb
-
-gdb_exit
clean_restart $binfile
do_exec_tests
@@ -45,9 +45,7 @@ set line [gdb_get_line_number "set breakpoint 1 here"]
# Initialize GDB after getting the line number, to make sure
# symbols aren't loaded.
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
set msg "set breakpoint by full path before loading symbols - built absolute"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -72,9 +70,7 @@ if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}
return -1
}
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
set msg "set breakpoint by full path before loading symbols - built relative"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -103,9 +99,7 @@ with_cwd [standard_output_file {}] {
}
}
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
set msg "set breakpoint by full path before loading symbols - built other"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -57,10 +57,7 @@ if {!$core_supported} {
}
# Now restart gdb and load the corefile.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
@@ -34,10 +34,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
@@ -35,10 +35,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
@@ -93,10 +93,7 @@ if {[runto csub]} {
gdb_continue_to_end "first session"
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
# Try exercising the "minimal" language a bit...
@@ -400,12 +400,7 @@ proc test_list_invalid_args {} {
"second use of \"list +INVALID\""
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
gdb_test_no_output "set width 0"
@@ -35,11 +35,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
@@ -68,11 +64,7 @@ gdb_test "" \
".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
"run to resolved breakpoint 1 (without symbols)"
-# Restart with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
with_test_prefix "second load" {
gdb_load ${binfile}
@@ -26,9 +26,7 @@ if {[build_executable $testfile.exp $testfile \
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
with_test_prefix "observer mode off" {
@@ -49,9 +49,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
proc test_load_core { print_symbol_loading } {
global binfile binfile_lib gcorefile srcdir subdir
with_test_prefix "core ${print_symbol_loading}" {
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
gdb_test_no_output "set print symbol-loading $print_symbol_loading"
if { ${print_symbol_loading} != "off" } {
gdb_test "file $binfile" "Reading symbols from.*" "file"
@@ -1087,11 +1087,7 @@ proc test_printf_convenience_var {prefix} {
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
gdb_test "print \$pc" "No registers\\."
@@ -199,9 +199,7 @@ save_vars { env(TERM) } {
set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
set env(GDBHISTSIZE) "10"
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
operate_and_get_next "Simple operate-and-get-next, two" \
"p 7" ".* = 7" \
@@ -25,9 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
#Check that invalid options are rejected.
foreach x {"-raednow" "readnow" "foo" "-readnow s"} {
@@ -194,9 +192,7 @@ if { "${function_foo_addr}" == "${function_bar_addr}" } {
# Now use a variable as an offset to add-symbol-file, and check that
# the functions' addresses change.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
gdb_test_no_output "set \$offset = 0x10000"
@@ -317,10 +313,7 @@ with_test_prefix "global vars, 3rd" {
# Now try loading the object as an exec-file; we should be able to print
# the values of variables after we do this.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
# Check the values of the variables.
gdb_test "print static_foo" "\\\$$decimal = 1"
@@ -45,10 +45,7 @@ gdb_test "list sep-proc.c:$location" \
# Try the same, but this time with a breakpoint. We need to exit
# GDB to make sure that we havn't loaded the full symbols yet when
# we test the breakpoint insertion.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
set test "breakpoint inside included file"
gdb_test_multiple "break sep-proc.c:$location" "$test" {
@@ -561,9 +561,7 @@ proc test_different_dir {type test_different_dir xfail} {
global srcdir subdir binfile srcfile timeout gdb_prompt
global bp_location6 decimal hex
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
gdb_test_no_output "set debug-file-directory ${test_different_dir}" \
"set separate debug location"
gdb_load ${binfile}
@@ -656,9 +654,7 @@ if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1
remote_exec build "cp ${debugfile} [standard_output_file sepdebug2.debug]"
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
+ clean_restart
set escapedobjdirsubdir [string_to_regexp [standard_output_file {}]]
@@ -44,10 +44,7 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_load_shlib $libobj
if {![runto_main]} {
@@ -34,10 +34,7 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_load_shlib $binfile_lib
# Set a breakpoint in the binary.
@@ -84,10 +84,7 @@ proc do_test { lib1opts lib2opts lib1first } {
}
with_test_prefix $testopts {
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load ${binfile}
+ clean_restart $binfile
gdb_load_shlib $lib1
gdb_load_shlib $lib2
@@ -13,9 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
# Do a bunch of testing of the set/unset/show substitute-path
# commands that do not require the presence of an executable.
@@ -50,12 +50,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_load_shlib $lib_sl
gdb_load_shlib $lib_sl2
@@ -49,12 +49,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
gdb_load_shlib $lib_sl
runto_main