[testsuite] Fix gdb.btrace/tailcall-only.exp errors on x86_64-m32

Message ID 20160408155331.GA31979@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil April 8, 2016, 3:53 p.m. UTC
  Hi,

$ runtest 'CC_FOR_TARGET=gcc -m32' gdb.btrace/tailcall-only.exp
Running ./gdb.btrace/tailcall-only.exp ...
gdb compile failed, tailcall-only.c: Assembler messages:
tailcall-only.c:142: Error: cannot represent relocation type BFD_RELOC_64
[...]
tailcall-only.c:425: Error: cannot represent relocation type BFD_RELOC_64

It works for the other x86 arch combinations:

--- 20160406clean63-fedora-rawhide//fedora-rawhide-x86_64/out/gdb-x86_64-redhat-linux-gnu-m32.sum       2016-04-06 17:44:45.262849875 +0200
+++ 20160408clean67-fedora-rawhide//fedora-rawhide-x86_64/out/gdb-x86_64-redhat-linux-gnu-m32.sum       2016-04-08 17:40:49.739742759 +0200
#gdb.btrace/tailcall-only.exp
+Running gdb/testsuite/gdb.btrace/tailcall-only.exp ...
+gdb compile failed, tailcall-only.c: Assembler messages:
+tailcall-only.c:142: Error: cannot represent relocation type BFD_RELOC_64
[...]
+tailcall-only.c:425: Error: cannot represent relocation type BFD_RELOC_64
+UNTESTED: gdb.btrace/tailcall-only.exp: tailcall-only.exp
--- 20160406clean63-fedora-rawhide//fedora-rawhide-x86_64/out/gdb-x86_64-redhat-linux-gnu-m64.sum       2016-04-06 17:44:45.555852344 +0200
+++ 20160408clean67-fedora-rawhide//fedora-rawhide-x86_64/out/gdb-x86_64-redhat-linux-gnu-m64.sum       2016-04-08 17:40:50.021744759 +0200
#gdb.btrace/tailcall-only.exp
+Running gdb/testsuite/gdb.btrace/tailcall-only.exp ...
+PASS: gdb.btrace/tailcall-only.exp: set record function-call-history-size 0
[...]
+PASS: gdb.btrace/tailcall-only.exp: info frame
--- 20160406clean63-fedora-rawhide//fedora-rawhide-i386/out/gdb-i686-redhat-linux-gnu-m32.sum   2016-04-06 17:43:44.152334900 +0200
+++ 20160408clean67-fedora-rawhide//fedora-rawhide-i386/out/gdb-i686-redhat-linux-gnu-m32.sum   2016-04-08 17:40:04.451421514 +0200
#gdb.btrace/tailcall-only.exp
+Running gdb/testsuite/gdb.btrace/tailcall-only.exp ...
+PASS: gdb.btrace/tailcall-only.exp: set record function-call-history-size 0
[...]
+PASS: gdb.btrace/tailcall-only.exp: info frame

OK for check-in?


Jan
gdb/testsuite/ChangeLog
2016-04-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.btrace/tailcall-only.exp: Use is_lp64_target check.
  

Comments

Metzger, Markus T April 11, 2016, 6:44 a.m. UTC | #1
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Jan Kratochvil
> Sent: Friday, April 8, 2016 5:54 PM
> To: gdb-patches@sourceware.org
> Cc: Metzger, Markus T <markus.t.metzger@intel.com>
> Subject: [testsuite patch] Fix gdb.btrace/tailcall-only.exp errors on x86_64-
> m32

Hi Jan,

> $ runtest 'CC_FOR_TARGET=gcc -m32' gdb.btrace/tailcall-only.exp Running
> ./gdb.btrace/tailcall-only.exp ...
> gdb compile failed, tailcall-only.c: Assembler messages:
> tailcall-only.c:142: Error: cannot represent relocation type BFD_RELOC_64 [...]
> tailcall-only.c:425: Error: cannot represent relocation type BFD_RELOC_64

I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
Like this:

set target_triplet "i686-unknown-linux"
set_board_info cflags "-m32"
set_board_info cppflags "-m32"

