]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add is_ilp32_target/is_lp64_target.
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 12 Jul 2010 17:33:15 +0000 (17:33 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 12 Jul 2010 17:33:15 +0000 (17:33 +0000)
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.

19 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/amd64-byte.exp
gdb/testsuite/gdb.arch/amd64-disp-step.exp
gdb/testsuite/gdb.arch/amd64-dword.exp
gdb/testsuite/gdb.arch/amd64-i386-address.exp
gdb/testsuite/gdb.arch/amd64-word.exp
gdb/testsuite/gdb.arch/i386-avx.exp
gdb/testsuite/gdb.arch/i386-bp_permanent.exp
gdb/testsuite/gdb.arch/i386-byte.exp
gdb/testsuite/gdb.arch/i386-disp-step.exp
gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
gdb/testsuite/gdb.arch/i386-prologue.exp
gdb/testsuite/gdb.arch/i386-size-overlap.exp
gdb/testsuite/gdb.arch/i386-size.exp
gdb/testsuite/gdb.arch/i386-sse.exp
gdb/testsuite/gdb.arch/i386-unwind.exp
gdb/testsuite/gdb.arch/i386-word.exp
gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
gdb/testsuite/lib/gdb.exp

index 5d29407f75b61b5a0284125491a8a8d89538555e..803e74dd5140a3587230d88abe89ed65a5bc473a 100644 (file)
@@ -1,3 +1,33 @@
+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.
+
 2010-07-07  Doug Evans  <dje@google.com>
 
        * lib/gdb.exp (gdb_test_list_exact): New function.
index 53d1c5498a95c50054643a81e6a8930499293e95..09b70532ea446d6808e8fce7e7d459a3060c5a32 100644 (file)
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 byte register tests."
     return
 }
index d77f02415dd6d0237b648ffa6b73447d85a5c4ce..f25093f1b283a3c70181d1568dcbfcf1cd54ef11 100644 (file)
@@ -22,7 +22,7 @@ if $tracelevel {
 }
 
 
-if ![istarget "x86_64-*-linux*"] then {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping x86_64 displaced stepping tests."
     return
 }
index 4d0a6b768915c4cbbbf68b8ef2ba81a41a6f4c35..3719b5839d87f1bf9d7a47befffdf0912f85fb29 100644 (file)
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 dword register tests."
     return
 }
index e98c254c4047941b36a68c28972034a6bdec23fa..829d9a2be1f87d4440f93e5c2ebf9846b6d843fb 100644 (file)
@@ -18,7 +18,7 @@
 # Test UNsigned extension of the 32-bit inferior address on a 64-bit host.
 # On native 32-bit host the test always PASSed.
 
-if {![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]} then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_lp64_target] } then {
     verbose "Skipping amd64->i386 adress test."
     return
 }
index 04448d7f7545917ced1ceb444e3ab854f507b12c..031f153b2e05463db222fe517796781ffb7b3d1f 100644 (file)
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 word register tests."
     return
 }
index 426e9d32fe45d435a016701b3ccbf986c99b94e6..7bf748ff10f9e605ed4b6dcd169a9f2f935a40ef 100644 (file)
@@ -77,7 +77,7 @@ gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
          "set first breakpoint in main"
 gdb_continue_to_breakpoint "continue to first breakpoint in main"
 
-if [istarget i?86-*-*] {
+if [is_ilp32_target] {
     set nr_regs 8
 } else {
     set nr_regs 16
index a8eb669bf3640e85a7811d06e0c1c5a22a8a4e45..a312db1fd3364096dbf01a24429582aef4ef4cf2 100644 (file)
@@ -22,7 +22,7 @@ if $tracelevel {
 
 # Test stepping over permanent breakpoints on i386.
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping skip over permanent breakpoint on i386 tests."
     return
 }
index d4dd5a504ae7ea31987f3f87b257d64e201b7e48..4a17ed085aad7c0efa4c65952bbde1c2d882bfd1 100644 (file)
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget i?86-*-*] } {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 byte register tests."
     return
 }
index 41f39cfb457569983c021667b001f774ac4c7998..298973c18ecfb181554a6053f28ff2f4ad85757e 100644 (file)
@@ -22,7 +22,7 @@ if $tracelevel {
 }
 
 
-if ![istarget "i?86-*-linux*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping x86 displaced stepping tests."
     return
 }
index fac9e11ffc3bffca4f0395cf77f500b3df54313b..4ad49028de096a32e25244dd5c65015601700a76 100644 (file)
@@ -27,7 +27,7 @@ if $tracelevel {
 # Test i386 unwinder.
 
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 unwinder tests."
     return
 }
index be4b2631a02603116aad5889cb539658172843b2..6b7b51dddc9d045f3e6ca60e0b4089e6b8e17d59 100644 (file)
@@ -26,7 +26,7 @@ if $tracelevel {
 # Test i386 prologue analyzer.
 
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 prologue tests."
     return
 }
index bb78c7a2f94300132d9b00278054a1fb5ce5e8ae..2f22422e6e6e513f3117a95e2c81fbd5c4a5fd7b 100644 (file)
@@ -21,7 +21,7 @@ if $tracelevel {
 
 # Test that GDB can handle overlapping sizes of symbols.
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 unwinder tests."
     return
 }
index e4d4ad3deec56b7c047995876ec281f3287c0f1d..6e397f9388ee92a375c9d56ca1e9b11ec5c45add 100644 (file)
@@ -24,7 +24,7 @@ if $tracelevel {
 
 # Test that GDB can see the sizes of symbols.
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 unwinder tests."
     return
 }
index 72a8fb2181bf86c7cd24f30ca13c77bc2d91eac8..cb3af4f4adf343c4832d8137d11eccf4dc94c3e7 100644 (file)
@@ -77,7 +77,7 @@ gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
          "set first breakpoint in main"
 gdb_continue_to_breakpoint "continue to first breakpoint in main"
 
-if [istarget i?86-*-*] {
+if [is_ilp32_target] {
     set nr_regs 8
 } else {
     set nr_regs 16
index ac966835b9a2b2b0ab72ad97295bd3808d2dc430..1c13089d51abdbdb0ea5f34cbac5e90d7252c98c 100644 (file)
@@ -25,7 +25,7 @@ if $tracelevel {
 # Test i386 unwinder.
 
 
-if ![istarget "i?86-*-*"] then {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 unwinder tests."
     return
 }
index a178fed25bc10509afaddc358bd761d66fe9c71e..827d10181ae6817eaa7e4d8078d2e1fa79ad4954 100644 (file)
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget i?86-*-*] } {
+if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
     verbose "Skipping i386 word register tests."
     return
 }
index c31c280c30958907f160f75bb7c93994b1fcd719..8ae23178f3c72a263b91c10507b5ba4d7103c6e0 100644 (file)
@@ -25,7 +25,7 @@ if $tracelevel {
 # instruction.
 
 
-if ![istarget "powerpc64-*"] then {
+if {![istarget "powerpc*"] || ![is_lp64_target]} {
     verbose "Skipping testing of powerpc64 single stepping over atomic sequences."
     return
 }
@@ -33,9 +33,9 @@ if ![istarget "powerpc64-*"] then {
 set testfile "ppc64-atomic-inst"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
-set compile_flags "debug quiet"
+set compile_flags {debug quiet}
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat $compile_flags additional_flags=-m64]] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
     unsupported "Testcase compile failed."
     return -1
 }
index b5b33628f9be9f3b569f9060d8e7f2bef017d94d..032c1c6d4fbab98e78413db202adf49f5aed31c2 100644 (file)
@@ -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.