From: Luis Machado <luis.machado@linaro.org>
To: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>,
Simon Marchi <simark@simark.ca>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "alan.hayward@arm.com" <alan.hayward@arm.com>
Subject: Re: [PATCH 2/2][AArch64] Test handling of additional brk instruction patterns
Date: Tue, 14 Jan 2020 13:59:00 -0000 [thread overview]
Message-ID: <68e22906-38b2-86f4-b1b9-bff20b52d0c6@linaro.org> (raw)
In-Reply-To: <BYAPR11MB3030A0EBC8F50F7B7B0F2081C4340@BYAPR11MB3030.namprd11.prod.outlook.com>
On 1/14/20 5:03 AM, Aktemur, Tankut Baris wrote:
> On Tuesday, January 14, 2020 5:25 AM, Simon Marchi wrote:
>> On 2020-01-13 12:25 p.m., Luis Machado wrote:
>>> 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-13 Luis Machado <luis.machado@linaro.org>
>>>
>>> * 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 | 30 +++++++++
>>> .../gdb.arch/aarch64-brk-patterns.exp | 67 +++++++++++++++++++
>>> 2 files changed, 97 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..ccf9a35a94
>>> --- /dev/null
>>> +++ b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.c
>>> @@ -0,0 +1,30 @@
>>> +/* 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 <http://www.gnu.org/licenses/>. */
>>> +
>>> +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..3532a0df95
>>> --- /dev/null
>>> +++ b/gdb/testsuite/gdb.arch/aarch64-brk-patterns.exp
>>> @@ -0,0 +1,67 @@
>>> +# 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 <http://www.gnu.org/licenses/>.
>>> +#
>>> +# 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] {
>
> I'm not aware of a common convention of use of braces and spaces, but adding braces
> as in {![runto_main]} and removing the spaces after/before the opening/closing braces
> in { [prepare_for_testing...] } above could make the use more consistent within the
> file.
>
That's fair. I've fixed it now to make it consistent.
>>> + untested "could not run to main"
>>> + return -1
>>> +}
>>> +
>>> +set keep_going 1
>>> +set count 0
>>> +set old_timeout $timeout
>>> +set timeout 10
>>> +
>>> +while { $keep_going } {
>>> +
>>> + set test "brk instruction $count causes SIGTRAP"
>>> +
>>> + # Continue to next program breakpoint instruction.
>>> + gdb_test_multiple "continue" $test {
>>> + -re "Program received signal SIGTRAP, Trace/breakpoint trap.*$gdb_prompt $" {
>>> + pass $test
>>> +
>>> + # 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"
>>> + }
>>> + -re "exited normally.*$gdb_prompt $" {
>>> + set keep_going 0
>>> + }
>>> + timeout {
>>> + fail $test
>>> + set keep_going 0
>>> + }
>>> + }
>>> + set count [expr "$count + 1"]
>
> A minor thing. This could be simplified as
>
> incr count
>
Fixed as well. Thanks!
next prev parent reply other threads:[~2020-01-14 13:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 17:25 [PATCH 0/2,v2][AArch64]Handle " Luis Machado
2020-01-13 17:25 ` [PATCH 1/2][AArch64] Recognize more program breakpoint patterns Luis Machado
2020-01-13 17:30 ` [PATCH 2/2][AArch64] Test handling of additional brk instruction patterns Luis Machado
2020-01-14 5:03 ` Simon Marchi
2020-01-14 13:45 ` Luis Machado
2020-01-14 15:37 ` Simon Marchi
[not found] ` <BYAPR11MB3030A0EBC8F50F7B7B0F2081C4340@BYAPR11MB3030.namprd11.prod.outlook.com>
2020-01-14 13:59 ` Luis Machado [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-12-23 17:34 [PATCH] [AArch64] Recognize more program breakpoint patterns Luis Machado
2020-01-13 17:03 ` [PATCH 1/2] " Luis Machado
2020-01-13 17:06 ` [PATCH 2/2] [AArch64] Test handling of additional brk instruction patterns Luis Machado
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=68e22906-38b2-86f4-b1b9-bff20b52d0c6@linaro.org \
--to=luis.machado@linaro.org \
--cc=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--cc=tankut.baris.aktemur@intel.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