public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Re: support biarch gcore?
       [not found] <201007062128.o66LSkNC032580@glazunov.sibelius.xs4all.nl>
@ 2010-07-07 12:30 ` Ulrich Weigand
  2010-07-08  2:35   ` Jon Zhou
  2010-07-08  4:47   ` H.J. Lu
  0 siblings, 2 replies; 13+ messages in thread
From: Ulrich Weigand @ 2010-07-07 12:30 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: jan.kratochvil, Jon.Zhou, gdb, gdb-patches

Mark Kettenis wrote:
> > Date: Tue, 6 Jul 2010 22:48:44 +0200 (CEST)
> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
> > 
> > Unfortunately, it also turned out that the section sizes provided for
> > .reg in those targets that have gdbarch_core_regset_sections, while
> > currently unused, were also nearly all wrong ...
> > 
> > The following patch fixes those sizes, and changes linux-nat.c to
> > use them.

> Although I don't feel qualified to judge the powerpc bits, this makes
> quite a bit of sense to me.  And yes, the value for amd64-linux is
> obviously wrong.

OK, thanks!

I've checked the patch in now.

Bye,
Ulrich

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: support biarch gcore?
  2010-07-07 12:30 ` support biarch gcore? Ulrich Weigand
@ 2010-07-08  2:35   ` Jon Zhou
  2010-07-08 11:17     ` Ulrich Weigand
  2010-07-08  4:47   ` H.J. Lu
  1 sibling, 1 reply; 13+ messages in thread
From: Jon Zhou @ 2010-07-08  2:35 UTC (permalink / raw)
  To: Ulrich Weigand, Mark Kettenis; +Cc: jan.kratochvil, gdb, gdb-patches

One more question

The patch is enable gdb to read the coredump generated by gcore
Or enable gcore to generate a readable coredump
Or both?

Thanks
jon

-----Original Message-----
From: Ulrich Weigand [mailto:uweigand@de.ibm.com] 
Sent: Wednesday, July 07, 2010 8:31 PM
To: Mark Kettenis
Cc: jan.kratochvil@redhat.com; Jon Zhou; gdb@sourceware.org; gdb-patches@sourceware.org
Subject: Re: support biarch gcore?

Mark Kettenis wrote:
> > Date: Tue, 6 Jul 2010 22:48:44 +0200 (CEST)
> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
> > 
> > Unfortunately, it also turned out that the section sizes provided for
> > .reg in those targets that have gdbarch_core_regset_sections, while
> > currently unused, were also nearly all wrong ...
> > 
> > The following patch fixes those sizes, and changes linux-nat.c to
> > use them.

> Although I don't feel qualified to judge the powerpc bits, this makes
> quite a bit of sense to me.  And yes, the value for amd64-linux is
> obviously wrong.

OK, thanks!

I've checked the patch in now.

Bye,
Ulrich

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-07 12:30 ` support biarch gcore? Ulrich Weigand
  2010-07-08  2:35   ` Jon Zhou
@ 2010-07-08  4:47   ` H.J. Lu
  2010-07-08  5:05     ` H.J. Lu
  1 sibling, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2010-07-08  4:47 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb, gdb-patches

On Wed, Jul 7, 2010 at 5:30 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> Mark Kettenis wrote:
>> > Date: Tue, 6 Jul 2010 22:48:44 +0200 (CEST)
>> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
>> >
>> > Unfortunately, it also turned out that the section sizes provided for
>> > .reg in those targets that have gdbarch_core_regset_sections, while
>> > currently unused, were also nearly all wrong ...
>> >
>> > The following patch fixes those sizes, and changes linux-nat.c to
>> > use them.
>
>> Although I don't feel qualified to judge the powerpc bits, this makes
>> quite a bit of sense to me.  And yes, the value for amd64-linux is
>> obviously wrong.
>
> OK, thanks!
>
> I've checked the patch in now.
>

Does this fix

http://sourceware.org/bugzilla/show_bug.cgi?id=11467

You can verify it with the testcase in

http://sourceware.org/ml/gdb-patches/2010-04/msg00425.html



-- 
H.J.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-08  4:47   ` H.J. Lu
@ 2010-07-08  5:05     ` H.J. Lu
  2010-07-08 11:15       ` Ulrich Weigand
  0 siblings, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2010-07-08  5:05 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

