Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Style "pwd" output
Date: Wed, 05 Jun 2019 15:21:00 -0000	[thread overview]
Message-ID: <32872d6a-15d6-9718-59ae-957694e114c9@redhat.com> (raw)
In-Reply-To: <87lfygi1x0.fsf@tromey.com>

On 6/5/19 2:42 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> I wish we didn't have to split the lines across different calls though.
> Pedro> I know we don't officially do i18n yet (*), but these kinds of changes will
> Pedro> only make it more difficult to get there.
> 
> Pedro> Maybe with something like:
> 
> Pedro>   if (strcmp (cwd.get (), current_directory) != 0)
> Pedro>     printf_unfiltered (_("Working directory <style=filename>%s<style/>\n (canonically <style=filename>%s<style/>).\n"),
> Pedro> 		       current_directory, cwd.get ());
> Pedro>   else
> Pedro>     printf_unfiltered (_("Working directory <style=filename>%s<style/>.\n"), current_directory);
> 
> Pedro> I'm sure you've considered something like that; I think we've discussed it
> Pedro> before.  What are your current thoughts?
> 
> I think what would be nice is a gdb-specific printf extension for this,
> e.g.:
> 
>     printf_unfiltered ("Working directory %<%s%>\n",
>                        ui_out_style_kind::FILE, 
>                        current_directory);
> 
> %< takes a style argument and %> does not.
> 
> However, for that to work, we'd need a GCC enhancement to let gdb modify
> the printf format checking.

While not so good looking, instead of a GCC enhancement, we could maybe
do it the Linux way, like binutils did too:

 https://sourceware.org/ml/binutils/2018-02/msg00306.html

See 871b3ab29e87c.

So e.g., %pS would be a style, a %pN would be no style.

    printf_unfiltered ("Working directory %pS%s%pN\n",
                       ui_out_style_kind::FILE, 
                       current_directory);

> 
> 
> Note that if we want to be serious about i18n then there is also the
> problem that the whole MI approach is not very i18n-friendly.  There are
> spots that split calls like this, but which can't easily be unsplit
> (even with a printf extension) due to MI.  So maybe something bigger is
> needed.

Right.

So instead of e.g.:

 uiout->text ("\nWatchpoint ");
 uiout->field_int ("wpnum", b->number);
 uiout->text (" deleted because the program has left the block in\n"
              "which its expression is valid.\n");

We could have:

 uiout->field_fmt ("\nWatchpoint %pF deleted because the program "
                    "has left the block in\n"
                    "which its expression is valid.\n"", 
                    int_field ("wpnum", b->number).ptr ());

With ui_out_field being something like 

 struct int_field
 {
    int_field (const char *field_name, int val);

    // need this because we can't pass a reference via va_args.
    void *ptr () { return this; }

    const char *m_field_name;
    int m_val;
 };

There would then be another class for CORE_ADDR, another for strings,
etc, matching the ui_out::field_int, ui_out::field_string, etc. methods.
Or alternatively, we could have a single uiout_field class that records 
its type depending on which ctor was called.

Thanks,
Pedro Alves


  reply	other threads:[~2019-06-05 15:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  2:01 Tom Tromey
2019-06-05  8:36 ` Pedro Alves
2019-06-05 13:42   ` Tom Tromey
2019-06-05 15:21     ` Pedro Alves [this message]
2019-06-05 18:12       ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-06-05 20:27         ` Tom Tromey
2019-06-05 20:39           ` Pedro Alves
2019-06-05 20:42             ` Pedro Alves
2019-06-05 20:49               ` Tom Tromey
2019-06-05 20:47             ` Tom Tromey
2019-06-05 21:25               ` Pedro Alves
2019-06-05 22:21                 ` Tom Tromey
2019-06-06 15:49                   ` Pedro Alves
2019-06-06 23:55                     ` Tom Tromey
2019-06-07 18:27                   ` Tom Tromey
2019-06-07 19:20                     ` Tom Tromey
2019-07-01 12:23                       ` Pedro Alves
2019-07-01 12:55                         ` Pedro Alves
2019-07-01 13:06                           ` Pedro Alves
2019-07-01 17:26                             ` Tom Tromey
2019-07-01 19:24                               ` [users/palves/format_strings] Down with .ptr() (Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)) Pedro Alves
2019-07-01 13:17                           ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 13:20                             ` Pedro Alves
2019-07-01 17:38                             ` Tom Tromey
2019-07-01 18:49                               ` Tom Tromey
2019-07-01 18:56                                 ` Pedro Alves
2019-07-01 19:30                                   ` [users/palves/format_strings] Document the gdb-specific formatters Pedro Alves
2019-07-01 19:25                               ` [users/palves/format_strings] Introduce string_field Pedro Alves
2019-07-01 17:43                         ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Tom Tromey
2019-07-01 19:29                           ` [users/palves/format_strings] Make printf_filtered support the gdb-specific formatters too Pedro Alves
2019-07-01 12:01                     ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 12:25                       ` Tom Tromey
2019-07-01 12:37                         ` Pedro Alves
2019-07-01 17:20                           ` Tom Tromey
2019-07-01 19:27                             ` [users/palves/format_strings] %pS/%pN -> %p[/%p] Pedro Alves
2019-07-01 19:32                         ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Philippe Waroquiers
2019-07-03 12:20                           ` Tom Tromey

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=32872d6a-15d6-9718-59ae-957694e114c9@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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