From: Stefan Hajnoczi <stefanha@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Eduardo Habkost <ehabkost@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH 4/4] tracetool: show trace-events filename/lineno in fmt string errors
Date: Fri, 28 Aug 2020 16:36:20 +0100 [thread overview]
Message-ID: <20200828153620.GA206776@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAFEAcA-B_HC-uRBchjtjKx=Zo5fj0Wf3yJA_1h1Rr8-rZm=V0Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]
On Thu, Aug 27, 2020 at 03:59:04PM +0100, Peter Maydell wrote:
> On Thu, 27 Aug 2020 at 15:29, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > The compiler encounters trace event format strings in generated code.
> > Format strings are error-prone and therefore clear compiler errors are
> > important.
> >
> > Use the #line directive to show the trace-events filename and line
> > number in format string errors:
> > https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Line-Control.html
> >
> > For example, if the cpu_in trace event's %u is changed to %p the
> > following error is reported:
> >
> > trace-events:29:18: error: format ‘%p’ expects argument of type ‘void *’, but argument 7 has type ‘unsigned int’ [-Werror=format=]
> >
> > Line 29 in trace-events is where cpu_in is defined. This works for any
> > trace-events file in the QEMU source tree and the correct path is
> > displayed.
> >
> > Unfortunately there does not seem to be a way to set the column, so "18"
> > is not the right character on that line.
>
> It's been pointed out to me that you could do this by
> making the generated code have suitable line breaks, padding,
> etc, so that the format string in the output ends up starting in
> the same column it was in the input trace file. Whether this is
> worthwhile I leave up to you :-)
>
> (The argument number (7 in your example) is also of course off,
> and that I think we're also stuck with. Getting the file and line
> number right is a solid improvement on the current situation.)
Thanks for mentioning that trick. I will leave the patch series as-is
for now.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-08-28 15:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 14:29 [PATCH 0/4] tracetool: show trace-events filename/lineno in fmt string errors Stefan Hajnoczi
2020-08-27 14:29 ` [PATCH 1/4] tracetool: add output filename command-line argument Stefan Hajnoczi
2020-08-31 20:17 ` Philippe Mathieu-Daudé
2020-09-01 12:55 ` Peter Maydell
2020-08-27 14:29 ` [PATCH 2/4] tracetool: add out_lineno and out_next_lineno to out() Stefan Hajnoczi
2020-09-01 12:49 ` Peter Maydell
2020-08-27 14:29 ` [PATCH 3/4] tracetool: add input filename and line number to Event Stefan Hajnoczi
2020-08-31 20:20 ` Philippe Mathieu-Daudé
2020-09-01 12:50 ` Peter Maydell
2020-08-27 14:29 ` [PATCH 4/4] tracetool: show trace-events filename/lineno in fmt string errors Stefan Hajnoczi
2020-08-27 14:59 ` Peter Maydell
2020-08-28 15:36 ` Stefan Hajnoczi [this message]
2020-09-01 12:52 ` Peter Maydell
2020-12-08 14:20 ` [PATCH 0/4] " Stefan Hajnoczi
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=20200828153620.GA206776@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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 NNTP newsgroup(s).