From: Pedro Alves <palves@redhat.com>
To: Alan Hayward <Alan.Hayward@arm.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: Re: [PATCH] gdbserver: When attaching, add process before lwps
Date: Fri, 25 Jan 2019 18:23:00 -0000 [thread overview]
Message-ID: <0e75277b-fa80-129d-e82b-3f854bb33124@redhat.com> (raw)
In-Reply-To: <20190125104834.2595-1-alan.hayward@arm.com>
On 01/25/2019 10:48 AM, Alan Hayward wrote:
> The recent BP/WP changes for AArch64 swapping the order in add_lwp()
> so that the process was added before the lwp. This was due to the lwp
> creation requiring the process data.
>
> This also needs changing in linux_attach().
>
> Fixes gdb.server/ext-attach.exp on Aarch64.
>
> (This regression was hidden due to the racy nature of the gdb.server
> tests - now they are no longer racy it'll be easier to spot. Also
> checked X86).
>
> gdb/gdbserver/ChangeLog:
>
> 2019-01-25 Alan Hayward <alan.hayward@arm.com>
>
> * linux-low.c (linux_attach): Add process before lwp.
> ---
> gdb/gdbserver/linux-low.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
> index 17cce24d76..1ab2cfb1eb 100644
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -1188,6 +1188,8 @@ linux_attach (unsigned long pid)
> ptid_t ptid = ptid_t (pid, pid, 0);
> int err;
>
> + proc = linux_add_process (pid, 1);
> +
> /* Attach to PID. We will check for other threads
> soon. */
> err = linux_attach_lwp (ptid);
> @@ -1198,8 +1200,6 @@ linux_attach (unsigned long pid)
> error ("Cannot attach to process %ld: %s", pid, reason.c_str ());
> }
>
> - proc = linux_add_process (pid, 1);
> -
This fails to consider the error conditions. That error call
visible above throws an exception.
- If GDBserver is already attached to the process, this will
create another process_info object for the already-attached
process, and leave it behind.
For this case, it would seem better to check whether we're
already attached to a given PID in common code, around
server.c:attach_inferior.
- If GDBserver isn't already attached, but the attach fails,
this will likewise leave a stale process_info object behind.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2019-01-25 18:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 10:48 Alan Hayward
2019-01-25 18:23 ` Pedro Alves [this message]
2019-02-01 11:20 ` Alan Hayward
[not found] ` <93ef0362-677a-4353-5942-d987a985e403@redhat.com>
2019-02-01 12:50 ` Pedro Alves
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=0e75277b-fa80-129d-e82b-3f854bb33124@redhat.com \
--to=palves@redhat.com \
--cc=Alan.Hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.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