On Wed, Jul 7, 2010 at 9:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jul 7, 2010 at 5:30 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>> Mark Kettenis wrote:
>>> > Date: Tue, 6 Jul 2010 22:48:44 +0200 (CEST)
>>> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
>>> >
>>> > Unfortunately, it also turned out that the section sizes provided for
>>> > .reg in those targets that have gdbarch_core_regset_sections, while
>>> > currently unused, were also nearly all wrong ...
>>> >
>>> > The following patch fixes those sizes, and changes linux-nat.c to
>>> > use them.
>>
>>> Although I don't feel qualified to judge the powerpc bits, this makes
>>> quite a bit of sense to me.  And yes, the value for amd64-linux is
>>> obviously wrong.
>>
>> OK, thanks!
>>
>> I've checked the patch in now.
>>
>
> Does this fix
>
> http://sourceware.org/bugzilla/show_bug.cgi?id=11467
>

It works.  Here is a patch to add a testcase.  OK to install?

Thanks.


-- 
H.J.
--
2010-07-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR corefiles/11467
	* gdb.arch/amd64-gcore32.exp: New.

[-- Attachment #2: gdb-32bit-8.patch --]
[-- Type: text/x-csrc, Size: 7530 bytes --]

2010-07-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR corefiles/11467
	* gdb.arch/amd64-gcore32.exp: New.

diff --git a/gdb/testsuite/gdb.arch/amd64-gcore32.exp b/gdb/testsuite/gdb.arch/amd64-gcore32.exp
new file mode 100644
index 0000000..66f733d
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-gcore32.exp
@@ -0,0 +1,227 @@
+# Copyright 2010
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+if { ![istarget x86_64-*-linux* ] } {
+    verbose "Skipping amd64-linux 32bit gcore tests."
+    return
+}
+
+set testfile "amd64-gcore32"
+set srcfile  gcore.c
+set binfile  ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
+     untested amd64-gcore32.exp
+     return -1
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Does this gdb support gcore?
+send_gdb "help gcore\n"
+gdb_expect {
+    -re "Undefined command: .gcore.*$gdb_prompt $" {
+	# gcore command not supported -- nothing to test here.
+	unsupported "gdb does not support gcore on this target"
+	return -1;
+    }
+    -re "Save a core file .*$gdb_prompt $" {
+	pass "help gcore"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "help gcore"
+    }
+    timeout {
+	fail "help gcore (timeout)"
+    }
+}
+
+if { ! [ runto_main ] } then {
+    untested amd64-gcore32.exp
+    return -1
+}
+
+proc capture_command_output { command prefix } {
+    global gdb_prompt
+    global expect_out
+
+    set output_string ""
+    gdb_test_multiple "$command" "capture_command_output for $command" {
+	-re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
+	    set output_string $expect_out(1,string)
+	}
+    }
+    return $output_string
+}
+
+gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
+	"set breakpoint at terminal_func"
+
+gdb_test "continue" "Breakpoint .* terminal_func.*" \
+	"continue to terminal_func"
+
+set print_prefix ".\[0123456789\]* = "
+
+set pre_corefile_backtrace [capture_command_output "backtrace" ""]
+set pre_corefile_regs [capture_command_output "info registers" ""]
+set pre_corefile_allregs [capture_command_output "info all-reg" ""]
+set pre_corefile_static_array \
+	[capture_command_output "print static_array" "$print_prefix"]
+set pre_corefile_uninit_array \
+	[capture_command_output "print un_initialized_array" "$print_prefix"]
+set pre_corefile_heap_string \
+	[capture_command_output "print heap_string" "$print_prefix"]
+set pre_corefile_local_array \
+	[capture_command_output "print array_func::local_array" "$print_prefix"]
+set pre_corefile_extern_array \
+	[capture_command_output "print extern_array" "$print_prefix"]
+
+set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
+
+set core_supported 0
+gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
+	"save a corefile" \
+{
+  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
+    pass "save a corefile"
+    global core_supported
+    set core_supported 1
+  }
+  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+    unsupported "save a corefile"
+    global core_supported
+    set core_supported 0
+  }
+}
+
+if {!$core_supported} {
+  return -1
+}
+
+# Now restart gdb and load the corefile.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+send_gdb "core ${objdir}/${subdir}/gcore.test\n"
+gdb_expect {
+    -re ".* is not a core dump:.*$gdb_prompt $" {
+	fail "re-load generated corefile (bad file format)"
+	# No use proceeding from here.
+	return;	
+    }
+    -re ".*: No such file or directory.*$gdb_prompt $" {
+	fail "re-load generated corefile (file not found)"
+	# No use proceeding from here.
+	return;	
+    }
+    -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
+	fail "re-load generated corefile (incomplete note section)"
+    }
+    -re "Core was generated by .*$gdb_prompt $" {
+	pass "re-load generated corefile"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "re-load generated corefile"
+    }
+    timeout {
+	fail "re-load generated corefile (timeout)"
+    }
+}
+
+send_gdb "where\n"
+gdb_expect_list "where in corefile" ".*$gdb_prompt $" {
+    ".*\[\r\n\]+#0 .* terminal_func \\(\\) at "
+    ".*\[\r\n\]+#1 .* array_func \\(\\) at "
+    ".*\[\r\n\]+#2 .* factorial_func \\(value=1\\) at "
+    ".*\[\r\n\]+#3 .* factorial_func \\(value=2\\) at "
+    ".*\[\r\n\]+#4 .* factorial_func \\(value=3\\) at "
+    ".*\[\r\n\]+#5 .* factorial_func \\(value=4\\) at "
+    ".*\[\r\n\]+#6 .* factorial_func \\(value=5\\) at "
+    ".*\[\r\n\]+#7 .* factorial_func \\(value=6\\) at "
+    ".*\[\r\n\]+#8 .* main \\(.*\\) at "
+}
+
+set post_corefile_regs [capture_command_output "info registers" ""]
+if ![string compare $pre_corefile_regs $post_corefile_regs] then {
+    pass "corefile restored general registers"
+} else {
+    fail "corefile restored general registers"
+}
+
+set post_corefile_allregs [capture_command_output "info all-reg" ""]
+if ![string compare $pre_corefile_allregs $post_corefile_allregs] then {
+    pass "corefile restored all registers"
+} else {
+    fail "corefile restored all registers"
+}
+
+set post_corefile_extern_array \
+	[capture_command_output "print extern_array" "$print_prefix"]
+if ![string compare $pre_corefile_extern_array $post_corefile_extern_array]  {
+    pass "corefile restored extern array"
+} else {
+    fail "corefile restored extern array"
+}
+
+set post_corefile_static_array \
+	[capture_command_output "print static_array" "$print_prefix"]
+if ![string compare $pre_corefile_static_array $post_corefile_static_array]  {
+    pass "corefile restored static array"
+} else {
+    fail "corefile restored static array"
+}
+
+set post_corefile_uninit_array \
+	[capture_command_output "print un_initialized_array" "$print_prefix"]
+if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array]  {
+    pass "corefile restored un-initialized array"
+} else {
+    fail "corefile restored un-initialized array"
+}
+
+set post_corefile_heap_string \
+	[capture_command_output "print heap_string" "$print_prefix"]
+if ![string compare $pre_corefile_heap_string $post_corefile_heap_string]  {
+    pass "corefile restored heap array"
+} else {
+    fail "corefile restored heap array"
+}
+
+set post_corefile_local_array \
+	[capture_command_output "print array_func::local_array" "$print_prefix"]
+if ![string compare $pre_corefile_local_array $post_corefile_local_array]  {
+    pass "corefile restored stack array"
+} else {
+    fail "corefile restored stack array"
+}
+
+set post_corefile_backtrace [capture_command_output "backtrace" ""]
+if ![string compare $pre_corefile_backtrace $post_corefile_backtrace]  {
+    pass "corefile restored backtrace"
+} else {
+    fail "corefile restored backtrace"
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-08  5:05     ` H.J. Lu
@ 2010-07-08 11:15       ` Ulrich Weigand
  2010-07-08 13:52         ` H.J. Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Ulrich Weigand @ 2010-07-08 11:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb, gdb-patches

H.J. Lu wrote:

> It works.  Here is a patch to add a testcase.  OK to install?

Maybe I'm missing something, but it looks like this is an identical
copy of the gcore.exp test, except that the executable is built
with -m32, right?

What does this test check that wouldn't already be checked by running
  make check RUNTESTFLAGS="--target_board='unix/-m32' gcore.exp"
?

Since you should be running the full -m32 testsuite anyway if you care
about the bi-arch debugger, I don't think we want to duplicate this
test case for no real gain ...

Bye,
Ulrich

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-08  2:35   ` Jon Zhou
@ 2010-07-08 11:17     ` Ulrich Weigand
  0 siblings, 0 replies; 13+ messages in thread
From: Ulrich Weigand @ 2010-07-08 11:17 UTC (permalink / raw)
  To: Jon Zhou; +Cc: Mark Kettenis, jan.kratochvil, gdb, gdb-patches

Jon Zhou wrote:

> One more question
> 
> The patch is enable gdb to read the coredump generated by gcore
> Or enable gcore to generate a readable coredump
> Or both?

The patch fixes the gcore command to generate a coredump in the
proper 32-bit format.

Reading in a 32-bit format coredump did already work correctly
before (e.g. a coredump generated by the kernel).

Bye,
Ulrich

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-08 11:15       ` Ulrich Weigand
@ 2010-07-08 13:52         ` H.J. Lu
  2010-07-09 15:48           ` [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?) Ulrich Weigand
  2010-07-21 22:45           ` support biarch gcore? Joseph S. Myers
  0 siblings, 2 replies; 13+ messages in thread
From: H.J. Lu @ 2010-07-08 13:52 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb, gdb-patches

On Thu, Jul 8, 2010 at 4:15 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> H.J. Lu wrote:
>
>> It works.  Here is a patch to add a testcase.  OK to install?
>
> Maybe I'm missing something, but it looks like this is an identical
> copy of the gcore.exp test, except that the executable is built
> with -m32, right?
>
> What does this test check that wouldn't already be checked by running
>  make check RUNTESTFLAGS="--target_board='unix/-m32' gcore.exp"
> ?
>
> Since you should be running the full -m32 testsuite anyway if you care
> about the bi-arch debugger, I don't think we want to duplicate this
> test case for no real gain ...
>

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 } */


-- 
H.J.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?)
  2010-07-08 13:52         ` H.J. Lu
@ 2010-07-09 15:48           ` Ulrich Weigand
  2010-07-09 15:56             ` H.J. Lu
  2010-07-09 21:43             ` H.J. Lu
  2010-07-21 22:45           ` support biarch gcore? Joseph S. Myers
  1 sibling, 2 replies; 13+ messages in thread
From: Ulrich Weigand @ 2010-07-09 15:48 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re:  support biarch gcore?)
  2010-07-09 15:48           ` [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?) Ulrich Weigand
@ 2010-07-09 15:56             ` H.J. Lu
  2010-07-09 21:43             ` H.J. Lu
  1 sibling, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2010-07-09 15:56 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb-patches

On Fri, Jul 9, 2010 at 8:48 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> 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!
>

I will give it a try.  It may take a while.

Thanks.


-- 
H.J.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re:  support biarch gcore?)
  2010-07-09 15:48           ` [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?) Ulrich Weigand
  2010-07-09 15:56             ` H.J. Lu
@ 2010-07-09 21:43             ` H.J. Lu
  2010-07-09 22:33               ` H.J. Lu
  1 sibling, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2010-07-09 21:43 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb-patches

On Fri, Jul 9, 2010 at 8:48 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> 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.
>

This syntax is strange. There are

--
if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
    verbose "Skipping x86 AVX tests."
    return
}
...
if [istarget i?86-*-*] {
    set nr_regs 8
} else {
    set nr_regs 16
}
...

I am looking for something like is_ilp32/is_lp64.


-- 
H.J.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re:  support biarch gcore?)
  2010-07-09 21:43             ` H.J. Lu
@ 2010-07-09 22:33               ` H.J. Lu
  2010-07-12 14:49                 ` Ulrich Weigand
  0 siblings, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2010-07-09 22:33 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2603 bytes --]

On Fri, Jul 9, 2010 at 2:43 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 8:48 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>> 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.
>>
>
> This syntax is strange. There are
>
> --
> if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
>    verbose "Skipping x86 AVX tests."
>    return
> }
> ...
> if [istarget i?86-*-*] {
>    set nr_regs 8
> } else {
>    set nr_regs 16
> }
> ...
>
> I am looking for something like is_ilp32/is_lp64.
>

This patch seems to work.

Thanks.


-- 
H.J.
---
2010-07-09  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.

[-- Attachment #2: gdb-biarch-1.patch --]
[-- Type: text/plain, Size: 12480 bytes --]

2010-07-09  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.

diff --git a/gdb/testsuite/gdb.arch/amd64-byte.exp b/gdb/testsuite/gdb.arch/amd64-byte.exp
index 53d1c54..09b7053 100644
--- a/gdb/testsuite/gdb.arch/amd64-byte.exp
+++ b/gdb/testsuite/gdb.arch/amd64-byte.exp
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 byte register tests."
     return
 }
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
index d77f024..f25093f 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/amd64-dword.exp b/gdb/testsuite/gdb.arch/amd64-dword.exp
index 4d0a6b7..3719b58 100644
--- a/gdb/testsuite/gdb.arch/amd64-dword.exp
+++ b/gdb/testsuite/gdb.arch/amd64-dword.exp
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 dword register tests."
     return
 }
diff --git a/gdb/testsuite/gdb.arch/amd64-i386-address.exp b/gdb/testsuite/gdb.arch/amd64-i386-address.exp
index e98c254..829d9a2 100644
--- a/gdb/testsuite/gdb.arch/amd64-i386-address.exp
+++ b/gdb/testsuite/gdb.arch/amd64-i386-address.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/amd64-word.exp b/gdb/testsuite/gdb.arch/amd64-word.exp
index 04448d7..031f153 100644
--- a/gdb/testsuite/gdb.arch/amd64-word.exp
+++ b/gdb/testsuite/gdb.arch/amd64-word.exp
@@ -23,7 +23,7 @@ if $tracelevel {
 }
 
 
-if { ![istarget x86_64-*-* ] } {
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64 word register tests."
     return
 }
diff --git a/gdb/testsuite/gdb.arch/i386-avx.exp b/gdb/testsuite/gdb.arch/i386-avx.exp
index 426e9d3..7bf748f 100644
--- a/gdb/testsuite/gdb.arch/i386-avx.exp
+++ b/gdb/testsuite/gdb.arch/i386-avx.exp
@@ -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
diff --git a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
index a8eb669..a312db1 100644
--- a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
+++ b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-byte.exp b/gdb/testsuite/gdb.arch/i386-byte.exp
index d4dd5a5..4a17ed0 100644
--- a/gdb/testsuite/gdb.arch/i386-byte.exp
+++ b/gdb/testsuite/gdb.arch/i386-byte.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-disp-step.exp b/gdb/testsuite/gdb.arch/i386-disp-step.exp
index 41f39cf..298973c 100644
--- a/gdb/testsuite/gdb.arch/i386-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/i386-disp-step.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
index fac9e11..4ad4902 100644
--- a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
+++ b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-prologue.exp b/gdb/testsuite/gdb.arch/i386-prologue.exp
index be4b263..6b7b51d 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-size-overlap.exp b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
index bb78c7a..2f22422 100644
--- a/gdb/testsuite/gdb.arch/i386-size-overlap.exp
+++ b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-size.exp b/gdb/testsuite/gdb.arch/i386-size.exp
index e4d4ad3..6e397f9 100644
--- a/gdb/testsuite/gdb.arch/i386-size.exp
+++ b/gdb/testsuite/gdb.arch/i386-size.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-sse.exp b/gdb/testsuite/gdb.arch/i386-sse.exp
index 72a8fb2..cb3af4f 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.exp
+++ b/gdb/testsuite/gdb.arch/i386-sse.exp
@@ -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
diff --git a/gdb/testsuite/gdb.arch/i386-unwind.exp b/gdb/testsuite/gdb.arch/i386-unwind.exp
index ac96683..1c13089 100644
--- a/gdb/testsuite/gdb.arch/i386-unwind.exp
+++ b/gdb/testsuite/gdb.arch/i386-unwind.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/i386-word.exp b/gdb/testsuite/gdb.arch/i386-word.exp
index a178fed..827d101 100644
--- a/gdb/testsuite/gdb.arch/i386-word.exp
+++ b/gdb/testsuite/gdb.arch/i386-word.exp
@@ -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
 }
