Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
To: gdb-patches@sourceware.org
Cc: uweigand@de.ibm.com, edjunior@gmail.com
Subject: [PATCH 08/17] [PowerPC] Add tests for PPR and DSCR
Date: Fri, 13 Jul 2018 13:53:00 -0000	[thread overview]
Message-ID: <20180713135226.2321-9-pedromfc@linux.ibm.com> (raw)
In-Reply-To: <20180713135226.2321-1-pedromfc@linux.ibm.com>

This patch adds a testcase for GDB access to the Program Priorty
Register and Data Stream Control Register.

gdb/ChangeLog:
YYYY-MM-DD  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.arch/powerpc-ppr-dscr.c: New file.
	* gdb.arch/powerpc-ppr-dscr.exp: New file.
---
 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c   |  32 ++++++++
 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp | 110 ++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp

diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c
new file mode 100644
index 0000000000..b53bf0d4d3
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c
@@ -0,0 +1,32 @@
+/* This test is part of GDB, the GNU debugger.
+
+   Copyright 2018 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/>.  */
+
+int main (void)
+{
+  /* Set Load Stream Disable bit in DSCR.  */
+  unsigned long dscr = 0x20;
+
+  /* This is the non-privileged SPR number to access DSCR,
+     available since isa 207.  */
+  asm volatile ("mtspr 3,%0" : : "r" (dscr));
+
+  /* Set PPR to low priority (010 in bits 11:13, or
+     0x0008000000000000).  */
+  asm volatile ("or 1,1,1");
+  asm volatile ("nop"); // marker
+  asm volatile ("nop");
+}
diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
new file mode 100644
index 0000000000..14cfa344bd
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
@@ -0,0 +1,110 @@
+# Copyright 2018 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/>.
+
+# This file is part of the gdb testsuite.
+
+# Test access to special purpose registers PPR and DSCR.
+
+if {![istarget "powerpc*-*-linux*"]} then {
+    verbose "Skipping PowerPC test for PPR and DSCR registers."
+    return
+}
+
+standard_testfile .c
+
+if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
+    return
+}
+
+proc check_register_access { regname } {
+    global gdb_prompt
+
+    set test "$regname register access"
+    gdb_test_multiple "info reg $regname" "$test" {
+	-re "Invalid register.*\r\n$gdb_prompt $" {
+	    unsupported "$test"
+	    return 0
+	}
+	-re "\r\n$regname.*\r\n$gdb_prompt $" {
+	    pass "$test"
+	    return 1
+	}
+    }
+    return 0
+}
+
+clean_restart $binfile
+
+if ![runto_main] {
+    return
+}
+
+if {![check_register_access "ppr"]} {
+    return
+}
+
+if {![check_register_access "dscr"]} {
+    return
+}
+
+# Do one pass to check if the instructions in our test programs are
+# available to this processor (e.g. mtspr 3, RS for accessing DSCR).
+proc ppr_dscr_available {} {
+    global gdb_prompt
+    global inferior_exited_re
+
+    set test "PPR/DSCR available to inferior"
+    gdb_test_multiple "continue" "" {
+	-re "Illegal instruction.*\r\n$gdb_prompt $" {
+	    unsupported "$test"
+	    return 0
+	}
+	-re "$inferior_exited_re normally.*$gdb_prompt $" {
+	    pass "$test"
+	    return 1
+	}
+    }
+    return 0
+}
+
+if {![ppr_dscr_available]} {
+    return
+}
+
+# Now do the actual test
+clean_restart $binfile
+
+runto_main
+
+set bp_line [gdb_get_line_number "marker"]
+
+gdb_breakpoint ${srcfile}:${bp_line}
+
+gdb_continue_to_breakpoint "continue to marker"
+
+# At the breakpoint the inferior should have set the
+# registers to these expected values.
+gdb_test "info reg dscr" "dscr.*0x0*20\[ \t\]+.*"
+gdb_test "info reg ppr" "ppr.*0x0*8000000000000\[ \t\]+.*"
+
+# Set Store Stream Enable in DSCR and set PPR to the medium-low
+# priority.
+gdb_test_no_output "set \$dscr = 0x8"
+gdb_test_no_output "set \$ppr = 0xC000000000000"
+
+gdb_test "stepi" "asm.*"
+
+gdb_test "info reg dscr" "dscr.*0x0*8+\[ \t\]+.*"
+gdb_test "info reg ppr" "ppr.*0x0*\[cC\]000000000000\[ \t\]+.*"
-- 
2.13.6


  parent reply	other threads:[~2018-07-13 13:53 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 13:53 [PATCH 00/17] GDB support for more powerpc registers on linux Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 03/17] [PowerPC] Fix indentation in arch/ppc-linux-common.c Pedro Franco de Carvalho
2018-07-13 15:18   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 13/17] [PowerPC] Add support for HTM registers Pedro Franco de Carvalho
2018-07-13 16:24   ` Ulrich Weigand
2018-07-13 18:16     ` Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 09/17] [PowerPC] Add support for TAR Pedro Franco de Carvalho
2018-07-13 15:30   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 10/17] [PowerPC] Add record/replay " Pedro Franco de Carvalho
2018-07-13 15:31   ` Ulrich Weigand
2018-07-13 13:53 ` Pedro Franco de Carvalho [this message]
2018-07-13 15:27   ` [PATCH 08/17] [PowerPC] Add tests for PPR and DSCR Ulrich Weigand
2018-07-13 13:53 ` [PATCH 12/17] [PowerPC] Add tests for TAR Pedro Franco de Carvalho
2018-07-13 15:33   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 07/17] [PowerPC] Add gdbserver support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:26   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 02/17] [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c Pedro Franco de Carvalho
2018-07-13 15:17   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 14/17] [PowerPC] Add gdbserver support for HTM registers Pedro Franco de Carvalho
2018-07-13 16:26   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 01/17] [PowerPC] Simplify rs6000_pseudo_register_reggroup_p Pedro Franco de Carvalho
2018-07-13 15:17   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 04/17] [PowerPC] Refactor have_ initializers in rs6000-tdep.c Pedro Franco de Carvalho
2018-07-13 15:19   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 06/17] [PowerPC] Add record/replay support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:25   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 16/17] [PowerPC] Add support for EBB and PMU registers Pedro Franco de Carvalho
2018-07-13 16:38   ` Ulrich Weigand
2018-07-13 18:23     ` Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 05/17] [PowerPC] Add support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:23   ` Ulrich Weigand
2018-07-13 14:23 ` [PATCH 15/17] [PowerPC] Add tests for HTM registers Pedro Franco de Carvalho
2018-07-13 16:27   ` Ulrich Weigand
2018-07-13 14:49 ` [PATCH 17/17] [PowerPC] Add gdbserver support for EBB and PMU registers Pedro Franco de Carvalho
2018-07-13 16:40   ` Ulrich Weigand
2018-07-13 18:29     ` Pedro Franco de Carvalho
2018-07-13 15:33 ` [PATCH 11/17] [PowerPC] Add gdbserver support for TAR Pedro Franco de Carvalho
2018-07-13 15:33   ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180713135226.2321-9-pedromfc@linux.ibm.com \
    --to=pedromfc@linux.ibm.com \
    --cc=edjunior@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox