[PATCH v2] [gdb/testsuite] Handle ptrace operation not permitted in can_spawn_for_attach

Pedro Alves pedro@palves.net
Wed Apr 24 19:40:49 GMT 2024


On 2024-04-18 07:32, Tom de Vries wrote:
> When running the testsuite on a system with kernel.yama.ptrace_scope set to 1,
> we run into attach failures.
> 
> Fix this by recognizing "ptrace: Operation not permitted" in
> can_spawn_for_attach.
> 
> Tested on aarch64-linux.

I really don't like relying on "attach" 's behavior to decide whether to test attach.
It's an inversion of responsibilities.

can_spawn_for_attach means "can I spawn a process, such that I will attach to it later", a
simple atomic thing.

Also, with this change, it means, "can I spawn a process and does attaching to it work?"
So it ends up misnamed.

Someone tried to add something very much like this a while ago, and I objected then:

  https://inbox.sourceware.org/gdb-patches/e5f08136-fa4d-2f21-ff83-8adf4d3a158e@palves.net/

We ended up with gdb_attach, added in a7e6a19e87f3, which handles the "ptrace: Operation not permitted"
scenarios too.  Some testcases have meanwhile been converted to use gdb_attach, but there are more,
of course.  IMO we should continue that direction.  gdb_attach is not unlike "gdb_run_cmd" for example.

See also:

  https://inbox.sourceware.org/gdb-patches/3b845985-cbd4-4996-145e-14191338b095@polymtl.ca/

Pedro Alves



More information about the Gdb-patches mailing list