[PATCH v4 2/4] gdb: testsuite: add new gdb_attach to check "attach" command

Simon Marchi simon.marchi@polymtl.ca
Mon Mar 21 15:00:25 GMT 2022


On 2022-03-18 22:11, Tiezhu Yang wrote:
> This commit adds new gdb_attach to centralize the failure checking of
> "attach" command. Return 0 if attach failed, otherwise return 1.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  gdb/testsuite/lib/gdb.exp | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 89dcd0a..149a1c3 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5111,6 +5111,30 @@ proc can_spawn_for_attach { } {
>      return 1
>  }
>  
> +# Centralize the failure checking of "attach" command.
> +# Return 0 if attach failed, otherwise return 1.
> +
> +proc gdb_attach { testpid args } {
> +    parse_args {
> +	{pattern ""}
> +    }
> +
> +    if { [llength $args] != 0 } {
> +	error "Unexpected arguments: $args"
> +    }
> +
> +    gdb_test_multiple "attach $testpid" "attach" {
> +	-re -wrap "Attaching to.*ptrace: Operation not permitted\\." {
> +	    unsupported "$gdb_test_name (Operation not permitted)"
> +	    return 0
> +	}
> +	-re -wrap "$pattern" {
> +	    pass $gdb_test_name
> +	    return 1
> +	}
> +    }
> +}

I guess we need a "return 0" at the end of the function, in case the test does fail?

Simon


More information about the Gdb-patches mailing list