From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB4zf-0003ls-QL for qemu-devel@nongnu.org; Tue, 13 Jan 2015 12:11:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YB4zb-0008Ux-Fg for qemu-devel@nongnu.org; Tue, 13 Jan 2015 12:11:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB4zb-0008Uk-6X for qemu-devel@nongnu.org; Tue, 13 Jan 2015 12:10:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0DHAwdK031070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 13 Jan 2015 12:10:58 -0500 From: "Dr. David Alan Gilbert (git)" Date: Tue, 13 Jan 2015 17:10:56 +0000 Message-Id: <1421169056-15151-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 1/1] Print PID and time in stderr traces List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, stefanha@redhat.com From: "Dr. David Alan Gilbert" 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 --- 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..16878a3 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 ', + '#include ', + '#include ', + '#include ', '#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.%%zd:%(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