qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] trace: Clarify DTrace/SystemTap help message
@ 2019-08-15 12:02 Philippe Mathieu-Daudé
  2019-08-15 14:45 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-15 12:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé,
	Thomas Huth, Daniel P . Berrange, Stefan Hajnoczi

Most tracing backends are implemented within QEMU, except the
DTrace/SystemTap backends.

One side effect is when running 'qemu -trace help', an incomplete
list of trace events is displayed when using the DTrace/SystemTap
backends.

This is partly due to trace events registered as modules with
trace_init(), and since the events are not used within QEMU,
the linker optimize and remove the unused modules (which is
OK in this particular case).
Currently only the events compiled in trace-root.o and in the
last trace.o member of libqemuutil.a are linked, resulting in
an incomplete list of events.

To avoid confusion, improve the help message, recommending to
use the proper systemtap script to display the events list.

Before:

  $ lm32-softmmu/qemu-system-lm32 -trace help 2>&1 | wc -l
  70

After:

  $ lm32-softmmu/qemu-system-lm32 -trace help
  Run 'qemu-trace-stap list qemu-system-lm32' to print a list
  of names of trace points with the DTrace/SystemTap backends.

  $ qemu-trace-stap list qemu-system-lm32 | wc -l
  1136

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 trace/control.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/trace/control.c b/trace/control.c
index 43fb7868db..bc2fe0859d 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -159,12 +159,19 @@ TraceEvent *trace_event_iter_next(TraceEventIter *iter)
 
 void trace_list_events(void)
 {
+#ifdef CONFIG_TRACE_DTRACE
+    fprintf(stderr, "Run 'qemu-trace-stap list %s' to print a list\n"
+                    "of names of trace points with the DTrace/SystemTap"
+                    " backends.\n",
+                    error_get_progname());
+#else
     TraceEventIter iter;
     TraceEvent *ev;
     trace_event_iter_init(&iter, NULL);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         fprintf(stderr, "%s\n", trace_event_get_name(ev));
     }
+#endif
 }
 
 static void do_trace_enable_events(const char *line_buf)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] trace: Clarify DTrace/SystemTap help message
  2019-08-15 12:02 [Qemu-devel] [PATCH] trace: Clarify DTrace/SystemTap help message Philippe Mathieu-Daudé
@ 2019-08-15 14:45 ` Stefan Hajnoczi
  2019-08-15 15:04   ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2019-08-15 14:45 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Thomas Huth, Daniel P . Berrange, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 2542 bytes --]

On Thu, Aug 15, 2019 at 02:02:47PM +0200, Philippe Mathieu-Daudé wrote:
> Most tracing backends are implemented within QEMU, except the
> DTrace/SystemTap backends.
> 
> One side effect is when running 'qemu -trace help', an incomplete
> list of trace events is displayed when using the DTrace/SystemTap
> backends.
> 
> This is partly due to trace events registered as modules with
> trace_init(), and since the events are not used within QEMU,
> the linker optimize and remove the unused modules (which is
> OK in this particular case).
> Currently only the events compiled in trace-root.o and in the
> last trace.o member of libqemuutil.a are linked, resulting in
> an incomplete list of events.
> 
> To avoid confusion, improve the help message, recommending to
> use the proper systemtap script to display the events list.
> 
> Before:
> 
>   $ lm32-softmmu/qemu-system-lm32 -trace help 2>&1 | wc -l
>   70
> 
> After:
> 
>   $ lm32-softmmu/qemu-system-lm32 -trace help
>   Run 'qemu-trace-stap list qemu-system-lm32' to print a list
>   of names of trace points with the DTrace/SystemTap backends.
> 
>   $ qemu-trace-stap list qemu-system-lm32 | wc -l
>   1136
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  trace/control.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/trace/control.c b/trace/control.c
> index 43fb7868db..bc2fe0859d 100644
> --- a/trace/control.c
> +++ b/trace/control.c
> @@ -159,12 +159,19 @@ TraceEvent *trace_event_iter_next(TraceEventIter *iter)
>  
>  void trace_list_events(void)
>  {
> +#ifdef CONFIG_TRACE_DTRACE
> +    fprintf(stderr, "Run 'qemu-trace-stap list %s' to print a list\n"
> +                    "of names of trace points with the DTrace/SystemTap"
> +                    " backends.\n",
> +                    error_get_progname());
> +#else
>      TraceEventIter iter;
>      TraceEvent *ev;
>      trace_event_iter_init(&iter, NULL);
>      while ((ev = trace_event_iter_next(&iter)) != NULL) {
>          fprintf(stderr, "%s\n", trace_event_get_name(ev));
>      }
> +#endif

Multiple trace backends can be built into QEMU.  In that case the list
might be complete and the user may not be using stap at all.  Perhaps
the message should be turned into a warning instead and the list should
still be printed:

  This list of trace events may be incompletel.  Run 'qemu-trace-stap
  list %s' to print a list of names of trace events with the
  DTrace/SystemTap backends.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] trace: Clarify DTrace/SystemTap help message
  2019-08-15 14:45 ` Stefan Hajnoczi
