qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH-for-4.2] tracing: Allow to tune tracing options via the environment
@ 2019-07-03 17:10 Philippe Mathieu-Daudé
  2019-07-03 17:25 ` Daniel P. Berrangé
  2019-07-03 21:58 ` no-reply
  0 siblings, 2 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-07-03 17:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Stefan Hajnoczi

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é <philmd@redhat.com>
---
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



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

end of thread, other threads:[~2019-07-09  8:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03 17:10 [Qemu-devel] [RFC PATCH-for-4.2] tracing: Allow to tune tracing options via the environment Philippe Mathieu-Daudé
2019-07-03 17:25 ` Daniel P. Berrangé
2019-07-03 17:29   ` Philippe Mathieu-Daudé
2019-07-04 10:24   ` Stefan Hajnoczi
2019-07-04 10:28     ` Daniel P. Berrangé
2019-07-05  8:07       ` Stefan Hajnoczi
2019-07-05  9:48         ` Philippe Mathieu-Daudé
2019-07-05 13:19           ` Markus Armbruster
2019-07-05 17:53             ` Philippe Mathieu-Daudé
2019-07-06  4:02               ` Markus Armbruster
2019-07-08  9:34                 ` Daniel P. Berrangé
2019-07-08 10:27                   ` Philippe Mathieu-Daudé
2019-07-08 10:38                     ` Daniel P. Berrangé
2019-07-09  5:53                       ` Markus Armbruster
2019-07-09  7:58                         ` Stefan Hajnoczi
2019-07-03 21:58 ` no-reply

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