public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add ISA 3.1 check to powerpc-plxv-norel.exp
@ 2021-06-23 18:32 Carl Love
  2021-06-24 15:50 ` Ulrich Weigand
  0 siblings, 1 reply; 2+ messages in thread
From: Carl Love @ 2021-06-23 18:32 UTC (permalink / raw)
  To: gdb-patches, Pedro Franco de Carvalho, Rogerio Alves,
	will schmidt, Ulrich Weigand
  Cc: cel

GDB maintainers:

The following patch adds a test for ISA 3.1 support to the powerpc-
plxv-norel.exp test.  This test will fail on illegal instruction on
hardware that does not support ISA 3.1.  The ISA test was added to
lib/gdb.exp to make it available for use with other tests.

The patch has been tested on Power 9 and Power 10.  Additionally, the
test was run as a remote test between two different machines.  The
patch worked as expected in all cases.

Please let me know if the patch is acceptable for GDB mainline. 
Thanks.

                    Carl Love


---------------------------------------------

This patch adds a file with the ISA 3.1 check.  The ISA 3.1 check is
added to the test to ensure the test is only run on ISA 3.1 or newer.

gdb/testsuite/ChangeLog
2021-06-23  Carl Love  <cel@us.ibm.com>

	* gdb.arch/powerpc-plxv-norel.exp: Add call to skip_power_isa_3_1_tests.
	* lib/gdb.exp(skip_power_isa_3_1_tests): New gdb_caching_proc test.
---
 .../gdb.arch/powerpc-plxv-nonrel.exp          |  4 +-
 gdb/testsuite/lib/gdb.exp                     | 47 +++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
index 08f1a379efb..446b2bdd39a 100644
--- a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
@@ -16,8 +16,8 @@
 # Test to see if gdb is properly single stepping over the
 # displaced plxv instruction.
 
-if { ![istarget powerpc*-*] } {
-    verbose "Skipping powerpc plxv test."
+if { ![istarget powerpc*-*] || [skip_power_isa_3_1_tests] } {
+    verbose "Skipping powerpc ISA 3.1 plxv test."
     return
 }
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f6686e19162..566ffad14fd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3068,6 +3068,53 @@ gdb_caching_proc skip_altivec_tests {
     return $skip_vmx_tests
 }
 
+# Run a test on the power target to see if it supports ISA 3.1 instructions
+gdb_caching_proc skip_power_isa_3_1_tests {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set me "skip_power_isa_3_1_tests"
+
+    # Compile a test program containing ISA 3.1 instructions.
+    set src {
+	int main() {
+	asm volatile ("pnop"); // marker
+		asm volatile ("nop");
+		return 0;
+	    }
+	}
+
+    if {![gdb_simple_compile $me $src executable ]} {
+        return 1
+    }
+
+    # No error message, compilation succeeded so now run it via gdb.
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$obj"
+    gdb_run_cmd
+    gdb_expect {
+        -re ".*Illegal instruction.*${gdb_prompt} $" {
+            verbose -log "\n$me Power ISA 3.1 hardware not detected"
+            set skip_power_isa_3_1_tests 1
+        }
+        -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+            verbose -log "\n$me: Power ISA 3.1 hardware detected"
+            set skip_power_isa_3_1_tests 0
+        }
+        default {
+          warning "\n$me: default case taken"
+            set skip_power_isa_3_1_tests 1
+        }
+    }
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me:  returning $skip_power_isa_3_1_tests" 2
+    return $skip_power_isa_3_1_tests
+}
+
 # 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.
 
-- 
2.27.0



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

* Re: [PATCH] Add ISA 3.1 check to powerpc-plxv-norel.exp
  2021-06-23 18:32 [PATCH] Add ISA 3.1 check to powerpc-plxv-norel.exp Carl Love
@ 2021-06-24 15:50 ` Ulrich Weigand
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Weigand @ 2021-06-24 15:50 UTC (permalink / raw)
  To: Carl Love
  Cc: gdb-patches, Pedro Franco de Carvalho, Rogerio Alves, will schmidt

On Wed, Jun 23, 2021 at 11:32:22AM -0700, Carl Love wrote:

> gdb/testsuite/ChangeLog
> 2021-06-23  Carl Love  <cel@us.ibm.com>
> 
> 	* gdb.arch/powerpc-plxv-norel.exp: Add call to skip_power_isa_3_1_tests.
> 	* lib/gdb.exp(skip_power_isa_3_1_tests): New gdb_caching_proc test.

This is OK.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

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

end of thread, other threads:[~2021-06-24 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 18:32 [PATCH] Add ISA 3.1 check to powerpc-plxv-norel.exp Carl Love
2021-06-24 15:50 ` Ulrich Weigand

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