-# Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# Copyright (C) 2003-2019 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
return 0
}
-if $tracelevel then {
- strace $tracelevel
-}
-
#
# This file uses shreloc.c, shreloc1.c and shreloc2.c
#
-set workdir ${objdir}/${subdir}
-set testfile "shreloc"
-set libfile1 "shreloc1"
-set libfile2 "shreloc2"
-set srcfile $srcdir/$subdir/$testfile.c
-set lib1src $srcdir/$subdir/$libfile1.c
-set lib2src $srcdir/$subdir/$libfile2.c
-set binfile $objdir/$subdir/$testfile
-set lib1_sl $objdir/$subdir/$libfile1.sl
-set lib2_sl $objdir/$subdir/$libfile2.sl
+standard_testfile .c shreloc1.c shreloc2.c
+
+set srcfile $srcdir/$subdir/$srcfile
+set lib1src $srcdir/$subdir/$srcfile2
+set lib2src $srcdir/$subdir/$srcfile3
+set binfile [standard_output_file $testfile]
+set lib1_sl [standard_output_file shreloc1.sl]
+set lib2_sl [standard_output_file shreloc2.sl]
-if [get_compiler_info ${binfile}] {
+if [get_compiler_info] {
return -1
}
}
if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} {
- untested "Could not build $lib1_sl."
+ untested "could not build $lib1_sl."
return -1
} elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} {
- untested "Could not build $lib1_s2."
+ untested "could not build $lib1_s2."
return -1
} elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
- untested "Could not build $binfile."
+ untested "could not build $binfile."
return -1
}
# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${workdir}/shreloc
-gdb_load_shlibs $lib1_sl $lib2_sl
+clean_restart $binfile
+gdb_load_shlib $lib1_sl
+gdb_load_shlib $lib2_sl
# Load up the shared objects
if ![runto_main] then {
- fail "Can't run to main"
+ fail "can't run to main"
return 0
}
-proc get_var_address { var } {
- global gdb_prompt hex
-
- send_gdb "print &${var}\n"
- # Match output like:
- # $1 = (int *) 0x0
- # $5 = (int (*)()) 0
- # $6 = (int (*)()) 0x24 <function_bar>
- gdb_expect {
- -re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
- {
- pass "get address of ${var}"
- if { $expect_out(1,string) == "0" } {
- return "0x0"
- } else {
- return $expect_out(1,string)
- }
- }
- -re "${gdb_prompt} $"
- { fail "get address of ${var} (unknown output)" }
- timeout
- { fail "get address of ${var} (timeout)" }
- }
- return ""
-}
-
#
# Check debugging symbol relocations
#
global gdb_prompt
- send_gdb "${command}\n"
-
# Discard output
- gdb_expect {
+ gdb_test_multiple "${command}" "${command}" {
-re ".*\[\r\n]+${gdb_prompt} $" {
return 1
}
return 1
}
-set msymfile "${workdir}/shreloc.txt"
+if [is_remote host] {
+ set msymfile shreloc.txt
+} else {
+ set msymfile [standard_output_file shreloc.txt]
+}
if [send_gdb_discard "maint print msymbols ${msymfile}"] {
if {[check_different "static_var_\[12\]" "${msymfile}"]} {
# A better approach would be include absolute symbols via the assembler.
#
if {[check_same "_minor_os_version__" "${msymfile}"]} {
- pass "Absolute symbols not relocated"
+ pass "absolute symbols not relocated"
} else {
- fail "Absolute symbols not relocated"
+ fail "absolute symbols not relocated"
}
}