@ 2019-08-15 15:04   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-15 15:04 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Thomas Huth, Daniel P . Berrange, qemu-devel, Stefan Hajnoczi

On 8/15/19 4:45 PM, Stefan Hajnoczi wrote:
> On Thu, Aug 15, 2019 at 02:02:47PM +0200, Philippe Mathieu-Daudé wrote:
>> Most tracing backends are implemented within QEMU, except the
>> DTrace/SystemTap backends.
>>
>> One side effect is when running 'qemu -trace help', an incomplete
>> list of trace events is displayed when using the DTrace/SystemTap
>> backends.
>>
>> This is partly due to trace events registered as modules with
>> trace_init(), and since the events are not used within QEMU,
>> the linker optimize and remove the unused modules (which is
>> OK in this particular case).
>> Currently only the events compiled in trace-root.o and in the
>> last trace.o member of libqemuutil.a are linked, resulting in
>> an incomplete list of events.
>>
>> To avoid confusion, improve the help message, recommending to
>> use the proper systemtap script to display the events list.
>>
>> Before:
>>
>>   $ lm32-softmmu/qemu-system-lm32 -trace help 2>&1 | wc -l
>>   70
>>
>> After:
>>
>>   $ lm32-softmmu/qemu-system-lm32 -trace help
>>   Run 'qemu-trace-stap list qemu-system-lm32' to print a list
>>   of names of trace points with the DTrace/SystemTap backends.
>>
>>   $ qemu-trace-stap list qemu-system-lm32 | wc -l
>>   1136
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  trace/control.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/trace/control.c b/trace/control.c
>> index 43fb7868db..bc2fe0859d 100644
>> --- a/trace/control.c
>> +++ b/trace/control.c
>> @@ -159,12 +159,19 @@ TraceEvent *trace_event_iter_next(TraceEventIter *iter)
>>  
>>  void trace_list_events(void)
>>  {
>> +#ifdef CONFIG_TRACE_DTRACE
>> +    fprintf(stderr, "Run 'qemu-trace-stap list %s' to print a list\n"
>> +                    "of names of trace points with the DTrace/SystemTap"
>> +                    " backends.\n",
>> +                    error_get_progname());
>> +#else
>>      TraceEventIter iter;
>>      TraceEvent *ev;
>>      trace_event_iter_init(&iter, NULL);
>>      while ((ev = trace_event_iter_next(&iter)) != NULL) {
>>          fprintf(stderr, "%s\n", trace_event_get_name(ev));
>>      }
>> +#endif
> 
> Multiple trace backends can be built into QEMU.  In that case the list

I did not know, that explains the final 's' to the
--enable-trace-backends option.

The "== Trace backends ==" of docs/devel/tracing.txt is not clear about
this.

> might be complete and the user may not be using stap at all.  Perhaps
> the message should be turned into a warning instead and the list should
> still be printed:
> 
>   This list of trace events may be incompletel.  Run 'qemu-trace-stap
>   list %s' to print a list of names of trace events with the
>   DTrace/SystemTap backends.

OK, thanks!

Phil.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-15 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15 12:02 [Qemu-devel] [PATCH] trace: Clarify DTrace/SystemTap help message Philippe Mathieu-Daudé
2019-08-15 14:45 ` Stefan Hajnoczi
2019-08-15 15:04   ` Philippe Mathieu-Daudé

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).