aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-07-12 17:33:15 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-07-12 17:33:15 +0000
commitadd265ae415ecd40208537d1f84155f868668ef5 (patch)
tree5a6c5c581d651b42b9416e2c2eaf149b80bb7ffd /gdb/testsuite/lib
parent953ac07ed78d7fa016fe4ef551afc513700aa393 (diff)
downloadgdb-add265ae415ecd40208537d1f84155f868668ef5.zip
gdb-add265ae415ecd40208537d1f84155f868668ef5.tar.gz
gdb-add265ae415ecd40208537d1f84155f868668ef5.tar.bz2
Add is_ilp32_target/is_lp64_target.
2010-07-12 Ulrich Weigand <uweigand@de.ibm.com> H.J. Lu <hongjiu.lu@intel.com> * lib/gdb.exp (is_ilp32_target): New. (is_lp64_target): Likewise. * gdb.arch/amd64-byte.exp: Use is_lp64_target to check 64bit target. * gdb.arch/amd64-disp-step.exp: Likewise. * gdb.arch/amd64-dword.exp: Likewise. * gdb.arch/amd64-i386-address.exp: Likewise. * gdb.arch/amd64-word.exp: Likewise. * gdb.arch/i386-avx.exp: Use is_ilp32_target to check for 32bit target. * gdb.arch/i386-bp_permanent.exp: Likewise. * gdb.arch/i386-byte.exp: Likewise. * gdb.arch/i386-disp-step.exp: Likewise. * gdb.arch/i386-gnu-cfi.exp: Likewise. * gdb.arch/i386-prologue.exp: Likewise. * gdb.arch/i386-size-overlap.exp: Likewise. * gdb.arch/i386-size.exp: Likewise. * gdb.arch/i386-sse.exp: Likewise. * gdb.arch/i386-unwind.exp: Likewise. * gdb.arch/i386-word.exp: Likewise. * gdb.arch/ppc64-atomic-inst.exp: Use is_lp64_target to execute test only when building 64-bit executables. Do not hard-code -m64 option.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp77
1 files changed, 77 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b5b3362..032c1c6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1454,6 +1454,83 @@ proc skip_shlib_tests {} {
return 1
}
+# Return 1 if target is ILP32.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+proc is_ilp32_target {} {
+ global is_ilp32_target_saved
+
+ # Use the cached value, if it exists. Cache value per "board" to handle
+ # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+ set me "is_ilp32_target"
+ set board [target_info name]
+ if [info exists is_ilp32_target_saved($board)] {
+ verbose "$me: returning saved $is_ilp32_target_saved($board)" 2
+ return $is_ilp32_target_saved($board)
+ }
+
+
+ set src ilp32[pid].c
+ set obj ilp32[pid].o
+
+ set f [open $src "w"]
+ puts $f "int dummy\[sizeof (int) == 4"
+ puts $f " && sizeof (void *) == 4"
+ puts $f " && sizeof (long) == 4 ? 1 : -1\];"
+ close $f
+
+ verbose "$me: compiling testfile $src" 2
+ set lines [gdb_compile $src $obj object {quiet}]
+ file delete $src
+ file delete $obj
+
+ if ![string match "" $lines] then {
+ verbose "$me: testfile compilation failed, returning 0" 2
+ return [set is_ilp32_target_saved($board) 0]
+ }
+
+ verbose "$me: returning 1" 2
+ return [set is_ilp32_target_saved($board) 1]
+}
+
+# Return 1 if target is LP64.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+proc is_lp64_target {} {
+ global is_lp64_target_saved
+
+ # Use the cached value, if it exists. Cache value per "board" to handle
+ # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+ set me "is_lp64_target"
+ set board [target_info name]
+ if [info exists is_lp64_target_saved($board)] {
+ verbose "$me: returning saved $is_lp64_target_saved($board)" 2
+ return $is_lp64_target_saved($board)
+ }
+
+ set src lp64[pid].c
+ set obj lp64[pid].o
+
+ set f [open $src "w"]
+ puts $f "int dummy\[sizeof (int) == 4"
+ puts $f " && sizeof (void *) == 8"
+ puts $f " && sizeof (long) == 8 ? 1 : -1\];"
+ close $f
+
+ verbose "$me: compiling testfile $src" 2
+ set lines [gdb_compile $src $obj object {quiet}]
+ file delete $src
+ file delete $obj
+
+ if ![string match "" $lines] then {
+ verbose "$me: testfile compilation failed, returning 0" 2
+ return [set is_lp64_target_saved($board) 0]
+ }
+
+ verbose "$me: returning 1" 2
+ return [set is_lp64_target_saved($board) 1]
+}
+
# Run a test on the target to see if it supports vmx hardware. Return 0 if so,
# 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.