From: Tom Tromey <tom@tromey.com>
To: "Alexandra Hájková" <ahajkova@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] remote.c: Make packet_check_result return a structure
Date: Fri, 22 Dec 2023 08:32:35 -0700 [thread overview]
Message-ID: <87il4q2qy4.fsf@tromey.com> (raw)
In-Reply-To: <20231222113359.1224157-1-ahajkova@redhat.com> ("Alexandra =?utf-8?B?SMOhamtvdsOhIidz?= message of "Fri, 22 Dec 2023 12:33:59 +0100")
>>>>> "Alexandra" == Alexandra Hájková <ahajkova@redhat.com> writes:
Alexandra> packet_check_result currently returns an packet_result enum.
Alexandra> If GDB will recieve an error in a format E.errtext, which
Alexandra> is possible for some q packets, such errtext is lost if
Alexandra> treated by packet_check_result.
Thank you for the patch. I think the general idea makes sense.
Alexandra> There's no infrastructure to test this with a test case so
Alexandra> I tested this by modifying store_registers_using_G function
Alexandra> to get an error message:
packet_check_result is isolated enough that, if you wanted, you could
write unit tests for it.
Alexandra> +/* Keeps packet's return value. If packet's return value is PACKET_ERROR,
Alexandra> + err_msg contains an error message string from E.string or the number
Alexandra> + stored as a string from E.num. */
Alexandra> +struct packet_result
Alexandra> +{
Alexandra> + packet_result (enum packet_status status, std::string err_msg)
Alexandra> + : m_status (status),
Alexandra> + m_err_msg (std::move (err_msg))
This is formatted strangely.
Alexandra> + packet_result (enum packet_status status)
Alexandra> + : m_status (status)
Alexandra> + {
Alexandra> + gdb_assert (status != PACKET_ERROR);
Here and elsewhere the "{" is indented too far.
Also, single-argument constructors should ordinarily be "explicit".
Alexandra> + }
Alexandra> +
Alexandra> +private:
Alexandra> + enum packet_status m_status;
Alexandra> + std::string m_err_msg;
Alexandra> +
Alexandra> +public:
Better IMO to put all the private stuff at the end.
Alexandra> + enum packet_status
Alexandra> + status () const
For methods this all goes on one line.
Alexandra> -static enum packet_result
Alexandra> +static struct packet_result
Since you're touching this anyway you might as well leave out the
'struct' keyword.
Tom
next prev parent reply other threads:[~2023-12-22 15:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-22 11:33 Alexandra Hájková
2023-12-22 15:32 ` Tom Tromey [this message]
2024-01-05 14:36 ` Andrew Burgess
2024-01-09 14:54 ` Tom Tromey
2023-12-26 15:39 ` Thiago Jung Bauermann
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=87il4q2qy4.fsf@tromey.com \
--to=tom@tromey.com \
--cc=ahajkova@redhat.com \
--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).