Skip to contentSkip to conversation

trace: Clarify DTrace/SystemTap help message

PATCH Superseded Philippe Mathieu-Daudé 2 participants 3 messages Aug 15, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: Clarify DTrace/SystemTap help message

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
---
 trace/control.c | 7 +++++++
 1 file changed, 7 insertions(+)
trace/control.c +7 -0
index 43fb7868db..bc2fe0859d 100644
@@ -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)
Signature · 1 line
2.20.1
#1 lore raw
Quoted 48 lines · Philippe Mathieu-Daudé

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
---
 trace/control.c | 7 +++++++
 1 file changed, 7 insertions(+)
trace/control.c +3 -0
index 43fb7868db..bc2fe0859d 100644
@@ -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"

trace/control.c TraceEvent *trace_event_iter_next(TraceEventIter *iter) · line 174

Quoted 10 lines
trace/control.c +4 -0
+                    " 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

#2 lore raw
Quoted 53 lines · Stefan Hajnoczi
Quoted 52 lines · Philippe Mathieu-Daudé

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
---
 trace/control.c | 7 +++++++
 1 file changed, 7 insertions(+)
trace/control.c +6 -0
index 43fb7868db..bc2fe0859d 100644
@@ -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;
Quoted 8 lines

trace/control.c TraceEvent *trace_event_iter_next(TraceEventIter *iter) · line 174

Quoted 6 lines
trace/control.c +1 -0
     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.

Quoted 7 lines

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.