From patchwork Fri Jul 13 13:52:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Franco de Carvalho X-Patchwork-Id: 28376 Received: (qmail 100630 invoked by alias); 13 Jul 2018 13:53:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 100440 invoked by uid 89); 13 Jul 2018 13:53:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=2* X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jul 2018 13:53:38 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6DDnIx6034875 for ; Fri, 13 Jul 2018 09:53:37 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k6v58khf6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 13 Jul 2018 09:53:37 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jul 2018 07:53:36 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 13 Jul 2018 07:53:33 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6DDrUbR25952502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Jul 2018 06:53:31 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA44ABE059; Fri, 13 Jul 2018 07:53:30 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79D65BE05A; Fri, 13 Jul 2018 07:53:30 -0600 (MDT) Received: from pedro.localdomain (unknown [9.85.180.127]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 13 Jul 2018 07:53:30 -0600 (MDT) Received: by pedro.localdomain (Postfix, from userid 1000) id 16B3F3C04B8; Fri, 13 Jul 2018 10:53:25 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com, edjunior@gmail.com Subject: [PATCH 12/17] [PowerPC] Add tests for TAR Date: Fri, 13 Jul 2018 10:52:21 -0300 In-Reply-To: <20180713135226.2321-1-pedromfc@linux.ibm.com> References: <20180713135226.2321-1-pedromfc@linux.ibm.com> x-cbid: 18071313-0004-0000-0000-00001462CF4E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009363; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01060763; UDB=6.00544525; IPR=6.00838681; MB=3.00022128; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-13 13:53:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071313-0005-0000-0000-00008812F5E4 Message-Id: <20180713135226.2321-13-pedromfc@linux.ibm.com> This patch adds a testcase for GDB access to the Target Address Register. gdb/testsuite/ChangeLog: YYYY-MM-DD Pedro Franco de Carvalho * gdb.arch/powerpc-tar.c: New file. * gdb.arch/powerpc-tar.exp: New file. --- gdb/testsuite/gdb.arch/powerpc-tar.c | 33 ++++++++++ gdb/testsuite/gdb.arch/powerpc-tar.exp | 115 +++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.c create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.exp diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.c b/gdb/testsuite/gdb.arch/powerpc-tar.c new file mode 100644 index 0000000000..8e545b2ba3 --- /dev/null +++ b/gdb/testsuite/gdb.arch/powerpc-tar.c @@ -0,0 +1,33 @@ +/* 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 . */ + +int main (void) +{ + void * target1 = &&target1_l; + void * target2 = &&target2_l; + asm volatile ("mtspr 815,%0" : : "r" (target1) : ); + + /* Branch always to TAR. */ + asm volatile ("bctar 20,0,0"); // marker + + target2_l: + asm volatile ("nop"); // marker 2 + target1_l: + asm volatile ("nop"); + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.exp b/gdb/testsuite/gdb.arch/powerpc-tar.exp new file mode 100644 index 0000000000..f3c77a960e --- /dev/null +++ b/gdb/testsuite/gdb.arch/powerpc-tar.exp @@ -0,0 +1,115 @@ +# 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 . + +# This file is part of the gdb testsuite. + +# Test access to special purpose register TAR. + +if {![istarget "powerpc*-*-linux*"]} then { + verbose "Skipping PowerPC test for the TAR register." + return +} + +standard_testfile .c + +if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { + return -1 +} + +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 + +runto_main + +if {![check_register_access "tar"]} { + return +} + +# Do one pass to check if TAR is usable, system +# software can prevent it from being used. +proc tar_available {} { + global gdb_prompt + global inferior_exited_re + + set test "TAR 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 {![tar_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" + +set target1 [get_hexadecimal_valueof "target1" -1] +set tar [get_hexadecimal_valueof "\$tar" -2] + +set test "TAR value from mtspr" + +if {${target1} == ${tar}} { + pass $test +} else { + fail $test +} + +set target2 [get_hexadecimal_valueof "target2" -1] + +if {$target2 == -1} { + fail "Could not get value of label2" + return +} + +gdb_test_no_output "set \$tar = $target2" + +set bp_line [gdb_get_line_number "marker 2"] + +gdb_breakpoint ${srcfile}:${bp_line} + +gdb_continue_to_breakpoint "continue to new target address" ".*marker 2.*"