diff --git a/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp b/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
index c31c280..8ae2317 100644
--- a/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
+++ b/gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp
@@ -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
 }
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.
 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re:       support biarch gcore?)
  2010-07-09 22:33               ` H.J. Lu
@ 2010-07-12 14:49                 ` Ulrich Weigand
  0 siblings, 0 replies; 13+ messages in thread
From: Ulrich Weigand @ 2010-07-12 14:49 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb-patches

H.J. Lu wrote:

> > This syntax is strange. There are
> >
> > --
> > if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
> >  verbose "Skipping x86 AVX tests."
> >  return
> > }
> > ...
> > if [istarget i?86-*-*] {
> >  set nr_regs 8
> > } else {
> >  set nr_regs 16
> > }
> > ...
> >
> > I am looking for something like is_ilp32/is_lp64.

Hmm, I was simply trying to keep the naming scheme in line with
the pre-existing skip_..._tests routines.  However, I guess you're
right if the test needs to be used for other decisions than
simply skipping a test, a different name would be better.

> 2010-07-09  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.

This is OK.

Thanks,
Ulrich

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: support biarch gcore?
  2010-07-08 13:52         ` H.J. Lu
  2010-07-09 15:48           ` [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?) Ulrich Weigand
@ 2010-07-21 22:45           ` Joseph S. Myers
  1 sibling, 0 replies; 13+ messages in thread
From: Joseph S. Myers @ 2010-07-21 22:45 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Ulrich Weigand, Mark Kettenis, jan.kratochvil, Jon.Zhou, gdb,
	gdb-patches

On Thu, 8 Jul 2010, 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 } */

I noted the issue with GDB testcases hardcoding target name tests in a 
previous discussion 
<http://sourceware.org/ml/gdb-patches/2010-03/msg00711.html>, and I think 
adopting GCC-style effective target support would be a good solution.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-07-21 22:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201007062128.o66LSkNC032580@glazunov.sibelius.xs4all.nl>
2010-07-07 12:30 ` support biarch gcore? Ulrich Weigand
2010-07-08  2:35   ` Jon Zhou
2010-07-08 11:17     ` Ulrich Weigand
2010-07-08  4:47   ` H.J. Lu
2010-07-08  5:05     ` H.J. Lu
2010-07-08 11:15       ` Ulrich Weigand
2010-07-08 13:52         ` H.J. Lu
2010-07-09 15:48           ` [rfc] skip_ilp32_tests / skip_lp64_tests predicates (was: Re: support biarch gcore?) Ulrich Weigand
2010-07-09 15:56             ` H.J. Lu
2010-07-09 21:43             ` H.J. Lu
2010-07-09 22:33               ` H.J. Lu
2010-07-12 14:49                 ` Ulrich Weigand
2010-07-21 22:45           ` support biarch gcore? Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).