From patchwork Wed Jan 29 14:09:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 37607 Received: (qmail 60715 invoked by alias); 29 Jan 2020 14:10:12 -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 60334 invoked by uid 89); 29 Jan 2020 14:10:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f194.google.com Received: from mail-qk1-f194.google.com (HELO mail-qk1-f194.google.com) (209.85.222.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Jan 2020 14:09:58 +0000 Received: by mail-qk1-f194.google.com with SMTP id s187so17091705qke.8 for ; Wed, 29 Jan 2020 06:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=DVB5XFApQ3pr5eyGMGK8eCXbttI+7SCqcpTvymqWiC0=; b=Do71hhNWrgasP01IN6rOFlKa49uR/+asKPtrNAmOoZ8wzDaZ0ymL2CelT6K8CFi4kX Z5Hu5svN8q0ib+ojBDNms+gv3RysK7mq+uolw3k9p3bJEUJKC4i4mrbENI8cHyOS0lWW s97BgcuwicYcQAxMBkZww/Mrk6A0tx0EFc6N8sdeED2CkLwYK+V+NwGtGd0qZnMexQ9X zzCRyv1vtRsvJRafBbadhWfqMd2WYutVKrxUAfVRElr2P6WGHiqNdvUS2ELzSGnIcTgq tTpWn5HCMH9cSZ5IVgf3tnoYoMNwO9bHdT7D8U9/vV4B6KCGP2a4lMYBY1jJqtog05zE YGsg== Return-Path: Received: from [192.168.0.185] ([191.251.164.76]) by smtp.gmail.com with ESMTPSA id 64sm999700qkk.123.2020.01.29.06.09.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2020 06:09:53 -0800 (PST) Subject: Re: [PATCH 2/2, v3] [AArch64] Test handling of additional brk instruction patterns From: Luis Machado To: Simon Marchi , gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com, alan.hayward@arm.com References: <20200115115137.17771-1-luis.machado@linaro.org> <20200115115137.17771-3-luis.machado@linaro.org> <99a220e1-36b2-0e31-ceb7-3880bf42263c@linaro.org> <23182c46-7e3c-f7e8-a91c-c8cc1049bdcd@linaro.org> Message-ID: <5998efd0-8cc3-afbd-ec58-4e5c4e54842b@linaro.org> Date: Wed, 29 Jan 2020 11:09:49 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <23182c46-7e3c-f7e8-a91c-c8cc1049bdcd@linaro.org> X-IsSubscribed: yes On 1/29/20 11:04 AM, Luis Machado wrote: > > > On 1/29/20 11:01 AM, Simon Marchi wrote: >> On 2020-01-29 6:30 a.m., Luis Machado wrote: >>>>> +# Number of expected SIGTRAP's to get.  This needs to be kept in sync >>>>> +# with the source file. >>>>> +set expected_traps 3 >>>>> +set keep_going 1 >>>>> +set count 0 >>>>> +set old_timeout $timeout >>>>> +set timeout 10 >>>> >>>> Any reason you are changing the timeout?  There is nothing in the >>>> test that >>>> looks like it would take time. >>>> >>> >>> If GDB doesn't support one of these instructions, it will be caught in >>> an infinite loop. The reduced timeout will prevent a long wait time >>> until we bail out. >> >> Ok.  The worry I have with it is that if the target board has raised >> the timeout >> on purpose, because it's testing with a slow target/link/emulator, >> then this will >> cancel it.  In this case I'd just leave the timeout as it is. >> Normally, GDB won't >> be broken for this test case, so it won't matter. >> >> Moreover, the timeout here on my x86 machine is 10 seconds by >> default.  I just checked >> on an AArch64 box on the compile farm, it's 10 there too.  So in which >> case was it >> useful to set it to 10? >> > > Interesting. In my mind the default was from 30 to 60. Maybe that has > changed over the years. If the boards are free to set it, then that is > more desirable. > > I'll let it be then. Here's the updated patch. From a2814e51d2dbec1130cf53b24a3f71041791fe69 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Mon, 13 Jan 2020 12:31:01 -0300 Subject: [PATCH] [AArch64] Test handling of additional brk instruction patterns New in v5: - Use gdb_test_name for gdb_test_multiple. - Use gdb_assert. - Verify count matches the expected sigtraps exactly. New in v4: - Fix formatting nit in gdb/testsuite/gdb.arch/aarch64-brk-patterns.c. New in v3: - Minor formatting and code cleanups. - Added count check to validate number of brk SIGTRAP's. - Moved count to SIGTRAP check conditional block. This test exercises the previous patch's code and makes sure GDB can properly get a SIGTRAP from various brk instruction patterns. GDB needs to be able to see the program exiting normally. If GDB doesn't support the additional brk instructions, we will see timeouts. We bail out with the first timeout since we won't be able to step through the program breakpoint anyway, so it is no use carrying on. gdb/testsuite/ChangeLog: 2020-01-29 Luis Machado * gdb.arch/aarch64-brk-patterns.c: New source file. * gdb.arch/aarch64-brk-patterns.exp: New test. --- gdb/testsuite/gdb.arch/aarch64-brk-patterns.c | 31 +++++++++ .../gdb.arch/aarch64-brk-patterns.exp | 69 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-brk-patterns.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp diff --git a/gdb/testsuite/gdb.arch/aarch64-brk-patterns.c b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.c new file mode 100644 index 0000000000..920ba8e2cb --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.c @@ -0,0 +1,31 @@ +/* This file is part of GDB, the GNU debugger. + + Copyright 2020 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) +{ + /* Dummy instruction just so GDB doesn't stop at the first breakpoint + instruction. */ + __asm __volatile ("nop\n\t"); + + /* Multiple BRK instruction patterns. */ + __asm __volatile ("brk %0\n\t" ::"n"(0x0)); + __asm __volatile ("brk %0\n\t" ::"n"(0x900 + 0xf)); + __asm __volatile ("brk %0\n\t" ::"n"(0xf000)); + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp new file mode 100644 index 0000000000..5cb55da219 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp @@ -0,0 +1,69 @@ +# Copyright 2020 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 if GDB stops at various BRK instruction patterns inserted into +# the code. + +if {![is_aarch64_target]} { + verbose "Skipping ${gdb_test_file_name}." + return +} + +standard_testfile +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { + return -1 +} + +if {![runto_main]} { + untested "could not run to main" + return -1 +} + +# Number of expected SIGTRAP's to get. This needs to be kept in sync +# with the source file. +set expected_traps 3 +set keep_going 1 +set count 0 + +# Make sure we have a lower timeout in case GDB doesn't support a particular +# instruction. Such instruction will cause GDB to loop infinitely. +while {$keep_going} { + # Continue to next program breakpoint instruction. + gdb_test_multiple "continue" "brk instruction $count causes SIGTRAP" { + -re "Program received signal SIGTRAP, Trace/breakpoint trap.*$gdb_prompt $" { + pass $gdb_test_name + + # Insert a breakpoint at the program breakpoint instruction so + # GDB can step over it. + gdb_test "break" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ + "insert breakpoint at brk instruction $count" + incr count + } + # We've reached the end of the test. + -re "exited normally.*$gdb_prompt $" { + set keep_going 0 + } + timeout { + fail $gdb_test_name + set keep_going 0 + } + } +} + +# Verify we stopped at the expected number of SIGTRAP's. +gdb_assert {$count == $expected_traps} "all brk instructions triggered" -- 2.17.1