public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target
@ 2023-01-25 20:06 Tom de Vries
  2023-01-25 20:06 ` [RFC 1/3] [gdb/contrib] Add refactor.py Tom de Vries
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-25 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I used a refactoring setup I wrote in python for another refactoring to
rewrite:
...
if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
    verbose "Skipping ${testfile}."
    return
}
...
into:
...
require is_x86_64_m64_target
...

It also handles the elseif case.

Due to a recent commit, only the elseif cases are transformed, the others
have been handled already.

Also, I see now that "require {istarget x86_64-*-*} is_lp64_target" can be used,
and that is_x86_64_m64_target not stricly necessary.

I've included the two patches with the refactoring scripts.

Tom de Vries (3):
  [gdb/contrib] Add refactor.py
  [gdb/contrib] Add refactor_require.py
  [gdb/testsuite] Add and use is_x86_64_m64_target

 gdb/contrib/refactor.py                       | 73 +++++++++++++++++++
 gdb/contrib/refactor_require.py               | 53 ++++++++++++++
 .../gdb.arch/amd64-entry-value-param.exp      |  5 +-
 gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp |  5 +-
 .../gdb.mi/mi2-amd64-entry-value.exp          |  5 +-
 .../gdb.python/py-framefilter-invalidarg.exp  |  5 +-
 gdb/testsuite/gdb.python/py-linetable.exp     |  5 +-
 .../gdb.reverse/amd64-tailcall-reverse.exp    |  5 +-
 .../gdb.reverse/singlejmp-reverse.exp         |  5 +-
 gdb/testsuite/lib/gdb.exp                     |  4 +
 10 files changed, 143 insertions(+), 22 deletions(-)
 create mode 100755 gdb/contrib/refactor.py
 create mode 100644 gdb/contrib/refactor_require.py


base-commit: 6121eeb72978cc5749c4c9f119b4dbaf637517c9
-- 
2.35.3


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

* [RFC 1/3] [gdb/contrib] Add refactor.py
  2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
@ 2023-01-25 20:06 ` Tom de Vries
  2023-01-25 20:06 ` [RFC 2/3] [gdb/contrib] Add refactor_require.py Tom de Vries
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-25 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Add a refactoring script gdb/contrib/refactor.py that takes a transformation
script as argument, for instance a script gdb/contrib/transform.py, like so:
...
$ ./gdb/contrib/refactor.py transform
...
---
 gdb/contrib/refactor.py | 73 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100755 gdb/contrib/refactor.py

diff --git a/gdb/contrib/refactor.py b/gdb/contrib/refactor.py
new file mode 100755
index 00000000000..fe2fa019051
--- /dev/null
+++ b/gdb/contrib/refactor.py
@@ -0,0 +1,73 @@
+#! /usr/bin/env python3
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of GDB.
+#
+# 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/>.
+
+import os
+import sys
+import re
+
+transform_file = sys.argv[1]
+transform_file = re.sub(r"\.py$", r"", transform_file)
+
+transformation = __import__(transform_file)
+
+# Define scope of refactoring.
+
+# Sources.
+#dirs = ["gdb", "gdbserver", "gdbsupport"]
+#avoid_dir = "/testsuite/"
+#exts = [".c", ".cc", ".h"]
+
+# Testsuite.
+#dirs = ["gdb/testsuite"]
+#avoid_dir = None
+#exts = [".exp"]
+
+# In transformation file.
+dirs=transformation.dirs
+avoid_dir=transformation.avoid_dir
+exts=transformation.exts
+
+def handle_file(filename):
+    file = open(filename, 'r+')
+    data = file.read()
+    file.close()
+
+    transformation.have_match = False
+    data = transformation.transform(data)
+    if transformation.have_match:
+        file = open(filename, 'w')
+        file.write(data)
+        file.close()
+
+def main():
+    for dir in dirs:
+        for walk_root, walk_dirs, walk_files in os.walk(dir):
+            for file in walk_files:
+                full = os.path.join(walk_root, file)
+                if avoid_dir != None and avoid_dir in full:
+                    continue
+                found = False
+                for ext in exts:
+                    if file.endswith(ext):
+                        found = True
+                        break
+                if found:
+                    handle_file(full)
+
+main()
-- 
2.35.3


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

* [RFC 2/3] [gdb/contrib] Add refactor_require.py
  2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
  2023-01-25 20:06 ` [RFC 1/3] [gdb/contrib] Add refactor.py Tom de Vries
@ 2023-01-25 20:06 ` Tom de Vries
  2023-01-25 20:06 ` [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target Tom de Vries
  2023-01-25 21:26 ` [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom Tromey
  3 siblings, 0 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-25 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Add refactoring script refactor_require.py, to be used with refactor.py.
---
 gdb/contrib/refactor_require.py | 53 +++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 gdb/contrib/refactor_require.py

diff --git a/gdb/contrib/refactor_require.py b/gdb/contrib/refactor_require.py
new file mode 100644
index 00000000000..e8ac96643cf
--- /dev/null
+++ b/gdb/contrib/refactor_require.py
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of GDB.
+#
+# 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/>.
+
+import re
+
+dirs = ["gdb/testsuite"]
+avoid_dir = None
+exts = [".exp"]
+
+pattern_lines = [
+    "(else)?" + re.escape ("if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {"),
+    r"\s+verbose.*",
+    r"\s+return",
+    "\}"
+]
+pattern = "\n".join(pattern_lines)
+
+def repl(matchobj):
+    global have_match
+    have_match = True
+
+    if matchobj.group(1) == "else":
+        repl_lines = [
+            r"else {",
+            r"    require is_x86_64_m64_target",
+            r"}"
+        ]
+    else:
+        repl_lines = [
+            r"require is_x86_64_m64_target"
+        ]
+    repl= "\n".join(repl_lines)
+
+    return repl
+
+def transform(data):
+    return re.sub(pattern, repl, data)
-- 
2.35.3


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

* [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
  2023-01-25 20:06 ` [RFC 1/3] [gdb/contrib] Add refactor.py Tom de Vries
  2023-01-25 20:06 ` [RFC 2/3] [gdb/contrib] Add refactor_require.py Tom de Vries
@ 2023-01-25 20:06 ` Tom de Vries
  2023-01-25 21:25   ` Tom Tromey
  2023-01-25 21:26 ` [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom Tromey
  3 siblings, 1 reply; 15+ messages in thread
From: Tom de Vries @ 2023-01-25 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Add new proc is_x86_64_m64_target and use it by running:
...
$ ./gdb/contrib/refactor.py refactor_require
...
---
 gdb/testsuite/gdb.arch/amd64-entry-value-param.exp     | 5 ++---
 gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp          | 5 ++---
 gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp         | 5 ++---
 gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp | 5 +----
 gdb/testsuite/gdb.python/py-linetable.exp              | 5 ++---
 gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp   | 5 ++---
 gdb/testsuite/gdb.reverse/singlejmp-reverse.exp        | 5 ++---
 gdb/testsuite/lib/gdb.exp                              | 4 ++++
 8 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
index 242a7a35ce7..da1445f51c2 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
@@ -20,9 +20,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
     set srcfile ${srcfile2}
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping amd64-entry-value-param."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
index 9d3e4d40f60..1602aff5dc5 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
@@ -20,9 +20,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-tailcall-ret.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 4657509e84c..76acabc0ade 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -28,9 +28,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.mi/mi2-amd64-entry-value.exp COMPILE=1"
     set srcfile ${testfile}.c
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping mi2-amd64-entry-value."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 set executable ${testfile}
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index d2c29afa81d..2fab2bbd80a 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -19,10 +19,7 @@ require allow_python_tests
 
 standard_testfile amd64-py-framefilter-invalidarg.S
 
-if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping py-framefilter-invalidarg."
-    return
-}
+require is_x86_64_m64_target
 
 # We cannot use prepare_for_testing as we have to set the safe-patch
 # to check objfile and progspace printers.
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index d19516df9a8..c43fb7fc987 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -22,9 +22,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
index dd6e4d2045f..9654dffc378 100644
--- a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
@@ -22,9 +22,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.reverse/amd64-tailcall-reverse.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
index bc7e6876bd2..c31e555fe2a 100644
--- a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
@@ -26,9 +26,8 @@ if [info exists COMPILE] {
 				      ] == -1 } {
 	return -1
     }
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 } elseif { [build_executable ${testfile}.exp ${testfile} \
 	    [list ${srcfile} ${srcfile2}] {}] == -1 } {
     return -1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e2af5a252b7..cc454583242 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3414,6 +3414,10 @@ proc is_x86_like_target {} {
     return [expr [is_ilp32_target] && ![is_amd64_regs_target]]
 }
 
+proc is_x86_64_m64_target {} {
+    return [istarget x86_64-*-* ] && [is_lp64_target]
+}
+
 # Return 1 if this target is an arm or aarch32 on aarch64.
 
 gdb_caching_proc is_aarch32_target {
-- 
2.35.3


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

* Re: [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-25 20:06 ` [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target Tom de Vries
@ 2023-01-25 21:25   ` Tom Tromey
  2023-01-26  9:17     ` [pushed] " Tom de Vries
  0 siblings, 1 reply; 15+ messages in thread
From: Tom Tromey @ 2023-01-25 21:25 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> Add new proc is_x86_64_m64_target and use it by running:
 
Tom> +proc is_x86_64_m64_target {} {

Probably should have an intro comment... it's kind of pedantic though
since IMO the name is pretty clear.

Tom> +    return [istarget x86_64-*-* ] && [is_lp64_target]

Should wrap this in [expr {...}], since otherwise calling this will
return a string like "1 && 0" or something.  Maybe we have a double-eval
somewhere if this is actually working.

Tom

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

* Re: [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target
  2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
                   ` (2 preceding siblings ...)
  2023-01-25 20:06 ` [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target Tom de Vries
@ 2023-01-25 21:26 ` Tom Tromey
  2023-01-26  9:30   ` Tom de Vries
  3 siblings, 1 reply; 15+ messages in thread
From: Tom Tromey @ 2023-01-25 21:26 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> I used a refactoring setup I wrote in python for another refactoring to
Tom> rewrite:
Tom> ...
Tom> if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
Tom>     verbose "Skipping ${testfile}."
Tom>     return
Tom> }
Tom> ...
Tom> into:
Tom> ...
Tom> require is_x86_64_m64_target
Tom> ...

Tom> It also handles the elseif case.

Tom> Due to a recent commit, only the elseif cases are transformed, the others
Tom> have been handled already.

If you want the existing requires could be converted to use the new
proc.  Seems a little simpler.

I sent a comment to one patch but otherwise this looks good to me.
Thanks for doing it.

FWIW I also have some refactoring scripts, but mine are
idiosyncratically written in emacs lisp, which is convenient in some
ways (easier to do multi-line edits, and back in the day I could have
them make ChangeLog entries) but worse in others (slow).

Tom

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

* [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-25 21:25   ` Tom Tromey
@ 2023-01-26  9:17     ` Tom de Vries
  2023-01-26 15:48       ` Tom de Vries
  0 siblings, 1 reply; 15+ messages in thread
From: Tom de Vries @ 2023-01-26  9:17 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches

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

On 1/25/23 22:25, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> Add new proc is_x86_64_m64_target and use it by running:
>   
> Tom> +proc is_x86_64_m64_target {} {
> 
> Probably should have an intro comment... it's kind of pedantic though
> since IMO the name is pretty clear.
> 

Done.

> Tom> +    return [istarget x86_64-*-* ] && [is_lp64_target]
> 
> Should wrap this in [expr {...}], since otherwise calling this will
> return a string like "1 && 0" or something.  Maybe we have a double-eval
> somewhere if this is actually working.

Done.

I've also rewritten the requires, as you suggested in the other reply, 
so we're now left with just these matches:
...
$ ( cd gdb/testsuite; find -type f -name "*.exp*" \
   | xargs grep 'x86_64.*lp64' )

./gdb.dwarf2/entry-value-typedef.exp:
   if { [istarget "x86_64-*-linux*"] && [is_lp64_target] } {

./gdb.base/jit-reader.exp:
   require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target

./gdb.arch/amd64-i386-address.exp:
   require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target

./lib/gdb.exp:
   return [expr [istarget x86_64-*-* ] && [is_lp64_target]]
...

Committed as attached.

[ FWIW, I did wonder for a bit about using the name is_amd64_m64_target 
instead, but didn't manage to convince myself one way or the other, so I 
just stuck with what I started with. ]

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Add-and-use-is_x86_64_m64_target.patch --]
[-- Type: text/x-patch, Size: 32761 bytes --]

From 67c1a16139fba98d1013901ef053c60c97e134d0 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Wed, 25 Jan 2023 20:31:23 +0100
Subject: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target

Add new proc is_x86_64_m64_target and use it where appropriate.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp   |  2 +-
 gdb/testsuite/gdb.arch/amd64-byte.exp                |  2 +-
 gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp       |  2 +-
 gdb/testsuite/gdb.arch/amd64-disp-step.exp           |  2 +-
 gdb/testsuite/gdb.arch/amd64-dword.exp               |  2 +-
 gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp  |  2 +-
 .../gdb.arch/amd64-entry-value-param-dwarf5.exp      |  2 +-
 gdb/testsuite/gdb.arch/amd64-entry-value-param.exp   |  5 ++---
 .../gdb.arch/amd64-entry-value-paramref.exp          |  2 +-
 gdb/testsuite/gdb.arch/amd64-entry-value.exp         |  2 +-
 gdb/testsuite/gdb.arch/amd64-eval.exp                |  2 +-
 .../gdb.arch/amd64-invalid-stack-middle.exp          |  2 +-
 gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp   |  2 +-
 gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp     |  2 +-
 gdb/testsuite/gdb.arch/amd64-prologue-skip.exp       |  2 +-
 gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp        |  2 +-
 gdb/testsuite/gdb.arch/amd64-stap-expressions.exp    |  2 +-
 .../gdb.arch/amd64-stap-optional-prefix.exp          |  5 +----
 .../gdb.arch/amd64-stap-special-operands.exp         |  2 +-
 gdb/testsuite/gdb.arch/amd64-stap-wrong-subexp.exp   |  2 +-
 gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp        |  2 +-
 gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp      |  2 +-
 gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp        |  5 ++---
 gdb/testsuite/gdb.arch/amd64-tailcall-self.exp       |  2 +-
 gdb/testsuite/gdb.arch/amd64-word.exp                |  2 +-
 gdb/testsuite/gdb.base/coredump-filter-build-id.exp  |  5 +----
 gdb/testsuite/gdb.compile/compile-cplus.exp          |  2 +-
 gdb/testsuite/gdb.compile/compile.exp                |  2 +-
 gdb/testsuite/gdb.cp/namelessclass.exp               |  4 +---
 gdb/testsuite/gdb.dwarf2/clztest.exp                 |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-common-block.exp        |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp           |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-error.exp               |  5 +----
 gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp        |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-op-out-param.exp        |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp       |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-restore.exp             |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-restrict.exp            |  4 +---
 .../gdb.dwarf2/dw2-single-line-discriminators.exp    |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp  |  4 +---
 gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp      |  4 +---
 gdb/testsuite/gdb.dwarf2/fission-base.exp            |  4 +---
 gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp    |  4 +---
 gdb/testsuite/gdb.dwarf2/fission-loclists.exp        |  4 +---
 gdb/testsuite/gdb.dwarf2/trace-crash.exp             |  4 +---
 gdb/testsuite/gdb.dwarf2/typeddwarf.exp              |  2 +-
 gdb/testsuite/gdb.mi/mi-reg-undefined.exp            |  4 +---
 gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp       |  5 ++---
 .../gdb.python/py-framefilter-invalidarg.exp         |  5 +----
 gdb/testsuite/gdb.python/py-linetable.exp            |  5 ++---
 gdb/testsuite/gdb.python/py-unwind.exp               |  2 +-
 gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp |  5 ++---
 gdb/testsuite/gdb.reverse/singlejmp-reverse.exp      | 12 ++++++------
 gdb/testsuite/lib/gdb.exp                            |  5 +++++
 54 files changed, 68 insertions(+), 114 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp b/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
index faa6ce14878..626240b6db8 100644
--- a/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
+++ b/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.arch/amd64-byte.exp b/gdb/testsuite/gdb.arch/amd64-byte.exp
index 78763e4e2ae..b6dfc8a26c8 100644
--- a/gdb/testsuite/gdb.arch/amd64-byte.exp
+++ b/gdb/testsuite/gdb.arch/amd64-byte.exp
@@ -18,7 +18,7 @@
 
 # This file is part of the gdb testsuite.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile amd64-pseudo.c
 
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
index fea71457081..ef44a248b82 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
@@ -18,7 +18,7 @@
 # Test displaced stepping over VEX-encoded RIP-relative AVX
 # instructions.
 
-require {istarget x86_64-*-*} is_lp64_target have_avx
+require is_x86_64_m64_target have_avx
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
index 6ca95f44406..2aee1e05774 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
@@ -18,7 +18,7 @@
 # Test amd64 displaced stepping.
 
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 set newline "\[\r\n\]*"
 
diff --git a/gdb/testsuite/gdb.arch/amd64-dword.exp b/gdb/testsuite/gdb.arch/amd64-dword.exp
index 9f227601ca4..201abb08c32 100644
--- a/gdb/testsuite/gdb.arch/amd64-dword.exp
+++ b/gdb/testsuite/gdb.arch/amd64-dword.exp
@@ -18,7 +18,7 @@
 
 # This file is part of the gdb testsuite.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile amd64-pseudo.c
 
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
index 30b4395433d..774b90bcdb0 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     standard_testfile
     lappend opts debug optimize=-O2
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
index 25615ceaafc..f6d11b26cc7 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     set srcfile ${srcfile2}
     lappend opts optimize=-O2 additional_flags=-gdwarf-5
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
index 242a7a35ce7..da1445f51c2 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
@@ -20,9 +20,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
     set srcfile ${srcfile2}
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping amd64-entry-value-param."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
index be22937481a..ff3e0242e9a 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
@@ -15,7 +15,7 @@
 
 standard_testfile .S .cc
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [prepare_for_testing_full "failed to prepare" \
 	  [list $testfile "c++" $srcfile {}]] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
index f5aa42a53b5..a700e9a691b 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     set srcfile ${testfile}.cc
     lappend opts debug optimize=-O2
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-eval.exp b/gdb/testsuite/gdb.arch/amd64-eval.exp
index c9ae30fc4d0..73e2864211c 100644
--- a/gdb/testsuite/gdb.arch/amd64-eval.exp
+++ b/gdb/testsuite/gdb.arch/amd64-eval.exp
@@ -17,7 +17,7 @@
 
 # This testcase exercises evaluation with amd64 calling conventions.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile .cc
 
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
index a5aaeedd359..156300be1d9 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
@@ -29,7 +29,7 @@
 
 standard_testfile .S
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {nopie}] } {
     return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
index 19b2972c34c..b6a25f8525f 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
@@ -30,7 +30,7 @@
 set opts {}
 standard_testfile .c
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
     return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp b/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
index 7f45b956b39..56fe3016c55 100644
--- a/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
+++ b/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     set srcfile ${srcfile2}
     lappend opts debug optimize=-O2
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
index 44464bd3193..be28fa04c84 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
@@ -16,7 +16,7 @@
 standard_testfile .S
 set binfile ${binfile}.o
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
     untested "failed to compile"
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
index d02c1418a30..f771b09ccbc 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
@@ -25,7 +25,7 @@ if [info exists COMPILE] {
     set srcfile ${csrcfile}
     lappend opts debug optimize=-O0
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if {[prepare_for_testing "failed to prepare" ${binfile} $srcfile $opts]} {
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-expressions.exp b/gdb/testsuite/gdb.arch/amd64-stap-expressions.exp
index 43627042e9e..48124a85f7f 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-expressions.exp
+++ b/gdb/testsuite/gdb.arch/amd64-stap-expressions.exp
@@ -15,7 +15,7 @@
 
 standard_testfile ".S"
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp b/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
index 98083bacb35..7758b9cd29b 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
+++ b/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
@@ -17,10 +17,7 @@
 
 standard_testfile ".S"
 
-if { ![istarget "x86_64-*-*"] || ![is_lp64_target] } {
-    verbose "Skipping $testfile.exp"
-    return
-}
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-special-operands.exp b/gdb/testsuite/gdb.arch/amd64-stap-special-operands.exp
index 9a453e53ace..147d0ff40b2 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-special-operands.exp
+++ b/gdb/testsuite/gdb.arch/amd64-stap-special-operands.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 proc test_probe { probe_name } {
     with_test_prefix "probe: ${probe_name}" {
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-wrong-subexp.exp b/gdb/testsuite/gdb.arch/amd64-stap-wrong-subexp.exp
index f2172a0ce35..fdfcb5a5e26 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-wrong-subexp.exp
+++ b/gdb/testsuite/gdb.arch/amd64-stap-wrong-subexp.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile amd64-stap-wrong-subexp.S
 
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
index 756f210d783..41b03b88bd5 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     standard_testfile amd64-tailcall-cxx1.cc amd64-tailcall-cxx2.cc
     lappend opts debug optimize=-O2
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} "${srcfile} ${srcfile2}" $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
index 30be37fe4ff..3267a5ae9ca 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
@@ -21,7 +21,7 @@ if [info exists COMPILE] {
     standard_testfile
     lappend opts debug optimize=-O2
 } else {
-    require {istarget x86_64-*-*} is_lp64_target
+    require is_x86_64_m64_target
 }
 
 lappend opts nopie
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
index 9d3e4d40f60..1602aff5dc5 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
@@ -20,9 +20,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-tailcall-ret.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
index e2fa9328e71..03e7ae971a8 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
@@ -15,7 +15,7 @@
 
 standard_testfile .S
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {}] } {
     return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-word.exp b/gdb/testsuite/gdb.arch/amd64-word.exp
index 5c3164aa941..76722f2f71e 100644
--- a/gdb/testsuite/gdb.arch/amd64-word.exp
+++ b/gdb/testsuite/gdb.arch/amd64-word.exp
@@ -18,7 +18,7 @@
 
 # This file is part of the gdb testsuite.
 
-require {istarget x86_64-*-*} is_lp64_target
+require is_x86_64_m64_target
 
 standard_testfile amd64-pseudo.c
 
diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
index 3c0021a6cc7..1ca10523d40 100644
--- a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
@@ -28,10 +28,7 @@ if { ![istarget *-*-linux*] } {
     untested "$testfile.exp"
     return -1
 }
-if { ![istarget "x86_64-*-*"] || ![is_lp64_target] } {
-    untested "$testfile.exp"
-    return -1
-}
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
     return -1
diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp
index 0b7cb59727a..489236a8b49 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus.exp
@@ -24,7 +24,7 @@ if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
     lappend options c++
 }
 
-if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+if { ![is_x86_64_m64_target] } {
     verbose "Skipping x86_64 LOC_CONST test."
     set srcfile3 ""
 }
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index 9fdd36719ae..f3d87cd2605 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -22,7 +22,7 @@ if [test_compiler_info gcc*] {
     lappend options additional_flags=-g3
 }
 
-if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+if { ![is_x86_64_m64_target] } {
     verbose "Skipping x86_64 LOC_CONST test."
     set srcfile3 ""
 }
diff --git a/gdb/testsuite/gdb.cp/namelessclass.exp b/gdb/testsuite/gdb.cp/namelessclass.exp
index 24cd6256508..f6a95f6f977 100644
--- a/gdb/testsuite/gdb.cp/namelessclass.exp
+++ b/gdb/testsuite/gdb.cp/namelessclass.exp
@@ -22,9 +22,7 @@ load_lib dwarf.exp
 # This test can only be run on x86-like targets which support DWARF.
 require dwarf2_support allow_cplus_tests
 
-if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 set csrcfile "${testfile}.cc"
diff --git a/gdb/testsuite/gdb.dwarf2/clztest.exp b/gdb/testsuite/gdb.dwarf2/clztest.exp
index 75dfb15ec20..a42b99a0677 100644
--- a/gdb/testsuite/gdb.dwarf2/clztest.exp
+++ b/gdb/testsuite/gdb.dwarf2/clztest.exp
@@ -22,9 +22,7 @@ set test "clztest"
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" "${test}" ${test}.S \
       {nodebug nopie additional_flags=-nostdlib}] } {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
index 7ac4ecb8600..b4f5a71e05a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
@@ -19,9 +19,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 # It requires fortran.
 require allow_fortran_tests
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp b/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp
index 262b9728527..527ce6eb2a2 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp
@@ -18,9 +18,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86_64 targets.
-if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-error.exp b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
index 0980f43078f..564c8c47089 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
@@ -20,10 +20,7 @@ require dwarf2_support
 
 standard_testfile .S
 
-if { ![istarget "x86_64-*-*"] || ![is_lp64_target] } {
-    verbose "Skipping $gdb_test_file_name."
-    return
-}
+require is_x86_64_m64_target
 
 # We can't use prepare_for_testing here because we need to check the
 # 'file' command's output.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp
index bdd7070dca2..d5401fa5701 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-break.exp
@@ -22,9 +22,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86_64 targets.
-if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 set basename "inline-break"
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.exp b/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.exp
index 535e74d255d..abb1dcebf9d 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.exp
@@ -21,9 +21,7 @@ set test "dw2-op-out-param"
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 if { [prepare_for_testing "failed to prepare" "${test}" ${test}.S {nodebug}] } {
     return -1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp b/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
index 06dd4dc3723..c0105506d3d 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-reg-undefined.exp
@@ -18,9 +18,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86_64 targets.
-if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-restore.exp b/gdb/testsuite/gdb.dwarf2/dw2-restore.exp
index fd8b2a84d22..3be758aa836 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-restore.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-restore.exp
@@ -16,9 +16,7 @@
 # Test handling of DW_CFA_restore_state.
 
 # This test can only be run on x86_64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0  
-}
+require is_x86_64_m64_target
 standard_testfile .S
 
 set opts [list {additional_flags=-nostdlib}]
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp b/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp
index d51cb8e0b7a..6f5a17759ae 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp
@@ -19,9 +19,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.exp b/gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.exp
index dfb531371eb..8ff6dadbe8b 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-single-line-discriminators.exp
@@ -22,9 +22,7 @@ load_lib dwarf.exp
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 set csrcfile ${testfile}.c
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp
index e532c4cb8f2..d4b7917fbdd 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp
@@ -20,9 +20,7 @@ standard_testfile .S
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 if {[prepare_for_testing "failed to prepare" "$testfile" $srcfile {nodebug nopie}]} {
     return -1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp b/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
index 63e75fb6343..a4bd938961e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
@@ -18,9 +18,7 @@ load_lib dwarf.exp
 # This test can only be run on x86-64 targets.  It checks for a bug
 # that existed in amd64-tdep.c, and depends on an error being produced
 # from within that file.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 # This test can only be run on targets which support DWARF-2 and use gas.
 require dwarf2_support
diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.exp b/gdb/testsuite/gdb.dwarf2/fission-base.exp
index b654de40fcb..e753ef1293e 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-base.exp
@@ -22,9 +22,7 @@ require {!is_remote host}
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
index a6fb3e875a8..ae8e20f4636 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
@@ -27,9 +27,7 @@ require {!is_remote host}
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
index d906eeb69cc..6bcb2988324 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
@@ -22,9 +22,7 @@ require {!is_remote host}
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/trace-crash.exp b/gdb/testsuite/gdb.dwarf2/trace-crash.exp
index 06c0c67a35e..fc1966a016b 100644
--- a/gdb/testsuite/gdb.dwarf2/trace-crash.exp
+++ b/gdb/testsuite/gdb.dwarf2/trace-crash.exp
@@ -20,9 +20,7 @@ load_lib trace-support.exp
 require dwarf2_support
 
 # This test can only be run on x86-64 targets.
-if {![istarget x86_64-*] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 standard_testfile .S
 
diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
index 0b89741e361..3fafe9cf6f8 100644
--- a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
+++ b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
@@ -23,7 +23,7 @@ require dwarf2_support
 # This test can only be run on x86 and amd64 targets (and not x32).
 if { [is_x86_like_target] } {
     set sfile ${test}.S
-} elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} {
+} elseif { [is_x86_64_m64_target] } {
     set sfile ${test}-amd64.S
 } else {
     return 0
diff --git a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
index 94db94289e2..caca9690e9b 100644
--- a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
+++ b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
@@ -20,9 +20,7 @@ set MIFLAGS "-i=mi"
 require dwarf2_support
 
 # This test can only be run on x86_64 targets.
-if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
-    return 0
-}
+require is_x86_64_m64_target
 
 gdb_exit
 if [mi_gdb_start] {
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 4657509e84c..76acabc0ade 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -28,9 +28,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.mi/mi2-amd64-entry-value.exp COMPILE=1"
     set srcfile ${testfile}.c
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping mi2-amd64-entry-value."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 set executable ${testfile}
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index d2c29afa81d..2fab2bbd80a 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -19,10 +19,7 @@ require allow_python_tests
 
 standard_testfile amd64-py-framefilter-invalidarg.S
 
-if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping py-framefilter-invalidarg."
-    return
-}
+require is_x86_64_m64_target
 
 # We cannot use prepare_for_testing as we have to set the safe-patch
 # to check objfile and progspace printers.
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index d19516df9a8..c43fb7fc987 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -22,9 +22,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 0d817378d97..5bf9ae129ac 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -32,7 +32,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug $fla
 }
 
 # This test runs on a specific platform.
-if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { continue }
+require is_x86_64_m64_target
 
 # The following tests require execution.
 
diff --git a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
index dd6e4d2045f..9654dffc378 100644
--- a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
@@ -22,9 +22,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.reverse/amd64-tailcall-reverse.exp COMPILE=1"
     standard_testfile
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
+} else {
+    require is_x86_64_m64_target
 }
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
diff --git a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
index bc7e6876bd2..23310e7cf9d 100644
--- a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
@@ -26,12 +26,12 @@ if [info exists COMPILE] {
 				      ] == -1 } {
 	return -1
     }
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping ${testfile}."
-    return
-} elseif { [build_executable ${testfile}.exp ${testfile} \
-	    [list ${srcfile} ${srcfile2}] {}] == -1 } {
-    return -1
+} else {
+    require is_x86_64_m64_target
+    if { [build_executable ${testfile}.exp ${testfile} \
+	      [list ${srcfile} ${srcfile2}] {}] == -1 } {
+	return -1
+    }
 }
 
 clean_restart $executable
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e2af5a252b7..0f9fe9a1e48 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3414,6 +3414,11 @@ proc is_x86_like_target {} {
     return [expr [is_ilp32_target] && ![is_amd64_regs_target]]
 }
 
+# Return 1 if this target is an x86_64 with -m64.
+proc is_x86_64_m64_target {} {
+    return [expr [istarget x86_64-*-* ] && [is_lp64_target]]
+}
+
 # Return 1 if this target is an arm or aarch32 on aarch64.
 
 gdb_caching_proc is_aarch32_target {

base-commit: f212f7feec305bb61407fff312f681add8c1b164
-- 
2.35.3


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

* Re: [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target
  2023-01-25 21:26 ` [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom Tromey
@ 2023-01-26  9:30   ` Tom de Vries
  0 siblings, 0 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-26  9:30 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches

On 1/25/23 22:26, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> I used a refactoring setup I wrote in python for another refactoring to
> Tom> rewrite:
> Tom> ...
> Tom> if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
> Tom>     verbose "Skipping ${testfile}."
> Tom>     return
> Tom> }
> Tom> ...
> Tom> into:
> Tom> ...
> Tom> require is_x86_64_m64_target
> Tom> ...
> 
> Tom> It also handles the elseif case.
> 
> Tom> Due to a recent commit, only the elseif cases are transformed, the others
> Tom> have been handled already.
> 
> If you want the existing requires could be converted to use the new
> proc.  Seems a little simpler.
> 

Done.

> I sent a comment to one patch but otherwise this looks good to me.
> Thanks for doing it.
> 
> FWIW I also have some refactoring scripts, but mine are
> idiosyncratically written in emacs lisp, which is convenient in some
> ways (easier to do multi-line edits, and back in the day I could have
> them make ChangeLog entries) but worse in others (slow).

I see.  I love to use emacs, but I'm not familiar with lisp, so that's 
not an option for me :)

Anyway, I don't think that the refactoring scripts I've posted here are 
ready for contribution, but ideally I'd love to have some refactoring 
tool commonly used, with the idea that it would enable not only posting 
the result of the transformation, put also the transformation itself, 
and you could get feedback on the transformation, people could try it 
out themselves, find cases they think could be handled in addition, post 
improved versions.  And something in python seems not a bad choice, 
considering the popularity of it.

FWIW, I've started out with the idea of using cocinelle for some gdb 
source transformation, but pretty soon found out that c++ support is 
missing/poor, so I abandoned that idea.

Thanks,
- Tom

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26  9:17     ` [pushed] " Tom de Vries
@ 2023-01-26 15:48       ` Tom de Vries
  2023-01-26 16:10         ` Tom Tromey
  0 siblings, 1 reply; 15+ messages in thread
From: Tom de Vries @ 2023-01-26 15:48 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches

On 1/26/23 10:17, Tom de Vries wrote:
> ./gdb.base/jit-reader.exp:
>    require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
> 
> ./gdb.arch/amd64-i386-address.exp:
>    require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target

And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?

Am I missing something here?

Otherwise, we can just use is_x86_64_m64_target here as well.

Thanks,
- Tom

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 15:48       ` Tom de Vries
@ 2023-01-26 16:10         ` Tom Tromey
  2023-01-26 16:36           ` Tom de Vries
  2023-01-26 16:38           ` Pedro Alves
  0 siblings, 2 replies; 15+ messages in thread
From: Tom Tromey @ 2023-01-26 16:10 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom Tromey, Tom de Vries

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> On 1/26/23 10:17, Tom de Vries wrote:
>> ./gdb.base/jit-reader.exp:
>>   require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
>> ./gdb.arch/amd64-i386-address.exp:
>>   require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target

Tom> And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?

Tom> Am I missing something here?

I am not sure.  Can you use 'gcc -m64' on an x86?  Or could you have a
64-bit machine that advertises as i386 if userspace is mostly 32-bit?

Tom

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 16:10         ` Tom Tromey
@ 2023-01-26 16:36           ` Tom de Vries
  2023-01-26 16:38           ` Pedro Alves
  1 sibling, 0 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-26 16:36 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches

On 1/26/23 17:10, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> On 1/26/23 10:17, Tom de Vries wrote:
>>> ./gdb.base/jit-reader.exp:
>>>    require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
>>> ./gdb.arch/amd64-i386-address.exp:
>>>    require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target
> 
> Tom> And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?
> 
> Tom> Am I missing something here?
> 
> I am not sure.  Can you use 'gcc -m64' on an x86? 

AFAIK, no.

> Or could you have a
> 64-bit machine that advertises as i386 if userspace is mostly 32-bit?

I think that could be, but AFAIU, is_lp64_target would be false for such 
a setup.

Thanks,
- Tom

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 16:10         ` Tom Tromey
  2023-01-26 16:36           ` Tom de Vries
@ 2023-01-26 16:38           ` Pedro Alves
  2023-01-26 17:08             ` Tom de Vries
  1 sibling, 1 reply; 15+ messages in thread
From: Pedro Alves @ 2023-01-26 16:38 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches; +Cc: Tom de Vries

On 2023-01-26 4:10 p.m., Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> On 1/26/23 10:17, Tom de Vries wrote:
>>> ./gdb.base/jit-reader.exp:
>>>   require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
>>> ./gdb.arch/amd64-i386-address.exp:
>>>   require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target
> 
> Tom> And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?
> 
> Tom> Am I missing something here?
> 
> I am not sure.  Can you use 'gcc -m64' on an x86?  

Yeah, you can.  CodeSourcery toolchains used to be like that back in the day -- 32-bit
hosted, so the target triplet indicated 32-bit, but you could use -m64 for 64-bit. 
No clue what they do nowadays.

Pedro Alves

> Or could you have a
> 64-bit machine that advertises as i386 if userspace is mostly 32-bit?



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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 16:38           ` Pedro Alves
@ 2023-01-26 17:08             ` Tom de Vries
  2023-01-26 18:25               ` Tom Tromey
  2023-01-26 18:34               ` Pedro Alves
  0 siblings, 2 replies; 15+ messages in thread
From: Tom de Vries @ 2023-01-26 17:08 UTC (permalink / raw)
  To: Pedro Alves, Tom Tromey, Tom de Vries via Gdb-patches

On 1/26/23 17:38, Pedro Alves wrote:
> On 2023-01-26 4:10 p.m., Tom Tromey wrote:
>>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Tom> On 1/26/23 10:17, Tom de Vries wrote:
>>>> ./gdb.base/jit-reader.exp:
>>>>    require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
>>>> ./gdb.arch/amd64-i386-address.exp:
>>>>    require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target
>>
>> Tom> And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?
>>
>> Tom> Am I missing something here?
>>
>> I am not sure.  Can you use 'gcc -m64' on an x86?
> 
> Yeah, you can.  CodeSourcery toolchains used to be like that back in the day -- 32-bit
> hosted, so the target triplet indicated 32-bit, but you could use -m64 for 64-bit.
> No clue what they do nowadays.

Ah, that's interesting, thanks.

So, perhaps then you could indeed end up with is_lp64_target == true on 
an i?86 (by using target board unix/-m64).

But assuming you would end up with a complete 64-bit executable, you 
still wouldn't been able to run it on the 32-bit target, so I think it's 
a corner-case that doesn't prevent us from dropping the i?86 test here.

Thanks,
- Tom

> 
> Pedro Alves
> 
>> Or could you have a
>> 64-bit machine that advertises as i386 if userspace is mostly 32-bit?
> 
> 

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 17:08             ` Tom de Vries
@ 2023-01-26 18:25               ` Tom Tromey
  2023-01-26 18:34               ` Pedro Alves
  1 sibling, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2023-01-26 18:25 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Pedro Alves, Tom Tromey, Tom de Vries

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> But assuming you would end up with a complete 64-bit executable, you
Tom> still wouldn't been able to run it on the 32-bit target, so I think
Tom> it's a corner-case that doesn't prevent us from dropping the i?86 test
Tom> here.

I wonder how many tests are never run.  I imagine some of those gdb.arch
tests haven't been run in years.  It seems possible that we could even
have some that can't be run -- like, rely on some target we've deleted.

Tom

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

* Re: [pushed] [gdb/testsuite] Add and use is_x86_64_m64_target
  2023-01-26 17:08             ` Tom de Vries
  2023-01-26 18:25               ` Tom Tromey
@ 2023-01-26 18:34               ` Pedro Alves
  1 sibling, 0 replies; 15+ messages in thread
From: Pedro Alves @ 2023-01-26 18:34 UTC (permalink / raw)
  To: Tom de Vries, Tom Tromey, Tom de Vries via Gdb-patches

On 2023-01-26 5:08 p.m., Tom de Vries via Gdb-patches wrote:
> On 1/26/23 17:38, Pedro Alves wrote:
>> On 2023-01-26 4:10 p.m., Tom Tromey wrote:
>>>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>>>
>>> Tom> On 1/26/23 10:17, Tom de Vries wrote:
>>>>> ./gdb.base/jit-reader.exp:
>>>>>    require {is_any_target "i?86-*-*" "x86_64-*-*"} is_lp64_target
>>>>> ./gdb.arch/amd64-i386-address.exp:
>>>>>    require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target
>>>
>>> Tom> And, doesn't is_lp64_target imply that we're not on an "i?86-*-*" ?
>>>
>>> Tom> Am I missing something here?
>>>
>>> I am not sure.  Can you use 'gcc -m64' on an x86?
>>
>> Yeah, you can.  CodeSourcery toolchains used to be like that back in the day -- 32-bit
>> hosted, so the target triplet indicated 32-bit, but you could use -m64 for 64-bit.
>> No clue what they do nowadays.
> 
> Ah, that's interesting, thanks.
> 
> So, perhaps then you could indeed end up with is_lp64_target == true on an i?86 (by using target board unix/-m64).

Right.

> 
> But assuming you would end up with a complete 64-bit executable, you still wouldn't been able to run it on the 32-bit target, so I think it's a corner-case that doesn't prevent us from dropping the i?86 test here.

Don't know whether that's true on all operating systems.

I may be misremembering -- it may be that gdb was actually built as 64-bit,
but with the toolchain configured to target 32-bit by default (and thus with 32-bit triplet).
In that case, then debugging would work.

See:

  https://sourceware.org/pipermail/gdb-patches/2009-April/064685.html

"x86 -m64" is also why is_amd64_regs_target also runs the test for [istarget "i?86-*"]:

 # Return 1 if target has x86_64 registers - either amd64 or x32.
 # x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
 # just from the target string.
 gdb_caching_proc is_amd64_regs_target {
     if {![istarget "x86_64-*-*"] && ![istarget "i?86-*"]} {
 	return 0
     }

Pedro Alves

> 
> Thanks,
> - Tom
> 
>>
>> Pedro Alves
>>
>>> Or could you have a
>>> 64-bit machine that advertises as i386 if userspace is mostly 32-bit?
>>
>>


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

end of thread, other threads:[~2023-01-26 18:34 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
2023-01-25 20:06 ` [RFC 1/3] [gdb/contrib] Add refactor.py Tom de Vries
2023-01-25 20:06 ` [RFC 2/3] [gdb/contrib] Add refactor_require.py Tom de Vries
2023-01-25 20:06 ` [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target Tom de Vries
2023-01-25 21:25   ` Tom Tromey
2023-01-26  9:17     ` [pushed] " Tom de Vries
2023-01-26 15:48       ` Tom de Vries
2023-01-26 16:10         ` Tom Tromey
2023-01-26 16:36           ` Tom de Vries
2023-01-26 16:38           ` Pedro Alves
2023-01-26 17:08             ` Tom de Vries
2023-01-26 18:25               ` Tom Tromey
2023-01-26 18:34               ` Pedro Alves
2023-01-25 21:26 ` [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom Tromey
2023-01-26  9:30   ` Tom de Vries

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).