public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [RFC] Allow explicit 16 or 32 char in 'x /s'
Date: Thu, 18 Mar 2010 22:08:00 -0000	[thread overview]
Message-ID: <m3mxy5z3j8.fsf@fleche.redhat.com> (raw)
In-Reply-To: <11484.4708740295$1268865815@news.gmane.org> (Pierre Muller's 	message of "Wed, 17 Mar 2010 23:42:53 +0100")

>>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr> writes:

Pierre>   The patch below allows to 
Pierre> print strings that are made of 16 bit or 32 bit char 
Pierre> using:
Pierre> 'x /hs ' or 'x /ws ' commands.

It seems like a good idea to me.

Pierre>   I tried to enable this feature, keeping it to a minimum:
Pierre>   The size modifier is not remembered for /s format,
Pierre> thus any subsequent use of /s alone will still 
Pierre> print out byte char strings.

If the user types 'x/2hs' and then 'x/2', does the second invocation
still print wide strings?  I think it should.

Pierre> -      if (!strcmp (name, "char16_t"))
Pierre> +      /* Also recognize the type used by 'x /hs' command.  */
Pierre> +      if (!strcmp (name, "char16_t")
Pierre> +          || (TYPE_CODE (elttype) == TYPE_CODE_INT
Pierre> +              && TYPE_LENGTH (elttype) == 2))
Pierre>  	{
Pierre>  	  result = C_CHAR_16;
Pierre>  	  goto done;
Pierre>  	}

I am a little concerned that this code can confuse the user.
If sizeof(wchar_t) == 2, then sometimes you could end up printing a
wchar_t using UTF-16 -- which may or may not be appropriate.

I'm not sure how much this matters in practice.  However, it seems like
it may be cleaner to override classify_type's decision based directly on
the format character, instead of on the implied type.  What do you think
of that?  This would also let us introduce a new format character
meaning "wchar_t".

I think the documentation should reflect that the user can't choose the
encoding used here.

Pierre> +     The case of strings is handled n decode_format, only explicit

Typo, s/n/in/

Finally, please add some test cases.

Tom

       reply	other threads:[~2010-03-18 22:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <11484.4708740295$1268865815@news.gmane.org>
2010-03-18 22:08 ` Tom Tromey [this message]
2010-03-19  7:32   ` Eli Zaretskii
2010-03-22 22:54     ` Pierre Muller
     [not found]     ` <15103.6087111153$1269298497@news.gmane.org>
2010-03-30 20:33       ` Tom Tromey
2010-03-31 16:11         ` [RFC-v2] " Pierre Muller
     [not found]         ` <006101cad0ec$cb7915d0$626b4170$%muller@ics-cnrs.unistra.fr>
2010-03-31 16:17           ` Eli Zaretskii
2010-04-01  9:34             ` Pierre Muller
     [not found]             ` <000f01cad17e$7686f140$6394d3c0$%muller@ics-cnrs.unistra.fr>
2010-04-01 13:17               ` Eli Zaretskii
2010-04-05 23:01                 ` Pierre Muller
     [not found]                 ` <002701cad513$e44a7420$acdf5c60$%muller@ics-cnrs.unistra.fr>
2010-04-06 17:51                   ` Eli Zaretskii
2010-04-08 20:58                     ` [RFA-v3] " Pierre Muller
2010-04-16  8:41                       ` [PING] " Pierre Muller
     [not found]                       ` <48335.255837492$1271407316@news.gmane.org>
2010-04-21 22:49                         ` Tom Tromey
2010-04-21 23:22                           ` Pierre Muller
2010-06-11 17:38                       ` Ulrich Weigand
2010-07-02 19:09                         ` Tom Tromey
2010-07-05 10:17                           ` Ulrich Weigand
2010-07-20 20:13                             ` [patch] testsuite: regression on failed charset.exp compilation [Re: [RFA-v3] Allow explicit 16 or 32 char in 'x /s'] Jan Kratochvil
2010-07-20 22:00                               ` Tom Tromey
2010-07-20 22:13                                 ` Jan Kratochvil
2010-03-17 22:43 [RFC] Allow explicit 16 or 32 char in 'x /s' Pierre Muller
2010-03-18  7:01 ` Eli Zaretskii
2010-03-18 14:20   ` Pierre Muller
     [not found]   ` <001e01cac69a$75167630$5f436290$%muller@ics-cnrs.unistra.fr>
2010-03-18 18:26     ` Eli Zaretskii

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=m3mxy5z3j8.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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).