# non-stop, or all-stop mode.
proc test { non_stop } {
- global srcfile binfile
+ global srcfile
global gdb_prompt
global GDBFLAGS
global decimal
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $non_stop\""
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
global gdb_prompt old_gdb_prompt
global decimal
set srcfile watch_thread_num.c
- set binfile [standard_output_file ${testfile}-watch_thread_num]
+ set filename ${testfile}-watch_thread_num
+ set binfile [standard_output_file $filename]
set gdb_prompt $old_gdb_prompt
- if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
+ if { [prepare_for_testing "prepare" $filename $srcfile \
+ {debug nowarnings pthreads}] == 0 } {
- clean_restart
- gdb_load $binfile
if {![runto_main]} {
return
}
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
standard_testfile all-types.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
- }
-
-
-clean_restart
-gdb_load $binfile
-
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
+}
#
# set it up at a breakpoint so we can play with the variable values
}
proc_with_prefix test {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
# GDB used to have a bug on Windows where failing to attach once
# made a subsequent "attach" or "run" hang. So it's important for
# Attach to the parent, run it to a known point, extract the
# child's PID, and detach.
with_test_prefix "parent" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "attach $parent_pid" \
"Attaching to program.*, process $parent_pid.*" \
# Start over, and attach to the child this time.
with_test_prefix "child" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "attach $child_pid" \
"Attaching to program.*, process $child_pid.*" \
# Start the program running, and return its PID, ready for attaching.
-proc start_program {binfile} {
+proc start_program {testfile} {
global gdb_prompt
global decimal
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto setup_done]} {
return 0
proc test { editing } {
global gdb_prompt
- global binfile
global decimal
with_test_prefix "editing $editing" {
- set testpid [start_program $binfile]
+ set testpid [start_program $::testfile]
if {$testpid == ""} {
return
}
global escapedbinfile
global srcfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# Figure out a regular expression that will match the sysroot,
# noting that the default sysroot is "target:", and also noting
global timeout
global decimal
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# Figure out a regular expression that will match the sysroot,
# noting that the default sysroot is "target:", and also noting
global binfile2
global binfile3
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# Start two programs that can be attached to.
# The first program contains a 'int bidule' variable, the second a 'float bidule'.
# Run GDB on the test program up to where it will dump core.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
return false
}
- clean_restart
- gdb_load $binfile-$extension
+ clean_restart $::testfile-$extension
if { ![runto callback] } {
fail "has_cfi=$has_cfi: Can't run to callback"
"try edit when no symbol file is loaded"
# Now start with a test binary.
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
with_test_prefix "before starting inferior" {
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
# AFTER_KILL_COND is appended to the breakpoint condition, after "kill
# -SIGINT $gdb_pid".
proc test { {after_kill_cond ""} } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
proc test {continue_cmd} {
global gdb_prompt
- global binfile
global linenum
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# The bulk of the testcase. DUMPER indicates who is supposed to dump
# the core. It can be either "kernel", or "gdb".
proc test {dumper} {
- global binfile timeout corefile gdb_prompt
+ global timeout corefile gdb_prompt
# Run GDB on the bigcore program up-to where it will dump core.
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
}
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test_no_output "set print sevenbit-strings"
runto_main
# "attach".
with_test_prefix "run" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto_main]} {
return -1
with_test_prefix "attach" {
if {[can_spawn_for_attach]} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
}
proc run_test { cond_eval access_type bpexpr nloc } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { ![runto_main] } {
return -1
# Restart the inferior, which should unload the shared library, GDB
# should mark the b/p as disabled due to its condition again.
proc run_test { hit_cond } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
global line_bp
global hex decimal
global gdb_prompt
- global srcfile binfile
+ global srcfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return -1
set testfile1 "break-fun-addr1"
set srcfile1 ${testfile1}.c
-set binfile1 [standard_output_file ${testfile1}]
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } {
- untested "failed to compile first testcase"
- return -1
+if { [prepare_for_testing "prepare" $testfile1 $srcfile1] != 0 } {
+ return
}
# Start the debugger with the first executable, put a breakpoint
# on the first instruction of function "main" ("*main"), then
# run to that breakpoint.
-clean_restart
-gdb_load $binfile1
-
with_test_prefix "${testfile1}" {
gdb_test "break *main" \
set srcfile2 ${testfile2}.c
set binfile2 [standard_output_file ${testfile2}]
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
- untested "failed to compile second testcase"
- return -1
+if { [build_executable "build" $testfile2 $srcfile2] != 0 } {
+ return
}
# Now, keeping the same GDB process (so as to keep the same breakpoint),
# Restart GDB.
save_vars { GDB } {
set GDB [gdb_no_core]
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
}
# Capture the pid of GDB.
}
proc check_selected_frame_after_bt { bt_cmd stack_pattern } {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
with_test_prefix $bt_cmd {
standard_testfile .c
+set allow_float_test [allow_float_test]
+
set flags {}
lappend flags debug
lappend flags nowarnings
lappend_include_file flags $srcdir/lib/unbuffer_output.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } {
- untested "failed to compile"
- return -1
+# Build executable, and start GDB.
+if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } {
+ return
}
-set allow_float_test [allow_float_test]
-
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
standard_testfile call-signals.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
proc get_dummy_frame_number { } {
return ""
}
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
-
if { ![runto_main] } {
return 0
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-standard_testfile .c
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
-}
-
# Some targets can't do function calls, so don't even bother with this
# test.
require {!target_info exists gdb,cannot_call_functions}
-# Start with a fresh gdb.
+standard_testfile .c
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
+}
if { ![runto_main] } {
return 0
}
proc test_catch_syscall_multi_arch {} {
- global binfile
+ global testfile
set arch1 "i386"
set arch2 "i386:x86-64"
test_catch_syscall_multi_arch_1 $arch1 $arch2 $syscall1_name \
$syscall2_name $syscall_number
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
}
proc do_syscall_tests_without_xml {} {
# Execute the tests, using XML support
gdb_exit
if { [allow_xml_test] } {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
do_syscall_tests
# Now, we have to see if GDB displays a warning when we
# don't set the data-directory but try to use catch syscall
# anyway. For that, we must restart GDB first.
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
test_catch_syscall_fail_nodatadir
}
# Restart gdb
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Execute the tests, without XML support. In this case, GDB will
# only display syscall numbers, and not syscall names.
# Now let's try setting a large number of checkpoints (>600)
#
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
runto_main
gdb_breakpoint $break1_loc
#
with_test_prefix "delete checkpoint 0" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
runto_main
gdb_test "checkpoint" "Checkpoint 1: fork returned pid $decimal\\."
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ {debug additional_flags=-DVARIABLE=var1}] != 0 } {
+ return
}
set oldtimeout $timeout
gdb_test "" "Breakpoint \[0-9\]*, stop_here .*" "running to stop_here $ident"
}
-clean_restart
-gdb_load $binfile
-
gdb_test "break stop_here if (var1 == 42)" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
"setting conditional breakpoint on function"
return ""
}
-standard_testfile .c
-
# This testcase just needs a "Hello world" source file, reuse
# gdb.base/main.c instead of adding a new one.
-if { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
-}
+standard_testfile main.c
-# Start with a fresh gdb.
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
+}
if {![runto_main]} {
return 0
standard_testfile cvexpr.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
standard_testfile int-type.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
- }
-
-
-clean_restart
-gdb_load $binfile
-
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } {
+ return
+}
if {![runto_main]} {
return
proc find_location_contexts { } {
global loc_name loc_index fill
- global decimal hex gdb_prompt binfile
+ global decimal hex gdb_prompt
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# starting GDB, but before running to main.
proc_with_prefix scenario_1 { start_before } {
- global warning decimal fill bkptno_num_re binfile
+ global warning decimal fill bkptno_num_re
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { $start_before } {
if {![runto_main temporary]} {
# starting GDB, but before running to main.
proc_with_prefix scenario_2 { start_before } {
- global binfile bkptno_num_re
+ global bkptno_num_re
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { $start_before } {
if {![runto_main temporary]} {
# starting GDB, but before running to main.
proc_with_prefix scenario_3 { start_before } {
- global binfile bkptno_num_re loc_index warning
+ global bkptno_num_re loc_index warning
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { $start_before } {
if {![runto_main temporary]} {
# bother with a run to main in this case.
proc_with_prefix scenario_4 { start_before } {
- global binfile bkptno_num_re loc_index warning
+ global bkptno_num_re loc_index warning
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { $start_before } {
if {![runto_main temporary]} {
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
-
#
# set it up at a breakpoint so we can play with the variable values
#
# DISPLACED indicates whether to use displaced-stepping.
proc do_test {displaced breakpoint_always_inserted} {
global gdb_prompt decimal
- global srcfile binfile
+ global srcfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set displaced-stepping $displaced"
gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted"
# Load the core file and confirm that the full executable name is
# seen.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set saw_generated_line false
gdb_test_multiple "core-file $corefile_1" "load core file no args" {
-re "^Core was generated by `[string_to_regexp $binfile]'\\.\r\n" {
# Load the core file and confirm that the full executable name and
# argument list are seen.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set saw_generated_line false
gdb_test_multiple "core-file $corefile_2" "load core file with args" {
-re "^Core was generated by `[string_to_regexp $binfile] $args'\\.\r\n" {
# Restart, load the core file, and check the environment variable
# shows up.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Check for environment variable VAR_NAME in the environment, its
# value should be VAR_VALUE.
# LD_PRELOAD.
append_environment_default ASAN_OPTIONS verify_asan_link_order 0
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
# Start GDB with the modified environment, this means that, when
# using remote targets, gdbserver will also use the preload
# Restart GDB. This time we are _not_ using the preload library. We
# no longer need it as we are only analysing the core file now.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Load the core file.
gdb_test "core-file $corefile" \
# Now restart normally.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Test basic corefile recognition via core-file command.
remote_exec host "mv ${coremmap_data_filename} \
${coremmap_data_backup_filename}"
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Load the core file and check we get a warning about the
# coremmap.data file being missing.
# Test that we can unload the core with the "detach" command.
proc_with_prefix corefile_detach {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_test "core-file $::corefile" "Core was generated by .*" "load core"
gdb_test "detach" "No core file now\\." "detach core"
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
set re "Local core dump file:"
# Restart and run to the abort call.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {![runto_main]} {
return
gdb_test_no_output "maint print core-file-backed-mappings" \
"maint print core-file-backed-mapping with no core file"
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
[standard_output_file coredir.[getpid]/coremmap.data.backup]
remote_exec host "mv ${data_filename} ${backup_filename}"
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Load the core file. The 'coremap.data' file cannot be found by GDB,
# but all the mappings for that file are r/w and should be present in
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Basic/core tests using user-visible commands.
with_test_prefix "basics" {
if {$is_remote} {
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
}
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
}
set test_spawn_id [spawn_wait_for_attach $binfile]
standard_testfile attach.c
set escapedbinfile [string_to_regexp ${binfile}]
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
proc do_detach_tests {} {
gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass"
}
-clean_restart
-gdb_load $binfile
-
global pass
set pass "one"
do_detach_tests
# Try to compile the test case. If we can't, assume the
# toolchain does not yet provide DFP support and bail out.
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } {
- unsupported "decimal floating point not supported for this target."
- verbose "Skipping DFP tests."
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile {quiet debug}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
gdb_test "kill" ".*" "kill again"
gdb_test "detach" ".*" "detach again"
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
}
# Ok, on to real life
# Run the tests relating to the command "info sharedlibrary", to
# verify that the namespace ID is consistent.
proc test_info_shared {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { ![runto_main] } {
return
# Also tests that the namespace ID is only printed at the correct
# times.
proc_with_prefix test_conv_vars {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_test "print \$_linker_namespace_count" "0" \
"0 namespace before starting inferior"
# Restarting GDB so that we can test setting a breakpoint
# using the convenience variable, while a proper bp syntax
# isn't implemented for namespaces
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
}
# Run several tests relating to the command "info namespaces".
proc test_info_linker_namespaces {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
# Check that "info linker-namespaces" while the inferior is not running
# doesn't crash.
# Setup for calling 'test_dlmopen', this is the version of the test
# that doesn't use 'attach'.
proc test_dlmopen_no_attach {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { ![runto_main] } {
return
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
# Start the test program.
set test_spawn_id [spawn_wait_for_attach $::binfile]
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { ![runto_main] } {
return
# Check that we can 'next' over the dlclose calls without GDB giving any
# warnings or errors.
proc_with_prefix test_next_over_dlclose {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { ![runto_main] } {
return
set dp_location [gdb_get_line_number "set dprintf here"]
proc test { style } {
- global gdb_prompt binfile dp_location
+ global gdb_prompt dp_location
with_test_prefix "$style" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return -1
proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected_dprintf } {
set test_prefix "bai=${breakpoint_always_inserted} ds=${dprintf_style} dd=${disconnected_dprintf}"
- global binfile decimal gdb_prompt escapedbinfile
+ global decimal gdb_prompt escapedbinfile
with_test_prefix "$test_prefix" {
# Start with a clean gdb
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set breakpoint always-inserted ${breakpoint_always_inserted}"
gdb_test_no_output "set dprintf-style ${dprintf_style}"
gdb_exit
# Check that the process still exists by attaching a new gdb to it.
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
set test "re-attach to inferior"
set is_gdbserver [target_is_gdbserver]
# Restart GDB and 'source' the script; this will (still) run the program
# due to the 'run' command in the script.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
do_test "source $x_file" "load and run script using source command"
# This should leave us at the gdb prompt; Run program again using
gdb_test "" ".*x=3.*x=4.*x=3.*" "run to resolved dprintf"
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_load_shlib $lib_sl
#
# Restart GDB and set set up for testing.
proc restart {} {
- global binfile
global bp_location1 dp_location1
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return -1
# Test the "call" style.
proc test_call {} {
- global binfile
global bp_location1
# Now switch styles and rerun; in the absence of redirection the
# Test the "agent" style.
proc test_agent {} {
- global binfile
global gdb_prompt
restart
set srcfile_libdso1 $srcdir/$subdir/$libdso1.c
set binfile_libdso1 [standard_output_file $libdso1.so]
-if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \
- [list debug]] != "" } {
- untested "failed to compile shared library 2"
- return -1
+if { [build_executable "build shlib 1" $binfile_libdso1 \
+ $srcfile_libdso1 {debug shlib}] != 0 } {
+ return
}
-if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \
- [list debug]] != "" } {
- untested "failed to compile shared library 1"
- return -1
+if { [build_executable "build shlib 2" $binfile_libdso2 \
+ $srcfile_libdso2 {debug shlib}] != 0 } {
+ return
}
-if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \
- [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != "" } {
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $binfile_libdso2
gdb_load_shlib $binfile_libdso1
# Run the tests.
# This returns -1 on failure to compile or start, 0 otherwise.
proc dtrace_test {} {
- global testfile hex srcfile binfile
+ global testfile hex srcfile
standard_testfile
return -1
}
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto_main]} {
return -1
# this causes addresses to be out of range for IHEX.
lappend options {nopie}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile $options] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
"inaccessible memory is reported"
# Setup for the test, create COUNT breakpoints at the function BREAKPT.
proc test_setup { count } {
global srcfile
- global binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
return 0
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address"
standard_testfile
proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} {
- clean_restart
- gdb_load $::binfile
+ set filename [file tail $::binfile]
+
+ clean_restart $filename
if {![runto_main]} {
return
}
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $filename
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
standard_testfile int-type.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
- }
-
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } {
+ return
+}
if {![runto_main]} {
# don't find the $binfile for 'file delete $binfile'.
append binfile $EXEEXT
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
# Sanity-check: Verify that the executable exists. This is just to
# make sure that, when we verify later that the file does not exist,
# it really has been deleted.
standard_testfile foll-exec.c
-global binfile
-set binfile [standard_output_file "foll-exec"]
+set testfile "foll-exec"
+set binfile [standard_output_file $testfile]
set testfile2 "execd-prog"
set srcfile2 ${testfile2}.c
set binfile2 [standard_output_file ${testfile2}]
set compile_options debug
-# build the first test case
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } {
- untested "failed to compile secondary testcase"
- return -1
+# Build the executable which will be exec'd.
+if { [build_executable "build exec'd file" $testfile2 $srcfile2 $compile_options] != 0 } {
+ return
}
if { [is_remote target] } {
gdb_remote_download target $binfile2
}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } {
- untested "failed to compile main testcase"
- return -1
+# Build the test executable, which performs the exec.
+if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } {
+ return
}
proc do_exec_sysroot_test {} {
- global binfile srcfile srcfile2 testfile testfile2
global gdb_prompt
gdb_test_no_output "set sysroot /a/path/that/does/not/exist"
}
}
-# Start with a fresh gdb
-clean_restart
-gdb_load $binfile
do_exec_sysroot_test
# unmapped address in the second binary.
set objfile ${binfile}.o
-set exec1 ${binfile}1
-set exec2 ${binfile}2
+set testfile1 ${testfile}1
+set testfile2 ${testfile}2
+set exec1 [standard_output_file $testfile1]
+set exec2 [standard_output_file $testfile2]
if { [gdb_compile [file join $srcdir $subdir $srcfile] $objfile \
object [list debug]] != "" } {
# First check whether the address of "main" in exec1 is readable in
# exec2. If it is, then skip the test as unsupported.
-clean_restart
-gdb_load $exec1
+clean_restart $testfile1
if {![runto_main]} {
return -1
}
}
}
-clean_restart
-gdb_load $exec2
+clean_restart $testfile2
if {![runto_main]} {
return -1
}
# "breakpoint always-inserted" mode.
proc test { always_inserted } {
- global exec1
global gdb_prompt
- clean_restart
- gdb_load $exec1
+ clean_restart $::testfile1
gdb_test_no_output "set breakpoint always-inserted $always_inserted"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
#
# set it up at a breakpoint so we can play with the variable values
#
set oldtimeout $timeout
set timeout [expr {$timeout + 60}]
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ {debug nowarnings}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
gdb_test "break $srcfile:stop_here" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
"breakpoint function in file"
set libsrc ${srcdir}/${subdir}/${libfile}.c
set lib_sl [standard_output_file ${libfile}.sl]
-set lib_opts [list debug nowarnings]
+set lib_opts [list debug nowarnings shlib]
set exec_opts [list debug nowarnings shlib=$lib_sl]
-if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
- || [gdb_compile $srcdir/$subdir/$srcfile $binfile \
- executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib ${lib_sl}
if {![runto_main]} {
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {![runto_main]} {
return
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {![runto_main]} {
return
}
proc do_test {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_locate_shlib $::shlib_path
gdb_test_no_output "set follow-fork-mode child"
gdb_test_no_output "set detach-on-fork off"
foreach_with_prefix print_inferior_events { "on" "off" } {
foreach_with_prefix follow_fork_mode { "child" "parent" } {
foreach_with_prefix detach_on_fork { "on" "off" } {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test_no_output "set print inferior-events $print_inferior_events"
gdb_test_no_output "set follow-fork-mode $follow_fork_mode"
gdb_test_no_output "set detach-on-fork $detach_on_fork"
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
-}
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
+}
if {![runto break_me]} {
return
proc test {enable} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_test_no_output "maint frame-unwinder $enable DEBUGINFO"
# "select-frame view".
proc test_select_frame_view { with_pretty_printer } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { $with_pretty_printer } {
require allow_python_tests
# Initialize GDB after getting the line number, to make sure
# symbols aren't loaded.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set msg "set breakpoint by full path before loading symbols - built absolute"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set msg "set breakpoint by full path before loading symbols - built relative"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
}
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set msg "set breakpoint by full path before loading symbols - built other"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
standard_testfile .c
-# The ${binfile} basename needs to exceed 80 characters (`sizeof (psargs)')
+
+# The executable basename needs to exceed 80 characters (`sizeof (psargs)')
# plus some additional data to overwrite the stack frame.
set pattern 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-append binfile -${pattern}
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
-}
-# Start with a fresh gdb.
+set filename ${testfile}-${pattern}
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $filename $srcfile] != 0 } {
+ return
+}
gdb_test_no_output "set args ${pattern}" \
"set buffer exceeding arguments"
# Now restart gdb with the unstripped binary and load the corefile.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test "core ${gcorefile}" \
"Core was generated by .*" "re-load generated corefile"
}
with_test_prefix "first session" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_load_shlib ${binfile_lib}
if {![runto lib]} {
# Now restart gdb and load the corefile.
with_test_prefix "second session" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_load_shlib ${binfile_lib}
gdb_test "core ${gcorefile}" "Core was generated by .*" \
# Now restart gdb with the unstripped binary and load the corefile.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test "core ${gcorefile}" \
"Core was generated by .*" "re-load generated corefile"
}
# Now restart gdb and load the corefile.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
}
# Add the index section to the executable.
- clean_restart
- gdb_load $binfile.$extension
+ clean_restart $testfile.$extension
gdb_assert {[ensure_gdb_index ${binfile}.${extension} ${flag}] == 1} \
"add index to executable"
# Reload the executable (which now has an index), and try to
# generate and index from it. This will fail.
- clean_restart
- gdb_load $binfile.$extension
+ clean_restart $testfile.$extension
gdb_test "save gdb-index ${flag} $already_indexed_dir" \
"Error while writing index for `[string_to_regexp $binfile.$extension]': Cannot use an index to create the index" \
"try to generate an index from a binary with an index"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto abort {allow-pending}]} {
return
}
remote_exec build "rm -f ${binfile}"
-if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
- || [gdb_compile $execsrc ${binfile} executable \
- [list debug shlib=${libobj}]] != "" } {
- return -1
+if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $execsrc\
+ [list debug shlib=${libobj}]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $libobj
if {![runto_main]} {
set srcfile_lib2 $srcdir/$subdir/$lib2name.c
set binfile_lib2 [standard_output_file $lib2name.so]
-if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
- [list debug]] != "" } {
- untested "failed to compile shared library 1"
- return -1
+
+if { [build_executable "build shlib 1" $binfile_lib1 \
+ $srcfile_lib1 [list debug shlib]] != 0 } {
+ return
}
-if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
- [list debug]] != "" } {
- untested "failed to compile shared library 2"
- return -1
+if { [build_executable "build shlib 2" $binfile_lib2 \
+ $srcfile_lib2 [list debug shlib]] != 0 } {
+ return
}
-if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \
- [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != "" } {
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $binfile_lib1
gdb_load_shlib $binfile_lib2
# ifunc is resolved. For the description of RESOLVER_ATTR,
# RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above.
proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
- global binfile libfile lib_so
+ global libfile lib_so
global hex decimal
global gdb_prompt
set suffix [make_binsuffix $resolver_attr $resolver_debug $final_debug]
set lib_so [standard_output_file ${libfile}-$suffix.so]
- clean_restart
- gdb_load $binfile-$suffix
+ clean_restart $::testfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {
# Misc GNU ifunc tests. For the description of RESOLVER_ATTR,
# RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above.
proc misc_tests {resolver_attr resolver_debug final_debug} {
- global srcdir subdir srcfile binfile
+ global srcdir subdir srcfile
global libsrc lib_so libfile
global exec_opts executable
global hex gdb_prompt
# Start with a fresh gdb.
- clean_restart
- gdb_load $binfile-$suffix
+ clean_restart $::testfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if { ![runto_main] } {
return -1
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
set lib_basename hbreak-in-shr-unsupported-shr.so
set lib_so [standard_output_file ${lib_basename}]
-set lib_opts "debug"
+set lib_opts [list debug shlib]
set exec_opts [list debug shlib=${lib_so}]
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != ""
- || [gdb_compile ${srcdir}/${subdir}/${main_src} ${binfile} executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib" $lib_so $lib_src $lib_opts] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $main_src $exec_opts] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib_so
if {![runto_main]} {
# caller's caller directly.
proc setup {commands} {
- global srcfile binfile
+ global srcfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return -code return
require {expr {$compilation_succeeded}}
# Start with a fresh gdb.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
save_vars { timeout } {
set timeout 30
set binfile2 [standard_output_file $testfile2]
# Build the two executables for the test.
-if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} {
- untested "could not build $binfile"
+if {[build_executable "build exec'd file" $testfile2 $srcfile2] != 0} {
return -1
}
-if {[gdb_compile $srcdir/$subdir/$srcfile2 $binfile2 executable debug] != ""} {
- untested "could not build $binfile2"
+
+if {[prepare_for_testing "prepare" $testfile $srcfile] != 0} {
return -1
}
set binfile2 [gdb_remote_download target $binfile2]
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return -1
}
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
if { ![runto_main] } {
proc start_nested_structs_test { lang types } {
global testfile
global srcfile
- global binfile
- global subdir
- global srcdir
global compile_flags
standard_testfile infcall-nested-structs.c
append testfile "-" "$t"
}
- if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
- unresolved "failed to compile"
+ if { [prepare_for_testing "prepare for testing" \
+ $testfile $srcfile $flags] } {
return 0
}
- # Start with a fresh gdb.
- clean_restart
- gdb_load $binfile
-
# Make certain that the output is consistent
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
# that are problematic, STUB_SUITABLE is false.
proc do_test { method startup_with_shell inferior_args expected_results \
stub_suitable } {
- global binfile hex
+ global hex
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set startup-with-shell $startup_with_shell"
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
}
gdb_test_no_output "set detach-on-fork off"
}
set gcorefile [standard_output_file $testfile.gcore]
if {[gdb_gcore_cmd $gcorefile "save a core file"]} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
proc do_test { threads non-stop } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart
- gdb_load $::binfile-$threads
+ clean_restart $::testfile-$threads
}
gdb_test "info program" \
standard_testfile -test.c -lib.c
set solib_name [standard_output_file ${testfile}-lib.so]
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} ${solib_name} \
- {debug}] != "" } {
- untested "failed to compile shared library"
- return -1
-}
-if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
- [list debug shlib=${solib_name} ]] != ""} {
- untested "failed to compile executable"
- return -1
+if { [build_executable "build shlib" $solib_name $srcfile2 {debug shlib}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ [list debug shlib=${solib_name} ]] != 0} {
+ return
+}
set solib_name [gdb_load_shlib $solib_name]
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
fail "could not run to main"
# Attach to the parent, run it to a known point, extract the
# child's PID, and detach.
with_test_prefix "parent" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "attach $parent_pid" \
"Attaching to program.*, process $parent_pid.*" \
with_test_prefix "child" {
global gdb_prompt
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "attach $child_pid" \
"Attaching to program.*, process $child_pid.*" \
# The test proper.
proc do_test {} {
- global binfile
global gdb_prompt
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "set follow-fork-mode child" ".*"
set srcfile2 ${testfile2}.c
set binfile2 [standard_output_file ${testfile2}]
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \
- executable {debug}] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build exec'd file" $testfile2 $srcfile2] != 0 } {
+ return
}
if { [is_remote target] } {
set compile_options [list debug additional_flags=-DPROGRAM=\"$binfile2\"]
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
- executable $compile_options] != ""} {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
proc run_test { exit_p checkpoint_p } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop on\""
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
# and then quits GDB.
proc test {cmds_after_kill} {
- global binfile
global gdb_prompt
global decimal
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto done]} {
return
gdb_continue_to_end "first session"
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Try exercising the "minimal" language a bit...
standard_testfile .c
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable \
- {debug macros}] != ""} {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug macros}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
# Any command that causes GDB to read the debugging info for the
# lineinc.c compilation unit will do here.
set test_name "tolerate macro info with multiple #inclusions per line"
remote_file host delete $srcfile
# Now start GDB, run to main and try to list the source.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {![runto_main]} {
return 0
}
proc test_list_invalid_args {} {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "list -INVALID" \
"invalid explicit location argument, \"-INVALID\"" \
"first use of \"list -INVALID\""
"invalid explicit location argument, \"-INVALID\"" \
"second use of \"list -INVALID\""
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
"first use of \"list +INVALID\""
gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
proc test_list {command listsize1 listsize2 linerange1 linerange2} {
with_test_prefix "$command after stop: $listsize1, $listsize2" {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
}
standard_testfile int-type.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
-
#
# set it up at a breakpoint so we can play with the variable values
#
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug nowarnings]] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } {
+ return
}
-# use this to debug:
-#log_user 1
-
-clean_restart
-gdb_load $binfile
-
if {![runto known_types]} {
return
}
}
proc do_test { with_probes } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if { !$with_probes } {
gdb_test "maint ignore-probes libc ^longjmp$"
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Ask GDB to show the current definition of MACRO, and return a list
inline_func_a inline_func_b] \
"maint info blocks using stored \$pc, inferior still running"
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Use the recorded $pc value to check inline frames when the inferior
# is not executing.
foreach cmd {"per-command" "per-command time"} {
with_test_prefix $cmd {
# GDB only warns once, so restart between commands.
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test "mt set $cmd on" "$maybe_per_command_warning"
gdb_test "mt set $cmd off" "command started"
gdb_test_no_output "mt set $cmd on" \
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ [list debug ${additional_flags} nowarnings]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
-
#
# set it up at a breakpoint so we can play with the variable values
#
lappend flags debug
lappend_include_file flags $srcdir/lib/unbuffer_output.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } {
+ return
}
-# Start with a fresh gdb
-
-clean_restart
-gdb_load $binfile
-
-global gdb_prompt
-
# This is a test of gdb's ability to follow the parent, child or both
# parent and child of multiple Unix fork() system calls.
# parent's branch.
foreach mode { "child" "parent" } {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
runto_main
gdb_test_no_output "set follow-fork $mode"
# Start with a fresh gdb
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
runto_main
gdb_breakpoint $exit_bp_loc
lappend exec_opts additional_flags=-qstatsym
}
-if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
}
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
-
# Run to FUNC and unload symbols from system shared libraries, to
# avoid conflicts with the minsyms in the program. E.g.,
# intl/plural-exp.h has 'enum expression_operator {..., mult, ...}'.
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
set eol "\r\n"
set sp "\[ \t\]*"
-clean_restart
-gdb_load $binfile
-
gdb_test "ptype struct not_empty" \
"type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}"
# OPTS and BINFILE are used by the COMPILE string (defined above)
# when it is evaluated below.
set opts [list debug additional_flags=-nostdlib $pie]
- set binfile [standard_output_file $testfile-$pie]
+ set filename $testfile-$pie
+ set binfile [standard_output_file $filename]
set board [target_info name]
if {[board_info $board exists mathlib]} {
return -1
}
- clean_restart
- gdb_load $binfile
+ clean_restart $filename
gdb_breakpoint "*marker"
"-vtbl"
}
- global binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
"backtrace no-fil" \
"backtrace no-filters"
- global binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# does not cause a pagination prompt.
proc test_ctrlc_while_target_running_does_not_paginate {} {
- global binfile srcfile
+ global srcfile
global gdb_prompt
set testline [gdb_get_line_number "after sleep"]
with_test_prefix "ctrlc target running" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
# command without getting caught in pagination.
proc test_bg_execution_pagination_return {} {
- global binfile
global decimal
with_test_prefix "paginate" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
# Test paginating while printing about the inferior having exited.
#
proc test_paginate_inferior_exited {} {
- global binfile
global gdb_prompt pagination_prompt
global inferior_exited_re
with_test_prefix "paginate" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
gdb_test "p extern_global = 2" " = 2" "modify value"
gdb_test "p extern_global" " = 2" "value modified"
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test "p extern_global" " = 2" "value modified persisted"
}
# Generate a core file.
with_test_prefix "gcore" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto_main]} {
return
"check we read the frame's PC"
# Restart and load the Python unwinder script.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test_no_output "source ${remote_python_file}" "load python file"
# Tell the Python unwinder to use the frame-id we cached above.
}
proc setup_test {detach_on_fork {follow_fork_mode "parent"}} {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
- }
-
-clean_restart
-gdb_load $binfile
-
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } {
+ return
+}
#
# set it up at a breakpoint so we can play with the variable values
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return 0
}
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_load_shlib ${binfile_lib}
if {![runto lib]} {
# Now test the sharedlibrary command.
proc test_load_shlib { print_symbol_loading } {
- global binfile
global gdb_prompt
with_test_prefix "shlib ${print_symbol_loading}" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
+
if {![runto_main]} {
return -1
}
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# Get things started.
-
-clean_restart
-gdb_load $binfile
-
if {![runto marker1]} {
untested "couldn't run to marker1"
}
set test_spawn_id ""
if {$appear_how != "attach-nofile"} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
} else {
clean_restart
}
# while gdb is processing the internal software watchtpoint
# single-step. With remote debugging, the ctrl-c reaches GDB first.
with_test_prefix "run" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto_main]} {
return -1
# reaches GDB first. Test that as well.
with_test_prefix "attach" {
if {[can_spawn_for_attach]} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
# INPUTRC gets reset for the next testfile.
setenv INPUTRC $inputrc
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if { ![readline_is_used] } {
unsupported "completion doesn't work when readline isn't used."
# arrived. If it is then GDB will start displaying extra blank lines
# after each line of input.
proc run_test {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
gdb_breakpoint main
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# Get things started.
-
-clean_restart
-gdb_load $binfile
-
runto_main
# pause () -> SIGALRM -> handler () -> abort ()
# Get the size of random_data table (defaults to 48K).
set sizeof_random_data [get_sizeof "random_data" 48*1024]
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
#
# Part THREE: Check the upload behavior.
gdb_rename_execfile ${binfile1} ${binfile}
# Restart GDB entirely.
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
# Set a breakpoint on foo and run to it.
gdb_test "break foo" \
set timeout $prev_timeout
# Test PR cli/23785
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if { ![runto_main] } {
return -1
}
# Start with a fresh gdb.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set timeout 30
return2_tests
standard_testfile
-set binfile_threads ${binfile}-threads
-set binfile_nothreads ${binfile}-nothreads
+set testfile_threads ${testfile}-threads
+set testfile_nothreads ${testfile}-nothreads
unset binfile
+unset testfile
# Valid parameter / axis values:
#
set ::GDBFLAGS "$::GDBFLAGS -ex \"maint set target-non-stop on\""
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
if { ![runto_main] } {
gdb_run_cmd
gdb_test "" "Breakpoint $::decimal, .*main.*" "hit main breakpoint after re-run"
} elseif { ${run-or-attach} == "attach" } {
- set test_spawn_id [spawn_wait_for_attach $::binfile]
+ set binfile [standard_output_file $::testfile]
+ set test_spawn_id [spawn_wait_for_attach $binfile]
set test_pid [spawn_id_get_pid $test_spawn_id]
gdb_test_multiple "attach $test_pid" "attach to process" {
set options [list debug additional_flags=-DWITH_THREADS=$threaded \
additional_flags=-std=gnu99]
if { $threaded } {
- set binfile $binfile_threads
+ set testfile $testfile_threads
lappend options pthreads
} else {
- set binfile $binfile_nothreads
+ set testfile $testfile_nothreads
}
- if { [build_executable "failed to prepare" ${binfile} ${srcfile} $options] } {
+ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } {
continue
}
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
# Ensure we are at least after the getpid call, should we need it.
proc_with_prefix test {} {
global gdb_prompt binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set confirm off"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# get things started
-clean_restart
-gdb_load $binfile
-
# Advance to main
if {![runto_main]} {
return 0
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
- untested "failed to compile"
- return -1
-}
-
set location [gdb_get_line_number "say_hello" "sep-proc.c"]
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } {
+ return
+}
# Try to display the source code inside a file which is included by
# another source file. The purpose of this test is to verify that
# 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.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set test "breakpoint inside included file"
gdb_test_multiple "break sep-proc.c:$location" "$test" {
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
set command "info sym main"
set command_regex [string_to_regexp $command]
}
test_cd_into_dir
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
test_tilde_expansion
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
test_cwd_reset
}
proc test_set_inferior_tty { command } {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "$command hello" "set inferior-tty to hello"
gdb_test "show inferior-tty" \
proc_with_prefix test_setshow_annotate {} {
# Start with a fresh gdb
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
}
proc_with_prefix test_setshow_args {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# string settings tests.
proc test-string {variant} {
global gdb_prompt
- global srcfile binfile
+ global srcfile
# Load symbols for the completion test below.
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# Use these variables to make sure we don't call the wrong command
# by mistake.
# VAR_NAME_MATCH. If empty, defaults, to $var_value.
proc do_test { var_value { var_name "" } { var_name_match "" } { var_value_match "" } } {
- global binfile test_var_name
+ global test_var_name
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { $var_name == "" } {
set var_name $test_var_name
# fashions.
proc test_set_unset_vars { } {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
with_test_prefix "set 3 environment variables" {
# Set some environment variables
# Test that unsetting works.
proc test_unset { } {
- global hex decimal binfile gdb_prompt
+ global hex decimal gdb_prompt
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
do_prepare_inferior
}
with_test_prefix "set-then-unset" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# Test if setting and then unsetting $HOME works.
gdb_test_no_output "set environment HOME = test" "set HOME as test"
set lib1 [standard_output_file shr1.sl]
set lib2 [standard_output_file shr2.sl]
-set lib_opts "debug"
+set lib_opts {debug shlib}
set exec_opts {}
lappend exec_opts debug
lappend exec_opts shlib=$lib2
lappend_include_file exec_opts $srcdir/lib/unbuffer_output.c
-if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != ""
- || [gdb_compile_shlib ${lib2src} ${lib2} $lib_opts] != ""
- || [gdb_compile ${srcfile} ${binfile} executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib 1" $lib1 $lib1src $lib_opts] != 0 } {
+ return
}
-# Start with a fresh gdb.
+if { [build_executable "build shlib 2" $lib2 $lib2src $lib_opts] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
+}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib1
gdb_load_shlib $lib2
# Start with a fresh gdb.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# PR's 16495, 18213
# test that we can re-set breakpoints in shared libraries
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# Check that GDB disables dprintf breakpoints within a shared library
# when the shared library is unloaded.
proc_with_prefix test_dprintf_after_unload {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# inferior. We should not get an error about re-setting the dprintf
# breakpoint.
proc_with_prefix test_dprintf_with_rerun {} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
}
foreach_with_prefix type { breakpoint dprintf } {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
set lib1_sl [standard_output_file shreloc1.sl]
set lib2_sl [standard_output_file shreloc2.sl]
-set lib_opts "debug"
+set lib_opts {debug shlib}
set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl]
if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {
}
-if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} {
- untested "could not build $lib1_sl."
- return -1
-} elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} {
- untested "could not build $lib1_s2."
- return -1
-} elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
- untested "could not build $binfile."
- return -1
+if { [build_executable "build shlib 1" $lib1_sl $lib1src $lib_opts] != 0} {
+ return
}
-# Start with a fresh gdb.
+if { [build_executable "build shlib " $lib2_sl $lib2src $lib_opts] != 0} {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0} {
+ return
+}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib1_sl
gdb_load_shlib $lib2_sl
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# get things started
-clean_restart
-gdb_load $binfile
-
# Pass all the alarms straight through (but verbosely)
gdb_test "handle SIGALRM print pass nostop"
gdb_test "handle SIGVTALRM print pass nostop"
standard_testfile .c
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
runto_main
gdb_test "b [gdb_get_line_number "good, not blocked"]" \
# Test siginfo preservation in core files.
if {$gcore_created} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
standard_testfile .c
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \
- "${binfile}" executable {debug}] != "" } {
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
# Advance to main
if {![runto_main]} {
return 0
# Test siginfo preservation in core files.
if {$gcore_created} {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
# Now run the program through gdb, and dump its initial signal actions
# and mask in "gdb.txt".
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
}
test_handle_all_print
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {[runto_main]} {
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
#
# Run to `main' where we begin our tests.
#
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
}
-# get things started
-clean_restart
-gdb_load $binfile
-
# Advance to main
if {![runto_main]} {
return 0
# Restart GDB, set a display showing $PC, and run to main.
proc restart {} {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test "display/i \$pc"
}
with_test_prefix "skip delete completion" {
- global binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
+
if {![runto_main]} {
return
}
set libsrc $srcdir/$subdir/$libfile.c
set lib_sl [standard_output_file $libfile.sl]
-set lib_opts debug
+set lib_opts {debug shlib}
set exec_opts [list debug shlib=$lib_sl]
-if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
- || [gdb_compile $srcdir/$subdir/$srcfile $binfile \
- executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } {
+ return
}
-# Start with a fresh gdb
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
+}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib_sl
# This program implicitly loads SOM shared libraries.
set binfile_lib [standard_output_file ${libname}.so]
# Note: no debugging info here, since this will assure that the solib
# name is printed in the stack trace.
-set lib_flags {}
+set lib_flags {shlib}
# Binary file.
set testfile "solib-abort"
set binfile [standard_output_file ${testfile}]
set bin_flags [list debug shlib=${binfile_lib}]
-if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
- || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
- untested "failed to compile"
- return -1
+if { [build_executable "build solib" $binfile_lib $srcfile_lib \
+ $lib_flags] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } {
+ return
+}
if {![runto_main]} {
return 0
set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"]
-if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
- || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
- return -1
+if { [build_executable "build solib" $libobj $libsrc {debug shlib}] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $execsrc $exec_opts] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $libobj
if {![runto_main]} {
set libname "solib-symbol-lib"
set srcfile_lib ${srcdir}/${subdir}/${libname}.c
set binfile_lib [standard_output_file ${libname}.so]
-set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
+set lib_flags [list debug shlib ldflags=-Wl,-Bsymbolic]
# Binary file.
set testfile "solib-symbol-main"
set srcfile ${srcdir}/${subdir}/${testfile}.c
set binfile [standard_output_file ${testfile}]
set bin_flags [list debug shlib=${binfile_lib}]
-if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
- || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
- untested "failed to compile"
- return -1
+if { [build_executable "build solib" $binfile_lib $srcfile_lib \
+ $lib_flags] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $binfile_lib
# Set a breakpoint in the binary.
}
with_test_prefix $testopts {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
gdb_load_shlib $lib1
gdb_load_shlib $lib2
}
}
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if { [ishost *-*-mingw*] } {
gdb_test_no_output "set directories \$cdir;\$cwd"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug additional_flags=-fstack-check nowarnings]] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile \
+ [list debug additional_flags=-fstack-check nowarnings]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return 0
}
# Initial setup for simple test (wildcard expansion, variable substitution).
proc initial_setup_simple { startup_with_shell run_args } {
- global hex decimal binfile unique_file
+ global hex decimal unique_file
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_test_no_output "set startup-with-shell $startup_with_shell"
gdb_test_no_output "set print characters unlimited"
proc test_step_over { displaced } {
global hex
- global binfile
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return -1
set linenum_for_step_resume [gdb_get_line_number "break for step-resume test here"]
proc test {non_stop displaced always_inserted} {
- global binfile
global linenum_for_user_bp
global linenum_for_step_resume
global GDBFLAGS
save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS -ex \"set non-stop $non_stop\""
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
}
gdb_test_no_output "set displaced-stepping $displaced"
standard_testfile .c
remote_exec build "rm -f ${binfile}"
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return -1
-}
-clean_restart
-gdb_load $binfile
+if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } {
+ return
+}
if {![runto_main]} {
return 0
# prompt, the previous line disables styling as expected.
proc test_pagination_prompt_styling {} {
with_ansi_styling_terminal {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
# default style once the logging file has finished.
proc test_pagination_continue_styling_1 { length } {
with_ansi_styling_terminal {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
set filename [string repeat "ax" $length]
# Check to see if the Python styling of disassembler output is
# expected or not, this styling requires Python support in GDB, and
# the Python pygments module to be available.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
if {[allow_python_tests] && [gdb_py_module_available "pygments"]} {
set python_disassembly_styling true
} else {
proc do_test { remove_expr } {
global lib_basename lib_syms srcfile srcfile3
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
set lib1src $srcdir/$subdir/$srcfile3
set lib1 [standard_output_file symtab-search-order-1.sl]
-set lib_opts "debug"
+set lib_opts {debug shlib}
set exec_opts [list debug shlib=$lib1]
-if { [gdb_compile_shlib $lib1src $lib1 $lib_opts] != ""
- || [gdb_compile [list $srcfile $srcfile2] $binfile executable \
- $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib" $lib1 $lib1src $lib_opts] != 0 } {
+ return
}
-# Start with a fresh gdb.
+if { [prepare_for_testing "prepare" $testfile [list $srcfile $srcfile2] \
+ $exec_opts] != 0 } {
+ return
+}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib1
if {![runto_main]} {
# starting with TEST_GDB.
proc_with_prefix test_set_unset_env {} {
- global binfile
-
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
# First test with no TEST_GDB_VAR.
with_test_prefix "test1" {
}
proc_with_prefix test_inherit_env_var {} {
- global binfile
global bp_line
global env
save_vars {env(TEST_GDB_GLOBAL)} {
set env(TEST_GDB_GLOBAL) "Global environment value"
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
gdb_breakpoint $bp_line
}
proc do_tests {force_internal_tls} {
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
}
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
set lib3obj [standard_output_file "${testfile}3-lib.so"]
proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
- clean_restart
- gdb_load $::binfile
+ set filename [file tail $::binfile]
+
+ clean_restart $filename
+
if {![runto_main]} {
return
}
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $filename
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
standard_testfile
proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
- clean_restart
- gdb_load $::binfile
+ set filename [file tail $::binfile]
+
+ clean_restart $filename
+
if {![runto_main]} {
return
}
}
with_test_prefix "stripped" {
- set binfile_stripped "${::binfile}.stripped"
+ set filename_stripped "${filename}.stripped"
+ set binfile_stripped [standard_output_file $filename_stripped]
set objcopy [gdb_find_objcopy]
set cmd "$objcopy --strip-debug ${::binfile} $binfile_stripped"
if {![catch {exec {*}$cmd} cmd_output]} {
- clean_restart
- gdb_load $binfile_stripped
+ clean_restart $filename_stripped
if {![runto_main]} {
return
}
return
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $filename
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
gdb_remote_download host ${srcdir}/${subdir}/twice.c
-if { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $local_srcfile $options] != 0 } {
+ return
}
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
-
if {[runto_main]} {
# Test that GDB can still detect whether we have line numbers
# even if we're executing code in an include file.
remote_exec build "rm -f ${binfile}"
-if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
- || [gdb_compile $execsrc ${binfile} executable \
- [list debug shlib=${libobj}]] != "" } {
- return -1
+if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $execsrc \
+ [list debug shlib=${libobj}]] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib ${libobj}
if {![runto_main]} {
set lib_syms [shlib_symbol_file ${libname}]
set lib_syms2 [shlib_symbol_file ${libname2}]
-set lib_opts debug
+set lib_opts {debug shlib}
set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"]
-if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
- || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
- || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib 1" $lib_sl $libsrc $lib_opts] != 0 } {
+ return
+}
+
+if { [build_executable "build shlib 2" $lib_sl2 $libsrc2 $lib_opts] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib_sl
gdb_load_shlib $lib_sl2
lappend flags "additional_flags=-DTEST_COMPLEX"
}
-# build the first test case
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
- executable $flags] != "" } {
- untested "failed to compile"
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } {
+ return
}
-# Start with a fresh gdb.
-
-clean_restart
-gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
standard_testfile .c
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- return -1
+if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
-
if {![runto_main]} {
return
}
# A clean restart is needed to force the hardware watchpoint setup
# logic to run post attach rather than post inferior launch.
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach twice"
# default.
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
}
- clean_restart
- gdb_load $::binfile
+ clean_restart $::testfile
}
gdb_test_no_output "set can-use-hw-watchpoints $hw"
set lib_dlopen [shlib_target_file ${libname}]
set lib_syms [shlib_symbol_file ${libname}]
-set lib_opts debug
+set lib_opts {debug shlib}
set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"]
-if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
- || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
- untested "failed to compile"
- return -1
+if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } {
+ return
+}
+
+if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } {
+ return
}
-clean_restart
-gdb_load $binfile
gdb_load_shlib $lib_sl
runto_main
delete_breakpoints
proc test {always_inserted} {
- global srcfile binfile
+ global srcfile
with_test_prefix "always-inserted $always_inserted" {
- clean_restart
- gdb_load $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return
# This will turn hardware watchpoints back on and delete the watchpoint
# we just created.
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
# Disable hardware watchpoints if necessary.
if {!$allow_hw_watchpoint_tests_p} {
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
gdb_test "with language ada -- print g_s" \
" = \\(a => 1, b => 2, c => 3\\)"
return -1
}
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
# Test "maint with". VALUES is a list of values. A nested "with" is
# performed with each combination of pair of values from this list.
# Check repeating.
with_test_prefix "repeat" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
# "with" with no command reinvokes the previous command.
# Basic run control.
with_test_prefix "run control" {
- clean_restart
- gdb_load $binfile
+ clean_restart $testfile
if {![runto_main]} {
return