From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDVJH-00087W-7x for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:41:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDVJG-0008OM-9a for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:41:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDVJG-0008OH-1e for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:41:18 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0K9fHiY007037 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 20 Jan 2015 04:41:17 -0500 From: "Dr. David Alan Gilbert (git)" Date: Tue, 20 Jan 2015 09:41:15 +0000 Message-Id: <1421746875-9962-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH v2 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 Cc: 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 --- 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 ', + '#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.%%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