public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Philip Herron <philip.herron@embecosm.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Extract a common logger from jit and analyzer frameworks
Date: Fri, 05 Mar 2021 09:18:40 -0500	[thread overview]
Message-ID: <113d395803c4ec0923707c451947d4bac45aaa19.camel@redhat.com> (raw)
In-Reply-To: <68dd7ea2-18fd-9931-f2b4-0b0d412b307d@embecosm.com>

On Fri, 2021-03-05 at 10:58 +0000, Philip Herron wrote:
> On 04/03/2021 16:45, David Malcolm wrote:
> > On Thu, 2021-03-04 at 16:17 +0000, Philip Herron wrote:
> > > In development of the Rust FE logging is useful in debugging.
> > > Instead
> > > of
> > > rolling our own logger it became clear the loggers part of
> > > analyzer
> > > and jit
> > > projects could be extracted and made generic so they could be
> > > reused
> > > in
> > > other projects.

[...]

> > [...]
> > 
> > > @@ -144,19 +152,27 @@ logger::log_partial (const char *fmt, ...)
> > >  void
> > >  logger::log_va_partial (const char *fmt, va_list *ap)
> > >  {
> > > -  text_info text;
> > > -  text.format_spec = fmt;
> > > -  text.args_ptr = ap;
> > > -  text.err_no = 0;
> > > -  pp_format (m_pp, &text);
> > > -  pp_output_formatted_text (m_pp);
> > I think there's an issue here: what format codes are accepted by
> > this
> > function?
> > 
> > > +  if (!has_pretty_printer ())
> > > +    vfprintf (m_f_out, fmt, *ap);
> > ...here we're formatting using vfprintf...
> > 
> > > +  else
> > > +    {
> > > +      text_info text;
> > > +      text.format_spec = fmt;
> > > +      text.args_ptr = ap;
> > > +      text.err_no = 0;
> > > +      pp_format (m_pp, &text);
> > ...whereas here we're formatting using pp_format, which has
> > different
> > conventions.
> > 
> > The jit implementation decls have e.g.:
> >    GNU_PRINTF(2, 3);
> > whereas the analyzer decls have e.g.:
> >    ATTRIBUTE_GCC_DIAG(2, 3);
> > 
> > I'm not quite sure how to square this circle - templates?  Gah.
> > 
> > I guess the analyzer implementation drifted away from the jit
> > implementation (the analyzer code was originally copied from the
> > jit
> > code).  Sorry about that.
> > 
> > [...]
> > 
> > Hope this is constructive
> > Dave
> 
> Hi David,
> 
> Thanks for the great feedback and for reviewing my earlier attempts.
> It
> seems as though there are really two distinct loggers one with a
> pretty
> printer and one without. Maybe there is a case for creating
> BaseLogger
> which is using GNU_PRINTF and vfprintf etc. Then a
> PrettyPrinterLogger
> based on the BaseLogger but allows for the extensions and the pretty
> printer I think could solve this.

Nit: we don't use CamelCase in GCC [1]

>  Though at that point maybe it is
> getting too complex. 

Agreed, that would be too complicated.

> For gccrs I am interested in the logger in the
> analyzer since it can give such detailed output on the trees

FWIW, I'm not quite sure what you mean by the above.

>  which could
> be useful so maybe just extracting that is the right thing to do for
> GCC
> projects.
> 
> What do you think?

I don't think the jit logger exposes the formatted printing API to end-
users, so at some point it ought to be possible to port the jit logger
from vfprintf to pretty_printer.

How's this for a plan? - for the Rust FE you extract just the analyzer
logging, and at some later point I can port the jit logging over to the
shared gccrs/analyzer logging (so that the Rust FE project doesn't need
to depend on the jit porting being done).  Obviously it would be better
to have just one hierarchical logging framework rather than two, but at
least this way we don't have three, and it gives us a path to getting
down to a single one, and hopefully is sufficiently non-controversial
to not make it harder to (eventually) get the Rust FE merged into
mainline gcc.

Thoughts?

Hope this sounds sane
Dave

[1] except in template declarations, for template arguments


  reply	other threads:[~2021-03-05 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 16:17 Philip Herron
2021-03-04 16:45 ` David Malcolm
2021-03-05 10:58   ` Philip Herron
2021-03-05 14:18     ` David Malcolm [this message]
2021-03-05 15:07       ` Philip Herron

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=113d395803c4ec0923707c451947d4bac45aaa19.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=philip.herron@embecosm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).