qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH-for-4.2] tracing: Allow to tune tracing options


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [RFC PATCH-for-4.2] tracing: Allow to tune tracing options via the environment
Date: Wed, 3 Jul 2019 19:10:05 +0200

We can pass trace trace options with the -trace command line
argument.

Tracing might be useful when running qtests. To avoid to have
to modify the tests and recompile, add the possibility to pass
trace options via the shell environment.

We add:
- QEMU_TRACE_EVENTS:    List of events to enable (coma separated)
- QEMU_TRACE_EVENTFILE: File with list of events to enable
- QEMU_TRACE_LOGFILE:   File to log the trace events.

Example of use:

  $ QEMU_TRACE_EVENTS=pl011\* make check-qtest-arm
    TEST    check-qtest-arm: tests/boot-serial-test
  18650@1562168430.027490:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18650@1562168430.027535:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18650@1562168430.027544:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18650@1562168430.028037:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18650@1562168430.028049:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18650@1562168430.028057:pl011_can_receive LCR 0x00000000 read_count 0 
returning 1
  18653@1562168430.053250:pl011_write addr 0x00000000 value 0x00000054
  18653@1562168430.053276:pl011_irq_state irq state 0
  [...]

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
I'm not sure where to document that...
---
 trace/control.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/trace/control.c b/trace/control.c
index 43fb7868db..aea802623c 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -288,6 +288,8 @@ void trace_fini_vcpu(CPUState *vcpu)
 
 bool trace_init_backends(void)
 {
+    char *trace_env;
+
 #ifdef CONFIG_TRACE_SIMPLE
     if (!st_init()) {
         fprintf(stderr, "failed to initialize simple tracing backend.\n");
@@ -306,6 +308,13 @@ bool trace_init_backends(void)
     openlog(NULL, LOG_PID, LOG_DAEMON);
 #endif
 
+    trace_init_file(getenv("QEMU_TRACE_LOGFILE"));
+    trace_init_events(getenv("QEMU_TRACE_EVENTFILE"));
+    trace_env = getenv("QEMU_TRACE_EVENTS");
+    if (trace_env) {
+        trace_enable_events(trace_env);
+    }
+
     return true;
 }
 
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]