This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?)


H.J. Lu wrote:

> Very good point. There are some arch specific tests which are either
> 32bit or 64bit. Currently, we check target. It doesn't work -m32. We
> need something like
> 
> /* { dg-require-effective-target lp64 } */
> /* { dg-require-effective-target ilp32 } */

Right; I noticed this problem with one ppc64 test case as well.

I've tried to add testsuite predicates skip_ilp32_tests and skip_lp64_tests
modeled along the lines of the above GCC effective-target flags, and this
helps with this ppc64 test case.

Could you try whether you can use this to fix the i386/x86_64 tests?

I'd appreciate any comments on the approach below!

Bye,
Ulrich


ChangeLog:

	* lib/gdb.exp (skip_ilp32_tests): New procedure.
	(skip_lp64_tests): New procedure.
	* gdb.arch/ppc64-atomic-inst.exp: Use skip_lp64_tests to execute test
	only when building 64-bit executables.  Do not hard-code -m64 option.

Index: gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp,v
retrieving revision 1.5
diff -u -p -r1.5 ppc64-atomic-inst.exp
--- gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp	5 May 2010 18:06:57 -0000	1.5
+++ gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp	9 Jul 2010 15:40:41 -0000
@@ -25,7 +25,7 @@ if $tracelevel {
 # instruction.
 
 
-if ![istarget "powerpc64-*"] then {
+if {![istarget "powerpc*"] || [skip_lp64_tests]} {
     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: gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.152
diff -u -p -r1.152 gdb.exp
--- gdb/testsuite/lib/gdb.exp	28 Jun 2010 20:09:59 -0000	1.152
+++ gdb/testsuite/lib/gdb.exp	9 Jul 2010 15:40:42 -0000
@@ -1401,6 +1401,83 @@ proc skip_shlib_tests {} {
     return 1
 }
 
+# Return 1 if we should skip tests that assume the ILP32 model.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+proc skip_ilp32_tests {} {
+    global skip_ilp32_tests_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 "skip_ilp32_tests"
+    set board [target_info name]
+    if [info exists skip_ilp32_tests_saved($board)] {
+        verbose "$me:  returning saved $skip_ilp32_tests_saved($board)" 2
+        return $skip_ilp32_tests_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 1" 2
+        return [set skip_ilp32_tests_saved($board) 1]
+    }
+
+    verbose "$me:  returning 0" 2
+    return [set skip_ilp32_tests_saved($board) 0]
+}
+
+# Return 1 if we should skip tests that assume the LP64 model.
+# This cannot be decided simply from looking at the target string,
+# as it might depend on externally passed compiler options like -m64.
+proc skip_lp64_tests {} {
+    global skip_lp64_tests_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 "skip_lp64_tests"
+    set board [target_info name]
+    if [info exists skip_lp64_tests_saved($board)] {
+        verbose "$me:  returning saved $skip_lp64_tests_saved($board)" 2
+        return $skip_lp64_tests_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 1" 2
+        return [set skip_lp64_tests_saved($board) 1]
+    }
+
+    verbose "$me:  returning 0" 2
+    return [set skip_lp64_tests_saved($board) 0]
+}
+
 # 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.
 


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]