From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] Improve vRun error reporting
Date: Tue, 13 Feb 2024 12:56:31 +0000 [thread overview]
Message-ID: <d74b5392-703c-450a-aab5-e19cc38b8381@palves.net> (raw)
In-Reply-To: <20240212200153.882582-3-pedro@palves.net>
Hi!
This conflicts with Alexandra's just-merged packet_check_result changes. I see she has some follow up
patches that would help me here. I will take a look at those. For the meantime, disregard this patch.
Pedro Alves
On 2024-02-12 20:01, Pedro Alves wrote:
> After the previous commit, if starting the inferior process with "run"
> (vRun packet) fails, GDBserver reports an error using the "E." verbose
> error packet. On the GDB side, however, GDB doesn't yet do anything
> with verbose error strings when handling vRun errors. This commit
> fixes that.
>
> This makes remote debugging output the same as native output, when
> possible, another small step in the "local/remote parity" project.
>
> E.g., before, against GNU/Linux GDBserver:
>
> (gdb) run
> Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox
> Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed
>
> After, against GNU/Linux GDBserver (same as native):
>
> (gdb) run
> Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox
> During startup program exited with code 126.
>
> Change-Id: Ib386f267522603f554b52a885b15229c9639e870
> ---
> gdb/remote.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index b58dbd4cb66..dca5add260a 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -2400,6 +2400,19 @@ add_packet_config_cmd (const unsigned int which_packet, const char *name,
> }
> }
>
> +/* Strings that starts with "E.", are verbose error messages, like
> + "E.ERROR_MESSAGE". If BUF is such an error message, return a
> + pointer to message after the period. Otherwise return NULL. */
> +
> +static const char *
> +verbose_error_message (const char *buf)
> +{
> + if (buf[0] == 'E' && buf[1] == '.')
> + return buf + 2;
> + else
> + return nullptr;
> +}
> +
> static enum packet_result
> packet_check_result (const char *buf)
> {
> @@ -2415,7 +2428,7 @@ packet_check_result (const char *buf)
>
> /* Always treat "E." as an error. This will be used for
> more verbose error messages, such as E.memtypes. */
> - if (buf[0] == 'E' && buf[1] == '.')
> + if (verbose_error_message (buf) != nullptr)
> return PACKET_ERROR;
>
> /* The packet may or may not be OK. Just assume it is. */
> @@ -10502,7 +10515,13 @@ remote_target::extended_remote_run (const std::string &args)
> case PACKET_UNKNOWN:
> return -1;
> case PACKET_ERROR:
> - if (remote_exec_file[0] == '\0')
> + /* If we have a verbose error message, print just that. This
> + makes remote debugging output the same as native output, when
> + possible. */
> + if (const char *msg = verbose_error_message (rs->buf.data ());
> + msg != nullptr)
> + error (("%s"), msg);
> + else if (remote_exec_file[0] == '\0')
> error (_("Running the default executable on the remote target failed; "
> "try \"set remote exec-file\"?"));
> else
next prev parent reply other threads:[~2024-02-13 12:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 20:01 [PATCH 0/3] "run" and "attach" failure handling problems Pedro Alves
2024-02-12 20:01 ` [PATCH 1/3] Fix "run" failure with GDBserver Pedro Alves
2024-02-13 15:19 ` Lancelot SIX
2024-02-13 21:11 ` Pedro Alves
2024-02-12 20:01 ` [PATCH 2/3] Improve vRun error reporting Pedro Alves
2024-02-13 12:56 ` Pedro Alves [this message]
2024-02-13 15:36 ` Lancelot SIX
2024-02-12 20:01 ` [PATCH 3/3] Windows: Fix run/attach hang after bad run/attach Pedro Alves
2024-02-12 20:14 ` Hannes Domani
2024-02-13 12:20 ` Pedro Alves
2024-02-13 21:14 ` 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=d74b5392-703c-450a-aab5-e19cc38b8381@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@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).