[Qemu-devel] [PATCH v2] trace: Clarify DTrace/SystemTap help message

Philippe Mathieu-Daudé posted 1 patch 4 years, 8 months ago
Test docker-clang@ubuntu passed
Test FreeBSD passed
Test checkpatch passed
Test docker-mingw@fedora passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190823142203.5210-1-philmd@redhat.com
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>
trace/control.c | 6 ++++++
1 file changed, 6 insertions(+)
[Qemu-devel] [PATCH v2] trace: Clarify DTrace/SystemTap help message
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
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>
---
v2: Consider when multiple trace backends are used (Stefan)
---
 trace/control.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/trace/control.c b/trace/control.c
index 43fb7868db..d9cafc161b 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -165,6 +165,12 @@ void trace_list_events(void)
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         fprintf(stderr, "%s\n", trace_event_get_name(ev));
     }
+#ifdef CONFIG_TRACE_DTRACE
+    fprintf(stderr, "This list of names of trace points may be incomplete "
+                    "when using the DTrace/SystemTap backends.\n"
+                    "Run 'qemu-trace-stap list %s' to print the full list.\n",
+            error_get_progname());
+#endif
 }
 
 static void do_trace_enable_events(const char *line_buf)
-- 
2.20.1


Re: [Qemu-devel] [PATCH v2] trace: Clarify DTrace/SystemTap help message
Posted by Stefan Hajnoczi 4 years, 8 months ago
On Fri, Aug 23, 2019 at 04:22:03PM +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>
> ---
> v2: Consider when multiple trace backends are used (Stefan)
> ---
>  trace/control.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan