public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug server/31554] gdbserver --once --multi mishandles run & attach failures
Date: Fri, 26 Apr 2024 20:24:12 +0000	[thread overview]
Message-ID: <bug-31554-4717-PVGljSsDEr@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31554-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31554

--- Comment #3 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1fc8dc2dccb4a224cdd1c3973c7a09a752aa95b

commit f1fc8dc2dccb4a224cdd1c3973c7a09a752aa95b
Author: Pedro Alves <pedro@palves.net>
Date:   Wed Apr 17 19:26:32 2024 +0100

    Fix "attach" failure handling with GDBserver

    This fixes the same issue as the previous patch, but for "attach"
    instead of "run".

    If attaching to a process with "attach" (vAttach packet) fails,
    GDBserver throws an error that escapes all the way to the top level.
    When an error escapes all the way like that, GDBserver interprets it
    as a disconnection, and either goes back to waiting for a new GDB
    connection, or exits, if --once was specified.

    Here's an example:

    On the GDB side:

     ...
     (gdb) tar extended-remote :9999
     ...
     Remote debugging using :9999
     (gdb) attach 1
     Attaching to process 1
     Attaching to process 1 failed
     (gdb)

    On the GDBserver side:

     $ gdbserver --once --multi :9999
     Listening on port 9999
     Remote debugging from host 127.0.0.1, port 37464
     gdbserver: Cannot attach to process 1: Operation not permitted (1)
     $   # gdbserver exited

    This is wrong, as we've connected with extended-remote/--multi.
    GDBserver should just report an error to vAttach, and continue
    connected to GDB, waiting for other commands.

    This commit fixes GDBserver by catching the error locally in
    handle_v_attach.

    Note we now let pid == 0 pass down to attach_inferior.  That is so we
    get a useful textual error message to report to GDB.

    This fixes a couple KFAILs in gdb.base/attach.exp.  Still, I thought
    it would be useful to add a new testcase specifically for this
    scenario, in case gdb.base/attach.exp is ever split and stops trying
    to attach again after a failed attach, with the same GDB session.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19558
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31554

    Change-Id: I25314c7e5f1435eff69cb84d57ecac13d8de3393
    Approved-By: Tom Tromey <tom@tromey.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-04-26 20:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 18:19 [Bug server/31554] New: " pedro at palves dot net
2024-03-25 18:20 ` [Bug server/31554] " pedro at palves dot net
2024-04-12 17:45 ` cvs-commit at gcc dot gnu.org
2024-04-26 20:24 ` cvs-commit at gcc dot gnu.org [this message]
2024-04-26 21:12 ` pedro at palves dot net

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=bug-31554-4717-PVGljSsDEr@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).