From patchwork Fri Mar 4 10:44:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 11192 Received: (qmail 119994 invoked by alias); 4 Mar 2016 10:45:00 -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 119616 invoked by uid 89); 4 Mar 2016 10:45:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sig, alarm X-HELO: mail-pa0-f66.google.com Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 04 Mar 2016 10:44:54 +0000 Received: by mail-pa0-f66.google.com with SMTP id gc2so2225570pab.0 for ; Fri, 04 Mar 2016 02:44:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=LtYgkh8UiWpoyV3wO6VBL8DPi1dJJ9oDigTJU6RlNgI=; b=Jv8CEIeCFWPheUVirV41mZNx9qVS5pD1ojIgGqvZq8aQ3IUfknYodMD8nB46mbkrpA aydyI4RZWkd1Pun6UjN3rAS0ej4szqgyuIiZGgkn/YADYnQQek9rfaL97spPtokJJRT1 lOVc9v2u05pwrnosdTPRFWKJms28pd5KdrAT2CyltFw1WH7FkYi5nImV4JtaOBndRhhI IalEHf5PNZVR6jLqkeCtZl+eg8PrUhBeoOtPNrcPD5Drt/saUUItc0WWOV1Qpu/ZF4Mn AM80PUrVHS9mnDwKirzxaVOWnPPcX+0fuNOXMCtED0+ePY6UHNGX+WNwQN0qypN5ibBY rZJg== X-Gm-Message-State: AD7BkJJT/Kuk3WxmRL7KCQJbnefiFp4zyxsAAcz0+UmGBCOeO2ggwQU3XK99TnRN4UdKTQ== X-Received: by 10.66.225.177 with SMTP id rl17mr10958256pac.46.1457088292542; Fri, 04 Mar 2016 02:44:52 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id e20sm4604321pfd.4.2016.03.04.02.44.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Mar 2016 02:44:52 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 8/8] New test case gdb.base/branch-to-self.exp Date: Fri, 4 Mar 2016 10:44:36 +0000 Message-Id: <1457088276-1170-9-git-send-email-yao.qi@linaro.org> In-Reply-To: <1457088276-1170-1-git-send-email-yao.qi@linaro.org> References: <1457088276-1170-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes gdb/testsuite: 2016-03-02 Yao Qi * gdb.base/branch-to-self.c: New file. * gdb.base/branch-to-self.exp: New file. --- gdb/testsuite/gdb.base/branch-to-self.c | 44 ++++++++++++++++++++ gdb/testsuite/gdb.base/branch-to-self.exp | 67 +++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 gdb/testsuite/gdb.base/branch-to-self.c create mode 100644 gdb/testsuite/gdb.base/branch-to-self.exp diff --git a/gdb/testsuite/gdb.base/branch-to-self.c b/gdb/testsuite/gdb.base/branch-to-self.c new file mode 100644 index 0000000..c2ec564 --- /dev/null +++ b/gdb/testsuite/gdb.base/branch-to-self.c @@ -0,0 +1,44 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 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 . */ + +#include +#include +#include + +#if defined(__arm__) || defined(__aarch64__) +#define BRANCH_INSN "b" +#elif defined(__x86_64__) || defined(__i386__) +#define BRANCH_INSN "jmp" +#else +#endif + +volatile int counter = 0; + +static void +handler (int sig) +{ + counter = 5; +} + +int +main (void) +{ + signal (SIGALRM, handler); + alarm (5); + + asm (".Lhere: " BRANCH_INSN " .Lhere"); /* loop-line */ +} diff --git a/gdb/testsuite/gdb.base/branch-to-self.exp b/gdb/testsuite/gdb.base/branch-to-self.exp new file mode 100644 index 0000000..c4b5458 --- /dev/null +++ b/gdb/testsuite/gdb.base/branch-to-self.exp @@ -0,0 +1,67 @@ +# This testcase is part of GDB, the GNU debugger. +# +# Copyright 2016 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 . + +standard_testfile + +if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] == -1 } { + return -1 +} + +with_test_prefix "single-step" { + global testfile + + clean_restart ${testfile} + if ![runto_main] { + return -1 + } + set line_num [gdb_get_line_number "loop-line" ${testfile}.c] + + gdb_test "break ${testfile}.c:${line_num}" + gdb_continue_to_breakpoint "hit breakpoint" + gdb_test "si" ".*${testfile}.c:${line_num}.*" +} + +with_test_prefix "break-cond" { + global testfile + + foreach_with_prefix side {"host" "target"} { + + clean_restart ${testfile} + + if ![runto_main] { + return -1 + } + + set test "set breakpoint condition-evaluation $side" + gdb_test_multiple $test $test { + -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" { + # Target doesn't support breakpoint condition + # evaluation on its side. Skip the test. + continue + } + -re "^$test\r\n$gdb_prompt $" { + } + } + + set line_num [gdb_get_line_number "loop-line" ${testfile}.c] + gdb_test "break ${testfile}.c:${line_num} if counter > 3" + + gdb_continue_to_breakpoint "continue to break" + + gdb_test "p counter" ".* = 5" + } +}