Should I rather not set the target_triplet?

In that case, there are a few more build errors in other gdb.btrace tests.

Thanks,
Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Jan Kratochvil April 11, 2016, 7:55 p.m. UTC | #2
Hello Markus,

On Mon, 11 Apr 2016 08:44:23 +0200, Metzger, Markus T wrote:
> > From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> > owner@sourceware.org] On Behalf Of Jan Kratochvil
[...]
> > $ runtest 'CC_FOR_TARGET=gcc -m32' gdb.btrace/tailcall-only.exp Running
[...]
> I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
> Like this:
> 
> set target_triplet "i686-unknown-linux"
> set_board_info cflags "-m32"

that is an interesting idea and I agree it is a more correct way to run the
testsuite.

Nonetheless it seems to me GDB does not require arch-specific target_triplet
to be set, I have searched now a bit and picked for example:
	https://sourceware.org/ml/gdb-patches/2010-07/msg00343.html
This is why the functions like is_lp64_target were created.

I will leave it up to the GDB maintainers what is the correct way and possibly
adjust my testing scripts accordingly.


Thanks,
Jan
  
Pedro Alves July 20, 2016, 2:02 p.m. UTC | #3
On 04/11/2016 07:44 AM, Metzger, Markus T wrote:
>> -----Original Message-----
>> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
>> owner@sourceware.org] On Behalf Of Jan Kratochvil
>> Sent: Friday, April 8, 2016 5:54 PM
>> To: gdb-patches@sourceware.org
>> Cc: Metzger, Markus T <markus.t.metzger@intel.com>
>> Subject: [testsuite patch] Fix gdb.btrace/tailcall-only.exp errors on x86_64-
>> m32
> 
> Hi Jan,
> 
>> $ runtest 'CC_FOR_TARGET=gcc -m32' gdb.btrace/tailcall-only.exp Running
>> ./gdb.btrace/tailcall-only.exp ...
>> gdb compile failed, tailcall-only.c: Assembler messages:
>> tailcall-only.c:142: Error: cannot represent relocation type BFD_RELOC_64 [...]
>> tailcall-only.c:425: Error: cannot represent relocation type BFD_RELOC_64
> 
> I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
> Like this:
> 
> set target_triplet "i686-unknown-linux"
> set_board_info cflags "-m32"
> set_board_info cppflags "-m32"
> 
> Should I rather not set the target_triplet?

There's no reason you should _not_ set it.

But, multilib-style testing with --target_board=unix\{-m64,-m32\} etc.
should work _too_, IMO.

Thanks,
Pedro Alves
  
Jan Kratochvil July 20, 2016, 2:22 p.m. UTC | #4
On Wed, 20 Jul 2016 16:02:20 +0200, Pedro Alves wrote:
> On 04/11/2016 07:44 AM, Metzger, Markus T wrote:
> > I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
> > Like this:
> > 
> > set target_triplet "i686-unknown-linux"
> > set_board_info cflags "-m32"
> > set_board_info cppflags "-m32"
> > 
> > Should I rather not set the target_triplet?
> 
> There's no reason you should _not_ set it.
> 
> But, multilib-style testing with --target_board=unix\{-m64,-m32\} etc.
> should work _too_, IMO.

Checked in:
	7674d381b47f9f2411c0ca1da0c152940dc0d7bd


Thanks,
Jan
  
Metzger, Markus T July 20, 2016, 2:26 p.m. UTC | #5
> -----Original Message-----
> From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com]
> Sent: Wednesday, July 20, 2016 4:23 PM
> To: Pedro Alves <palves@redhat.com>
> Cc: Metzger, Markus T <markus.t.metzger@intel.com>; gdb-
> patches@sourceware.org
> Subject: [commit] [testsuite patch] Fix gdb.btrace/tailcall-only.exp errors on
> x86_64-m32
> 
> On Wed, 20 Jul 2016 16:02:20 +0200, Pedro Alves wrote:
> > On 04/11/2016 07:44 AM, Metzger, Markus T wrote:
> > > I'm setting the target triplet to "i686-unknown-linux" in my m32 configuration.
> > > Like this:
> > >
> > > set target_triplet "i686-unknown-linux"
> > > set_board_info cflags "-m32"
> > > set_board_info cppflags "-m32"
> > >
> > > Should I rather not set the target_triplet?
> >
> > There's no reason you should _not_ set it.
> >
> > But, multilib-style testing with --target_board=unix\{-m64,-m32\} etc.
> > should work _too_, IMO.
> 
> Checked in:
> 	7674d381b47f9f2411c0ca1da0c152940dc0d7bd

