From patchwork Wed Oct 7 09:26:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 8956 Received: (qmail 130010 invoked by alias); 7 Oct 2015 09:26:37 -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 129970 invoked by uid 89); 7 Oct 2015 09:26:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 07 Oct 2015 09:26:35 +0000 Received: by padhy16 with SMTP id hy16so16311934pad.1 for ; Wed, 07 Oct 2015 02:26:34 -0700 (PDT) X-Received: by 10.68.129.6 with SMTP id ns6mr53473069pbb.77.1444209994238; Wed, 07 Oct 2015 02:26:34 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (power-aix.osuosl.org. [140.211.15.154]) by smtp.gmail.com with ESMTPSA id xa4sm38490858pac.28.2015.10.07.02.26.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 02:26:33 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 01/11] More tests in gdb.arch/insn-reloc.c Date: Wed, 7 Oct 2015 10:26:15 +0100 Message-Id: <1444209985-15829-2-git-send-email-yao.qi@linaro.org> In-Reply-To: <1444209985-15829-1-git-send-email-yao.qi@linaro.org> References: <1444209985-15829-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch adds more tests in gdb.arch/insn-reloc.c to cover instruction BL and cover B.CON when CON is false. These new added tests can be used for displaced stepping too. gdb/testsuite: 2015-10-05 Yao Qi * gdb.arch/insn-reloc.c (can_relocate_bcond): Rename to ... (can_relocate_bcond_true): ... it. (can_relocate_bcond_false): New function. (foo): Likewise. (can_relocate_bl): Likewise. (testcases) [__aarch64__]: Add can_relocate_bcond_false and can_relocate_bl. --- gdb/testsuite/gdb.arch/insn-reloc.c | 50 ++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.arch/insn-reloc.c b/gdb/testsuite/gdb.arch/insn-reloc.c index c7148a2..dc6d8b6 100644 --- a/gdb/testsuite/gdb.arch/insn-reloc.c +++ b/gdb/testsuite/gdb.arch/insn-reloc.c @@ -159,7 +159,7 @@ can_relocate_b (void) */ static void -can_relocate_bcond (void) +can_relocate_bcond_true (void) { int ok = 0; @@ -469,6 +469,48 @@ can_relocate_ldr (void) else fail (); } + +/* Make sure we can relocate a B.cond instruction and condition is false. */ + +static void +can_relocate_bcond_false (void) +{ + int ok = 0; + + asm (" mov x0, #8\n" + " tst x0, #8\n" /* Clear the Z flag. */ + "set_point10:\n" /* Set tracepoint here. */ + " b.eq 0b\n" /* Condition is false. */ + " mov %[ok], #1\n" + " b 1f\n" + "0:\n" + " mov %[ok], #0\n" + "1:\n" + : [ok] "=r" (ok) + : + : "0", "cc"); + + if (ok == 1) + pass (); + else + fail (); +} + +static void +foo (void) +{ +} + +/* Make sure we can relocate a BL instruction. */ + +static void +can_relocate_bl (void) +{ + asm ("set_point11:\n" + " bl foo\n" + " bl pass\n"); /* Test that LR is updated correctly. */ +} + #endif /* Functions testing relocations need to be placed here. GDB will read @@ -482,7 +524,7 @@ static testcase_ftype testcases[] = { can_relocate_jump #elif (defined __aarch64__) can_relocate_b, - can_relocate_bcond, + can_relocate_bcond_true, can_relocate_cbz, can_relocate_cbnz, can_relocate_tbz, @@ -490,7 +532,9 @@ static testcase_ftype testcases[] = { can_relocate_adr_forward, can_relocate_adr_backward, can_relocate_adrp, - can_relocate_ldr + can_relocate_ldr, + can_relocate_bcond_false, + can_relocate_bl, #endif };