qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces
@ 2015-01-20  9:41 Dr. David Alan Gilbert (git)
  2015-02-05 19:39 ` Dr. David Alan Gilbert
  2015-02-06 10:29 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2015-01-20  9:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

When debugging migration it's useful to know the PID of
each trace message so you can figure out if it came from the source
or the destination.

Printing the time makes it easy to do latency measurements or timings
between trace points.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---

v2
  0 pad usec part

 scripts/tracetool/backend/stderr.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py
index 2a1e906..ca58054 100644
--- a/scripts/tracetool/backend/stderr.py
+++ b/scripts/tracetool/backend/stderr.py
@@ -21,6 +21,9 @@ PUBLIC = True
 
 def generate_h_begin(events):
     out('#include <stdio.h>',
+        '#include <sys/time.h>',
+        '#include <sys/types.h>',
+        '#include <unistd.h>',
         '#include "trace/control.h"',
         '')
 
@@ -31,7 +34,12 @@ def generate_h(event):
         argnames = ", " + argnames
 
     out('    if (trace_event_get_state(%(event_id)s)) {',
-        '        fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
+        '        struct timeval _now;',
+        '        gettimeofday(&_now, NULL);',
+        '        fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
+        '                        getpid(),',
+        '                        (size_t)_now.tv_sec, (size_t)_now.tv_usec',
+        '                        %(argnames)s);',
         '    }',
         event_id="TRACE_" + event.name.upper(),
         name=event.name,
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces
  2015-01-20  9:41 [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces Dr. David Alan Gilbert (git)
@ 2015-02-05 19:39 ` Dr. David Alan Gilbert
  2015-02-06 10:29 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2015-02-05 19:39 UTC (permalink / raw)
  To: qemu-devel, stefanha

* Dr. David Alan Gilbert (git) (dgilbert@redhat.com) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> When debugging migration it's useful to know the PID of
> each trace message so you can figure out if it came from the source
> or the destination.
> 
> Printing the time makes it easy to do latency measurements or timings
> between trace points.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Ping.

Dave

> ---
> 
> v2
>   0 pad usec part
> 
>  scripts/tracetool/backend/stderr.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py
> index 2a1e906..ca58054 100644
> --- a/scripts/tracetool/backend/stderr.py
> +++ b/scripts/tracetool/backend/stderr.py
> @@ -21,6 +21,9 @@ PUBLIC = True
>  
>  def generate_h_begin(events):
>      out('#include <stdio.h>',
> +        '#include <sys/time.h>',
> +        '#include <sys/types.h>',
> +        '#include <unistd.h>',
>          '#include "trace/control.h"',
>          '')
>  
> @@ -31,7 +34,12 @@ def generate_h(event):
>          argnames = ", " + argnames
>  
>      out('    if (trace_event_get_state(%(event_id)s)) {',
> -        '        fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
> +        '        struct timeval _now;',
> +        '        gettimeofday(&_now, NULL);',
> +        '        fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
> +        '                        getpid(),',
> +        '                        (size_t)_now.tv_sec, (size_t)_now.tv_usec',
> +        '                        %(argnames)s);',
>          '    }',
>          event_id="TRACE_" + event.name.upper(),
>          name=event.name,
> -- 
> 2.1.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces
  2015-01-20  9:41 [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces Dr. David Alan Gilbert (git)
  2015-02-05 19:39 ` Dr. David Alan Gilbert
@ 2015-02-06 10:29 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-02-06 10:29 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel

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

On Tue, Jan 20, 2015 at 09:41:15AM +0000, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> When debugging migration it's useful to know the PID of
> each trace message so you can figure out if it came from the source
> or the destination.
> 
> Printing the time makes it easy to do latency measurements or timings
> between trace points.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> 
> v2
>   0 pad usec part
> 
>  scripts/tracetool/backend/stderr.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)

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

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2015-02-06 10:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20  9:41 [Qemu-devel] [PATCH v2 1/1] Print PID and time in stderr traces Dr. David Alan Gilbert (git)
2015-02-05 19:39 ` Dr. David Alan Gilbert
2015-02-06 10:29 ` Stefan Hajnoczi

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