Would this also work for x32?

Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Jan Kratochvil July 20, 2016, 2:32 p.m. UTC | #6
On Wed, 20 Jul 2016 16:26:20 +0200, Metzger, Markus T wrote:
> > From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com]
> > Checked in:
> > 	7674d381b47f9f2411c0ca1da0c152940dc0d7bd
> 
> Would this also work for x32?

I do not have any x32 system setup. Is there some recommended x32 distro?
Unfortunately Fedora/RHEL have no x32 build.


Jan
  
Pedro Alves July 20, 2016, 2:36 p.m. UTC | #7
On 07/20/2016 03:26 PM, Metzger, Markus T wrote:
>> From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com]
>> On Wed, 20 Jul 2016 16:02:20 +0200, Pedro Alves wrote:

>>> But, multilib-style testing with --target_board=unix\{-m64,-m32\} etc.
>>> should work _too_, IMO.
>>
>> Checked in:
>> 	7674d381b47f9f2411c0ca1da0c152940dc0d7bd
> 
> Would this also work for x32?

Not sure this particular commit, but AFAIK, there's no target
triplet for x32, even.  Presumably people run x32 testing
with --target_board=unix/-mx32.  I'm on Fedora so can't test it, myself.

So using is_lp64_target / is_amd64_regs_target /  is_x86_like_target etc.
checks is really the only way to make a testcase detect it's targeting
x32, and adjust itself, skip, etc..  

Thanks,
Pedro Alves
  
Jan Kratochvil July 20, 2016, 2:38 p.m. UTC | #8
On Wed, 20 Jul 2016 16:36:46 +0200, Pedro Alves wrote:
> Not sure this particular commit, but AFAIK, there's no target
> triplet for x32, even.

https://sourceware.org/glibc/wiki/x32
->
x86_64-x32-linux


Jan
  
Pedro Alves July 20, 2016, 3:07 p.m. UTC | #9
On 07/20/2016 03:38 PM, Jan Kratochvil wrote:
> On Wed, 20 Jul 2016 16:36:46 +0200, Pedro Alves wrote:
>> Not sure this particular commit, but AFAIK, there's no target
>> triplet for x32, even.
> 
> https://sourceware.org/glibc/wiki/x32
> ->
> x86_64-x32-linux

AFAICS, that "x32" is in the "vendor" part of the triplet, which should
never mean anything for the tools themselves, being a free field to use by
whoever builds the tools, in order to give the binaries a unique
file name (x86_64-x32-linux-gcc, etc.), and for branding, like
x86_64-redhat-linux-gcc.  AFAICS, nothing in config.sub, and the
different configure scripts in binutils-gdb select on *-x32-*.

ISTR that a triplet like x86_64-*-linux-gnux32 or x86_64-*-linux-gnu-x32
was originally proposed, but then the toolchain ended using strictly
multilib flags to select/detect x32.  But, actually, now that I grep, I find
a few hits on "x86_64-*-linux-gnux32", though not many, so it looks like
there's a triplet after all.

Thanks,
Pedro Alves
  
Metzger, Markus T July 21, 2016, 1:50 p.m. UTC | #10
> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Wednesday, July 20, 2016 5:08 PM
> To: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Metzger, Markus T <markus.t.metzger@intel.com>; gdb-
> patches@sourceware.org
> Subject: Re: [commit] [testsuite patch] Fix gdb.btrace/tailcall-only.exp errors on
> x86_64-m32
> 
> On 07/20/2016 03:38 PM, Jan Kratochvil wrote:
> > On Wed, 20 Jul 2016 16:36:46 +0200, Pedro Alves wrote:
> >> Not sure this particular commit, but AFAIK, there's no target
> >> triplet for x32, even.
> >
> > https://sourceware.org/glibc/wiki/x32
> > ->
> > x86_64-x32-linux
> 
> AFAICS, that "x32" is in the "vendor" part of the triplet, which should
> never mean anything for the tools themselves, being a free field to use by
> whoever builds the tools, in order to give the binaries a unique
> file name (x86_64-x32-linux-gcc, etc.), and for branding, like
> x86_64-redhat-linux-gcc.  AFAICS, nothing in config.sub, and the
> different configure scripts in binutils-gdb select on *-x32-*.
> 
> ISTR that a triplet like x86_64-*-linux-gnux32 or x86_64-*-linux-gnu-x32
> was originally proposed, but then the toolchain ended using strictly
> multilib flags to select/detect x32.  But, actually, now that I grep, I find
> a few hits on "x86_64-*-linux-gnux32", though not many, so it looks like
> there's a triplet after all.

I use the triplet to select the source files for a test.  Seems that wasn't such
a good idea.

Using the pointer size doesn't seem to be such a good idea, either, as x32
uses x86_64 ISA with 32-bit pointers.

Is there a recommended/documented way on how this should be done?


thanks,
Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Pedro Alves July 21, 2016, 2 p.m. UTC | #11
On 07/21/2016 02:50 PM, Metzger, Markus T wrote:

> I use the triplet to select the source files for a test.  Seems that wasn't such
> a good idea.
> 
> Using the pointer size doesn't seem to be such a good idea, either, as x32
> uses x86_64 ISA with 32-bit pointers.

But that's exactly what you want.

> 
> Is there a recommended/documented way on how this should be done?

- is_amd64_regs_target detects x86_64 ISA.

- is_lp64_target detects 64-bit/32-bit pointers.

Thus:

  is_amd64_regs_target && is_lp64_target  == 64-bit
  is_amd64_regs_target && !is_lp64_target == x32
  !is_amd64_regs_target                   == 32-bit

See intro comments to is_amd64_regs_target and proc is_x86_like_target.

Thanks,
Pedro Alves
  
Metzger, Markus T July 21, 2016, 2:04 p.m. UTC | #12
> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Thursday, July 21, 2016 4:00 PM
> To: Metzger, Markus T <markus.t.metzger@intel.com>; Jan Kratochvil
> <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [commit] [testsuite patch] Fix gdb.btrace/tailcall-only.exp errors on
> x86_64-m32
> 
> On 07/21/2016 02:50 PM, Metzger, Markus T wrote:
> 
> > I use the triplet to select the source files for a test.  Seems that wasn't such
> > a good idea.
> >
> > Using the pointer size doesn't seem to be such a good idea, either, as x32
> > uses x86_64 ISA with 32-bit pointers.
> 
> But that's exactly what you want.
> 
> >
> > Is there a recommended/documented way on how this should be done?
> 
> - is_amd64_regs_target detects x86_64 ISA.
> 
> - is_lp64_target detects 64-bit/32-bit pointers.
> 
> Thus:
> 
>   is_amd64_regs_target && is_lp64_target  == 64-bit
>   is_amd64_regs_target && !is_lp64_target == x32
>   !is_amd64_regs_target                   == 32-bit
> 
> See intro comments to is_amd64_regs_target and proc is_x86_like_target.

Thanks,  looks like just "is_amd64_regs_target" is what I want.

Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Patch

diff --git a/gdb/testsuite/gdb.btrace/tailcall-only.exp b/gdb/testsuite/gdb.btrace/tailcall-only.exp
index 44501f5..50837bf 100644
--- a/gdb/testsuite/gdb.btrace/tailcall-only.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall-only.exp
@@ -35,9 +35,9 @@  if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
     standard_testfile tailcall-only.c
     lappend opts debug optimize=-O2
-} elseif {[istarget "x86_64-*-*"]} {
+} elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} {
 	standard_testfile x86_64-tailcall-only.S
-} elseif {[istarget "i?86-*-*"]} {
+} elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
 	standard_testfile i686-tailcall-only.S
 } else {
     verbose "Skipping ${testfile}."