Re: [PATCH 13/31] Add test for stepping over clone syscall

Pedro Alves
2023-11-13T14:09:41Z

On 2023-06-07 18:42, Andrew Burgess wrote:
> Pedro Alves <pedro@palves.net> writes:

>> +++ b/gdb/testsuite/gdb.threads/stepi-over-clone.c
>> @@ -0,0 +1,90 @@
>> +/* This testcase is part of GDB, the GNU debugger.
>> +
>> + Copyright 2021-2022 Free Software Foundation, Inc.
>
> <sigh> lets see if we can land this in 2023!

Fixed. :-)

>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
>> @@ -0,0 +1,392 @@
>> +# Copyright 2021-2022 Free Software Foundation, Inc.
>
> Date range again.

Fixed.

>
>> +
>> +# 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/>.
>> +
>> +# Test performing a 'stepi' over a clone syscall instruction.
>> +
>> +# This test relies on us being able to spot syscall instructions in
>> +# disassembly output. For now this is only implemented for x86-64.
>> +if { ![istarget x86_64-*-* ] } {
>> + return
>> +}
>
> This will need updating to the new 'require' mechanism.

Done.

>
>> +
>> +standard_testfile
>> +
>> +if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
>> + {debug pthreads additional_flags=-static}] } {
>> + return
>> +}
>> +
>> +if {![runto_main]} {
>> + return
>> +}
>> +
>> +# Arrange to catch the 'clone' syscall, run until we catch the
>> +# syscall, and try to figure out the address of the actual syscall
>> +# instruction so we can place a breakpoint at this address.
>> +
>> +gdb_test_multiple "catch syscall clone" "" {
>> + -re "The feature \'catch syscall\' is not supported.*\r\n$gdb_prompt $" {
>> + set supported 0
>> + pass $gdb_test_name
>> + return
>
> I know the mistakes here are mine rather than yours, but ...
>
> ... the 'set supported 0' appears to be pointless. And given we are
> returning here due to some feature not being supported, I think we
> should drop the 'pass $gdb_test_name' and instead do something like
> 'unsupported "unable to catch clone syscall"' before the return.
>

I changed it to this:

gdb_test_multiple "catch syscall group:process" "catch process syscalls" {
-re "The feature \'catch syscall\' is not supported.*\r\n$gdb_prompt $" {
unsupported $gdb_test_name
return
}
-re ".*$gdb_prompt $" {
pass $gdb_test_name
}
}

... so we have the same message for unsupported/pass.

> Otherwise, LGTM.
>
> Reviewed-By: Andrew Burgess <aburgess@redhat.com>

Thanks!