summaryrefslogtreecommitdiff
path: root/scripts/tracetool
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2015-01-20 09:41:15 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2015-02-06 10:27:22 +0000
commitdd9fe29c80b8a35f12d98928a97be3aded80cf69 (patch)
tree1dd36451cb2c4f425607b6472626c4376f79a6d0 /scripts/tracetool
parent16017c48547960539fcadb1f91d252124f442482 (diff)
trace: Print PID and time in stderr traces
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> Message-id: 1421746875-9962-1-git-send-email-dgilbert@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/tracetool')
-rw-r--r--scripts/tracetool/backend/stderr.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py
index 2a1e9064c3..ca58054621 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,