From: Pedro Alves <palves@redhat.com>
To: Doug Evans <dje@google.com>
Cc: Yao Qi <yao@codesourcery.com>, gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] use zuinteger_unlimited for some remote commands
Date: Tue, 05 Mar 2013 18:07:00 -0000 [thread overview]
Message-ID: <5136341A.4050605@redhat.com> (raw)
In-Reply-To: <CADPb22S776PH36hEWzHP3hhF6Yb_58Ty5kimuBN-YvjhR2X7sg@mail.gmail.com>
On 03/05/2013 05:33 PM, Doug Evans wrote:
> On Tue, Mar 5, 2013 at 4:59 AM, Pedro Alves <palves@redhat.com> wrote:
>> We could just as
>> well treat the variable internally as the correct type of
>> unsigned int, and handle UINT_MAX as unlimited internally too.
>
> Part of me is weeping that we didn't take this route.
In a way, I suppose I don't like it, because it ties a
magic _positive_ number as upper bound in the user/api
interface. And that also invites problems and tears
down the road. :-)
IOW, the magic number UINT_MAX actually depends on
host int width (32/64-bit, etc., exotic, but they exist),
so e.g., in theory python scripts may have trouble with that.
Also, if at some point we want to extend the range of
these variables to 64-bit, the magic number has to change,
as then UINT_MAX is midway through the valid range...
Signed negative "-1", "-2", etc. don't have that issue.
They mean the same whatever the width.
(And if we want another magic number in addition to "unlimited"?
Say, we need "disabled", while "0" still meaning "0".
Reserving and writting "UINT_MAX-1" gets much uglier then...
Maybe we'll end up with a struct instead of packing things
into a single number.)
That's a load of theory though. We could also just declare
the command is bound to a uint32_t variable, and document it as
such.
But still, OTOH, this same reasoning percolates all the
way to the remote protocol -- numbers in the remote protocol
don't actually have an upper bound / width hard coded. So there's
a possible compatibility issue here. Once UINT_MAX for one target
is deemed "not big enough", should we add new, different packets?
Or should GDB be adjusted to cope internally, while the visible
interfaces (cli/python/RSP) remain the same, only that they support
larger values?
The other approach (signed, -1) avoids actually thinking too
much about all these issues, and pondering on their
significance, hence my preference. :-)
> If uinteger is in the name, anything else just invites problems, if
> not tears ... :-)
To me, it indicates that for "normal" values, this command only
really accepts positive values. Negatives are almost an
implementation detail. We could make it fully an implementation
detail, if "set foo unlimited" was supported (I do think it should),
and, if that isn't actually problematic for frontends/python (is it?),
though I could imagine the negative values being more convenient in
scripts than having to check for special non-numbers.
With all that said -- it's fine with me if people remove the u.
--
Pedro Alves
next prev parent reply other threads:[~2013-03-05 18:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-15 13:29 [PATCH 0/2] Use zuinteger_unlimited Yao Qi
2013-02-15 13:29 ` [PATCH 2/2] use zuinteger_unlimited for heuristic-fence-post Yao Qi
2013-02-15 13:29 ` [PATCH 1/2] use zuinteger_unlimited for some remote commands Yao Qi
2013-03-04 13:19 ` Pedro Alves
2013-03-04 14:38 ` Yao Qi
2013-03-04 16:21 ` Pedro Alves
2013-03-05 7:45 ` Yao Qi
2013-03-05 12:59 ` Pedro Alves
2013-03-05 17:33 ` Doug Evans
2013-03-05 18:07 ` Pedro Alves [this message]
2013-03-06 0:30 ` Doug Evans
2013-02-25 3:15 ` ping : [PATCH 0/2] Use zuinteger_unlimited Yao Qi
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=5136341A.4050605@redhat.com \
--to=palves@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.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