From patchwork Wed Aug 11 11:13:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 61467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 11BE8B70AA for ; Wed, 11 Aug 2010 21:15:17 +1000 (EST) Received: from localhost ([127.0.0.1]:38336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oj9H8-0008EP-5l for incoming@patchwork.ozlabs.org; Wed, 11 Aug 2010 07:15:14 -0400 Received: from [140.186.70.92] (port=55153 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oj9Fd-0007St-50 for qemu-devel@nongnu.org; Wed, 11 Aug 2010 07:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oj9Fb-0000Df-MQ for qemu-devel@nongnu.org; Wed, 11 Aug 2010 07:13:41 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:33448) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oj9Fb-0000DJ-6B for qemu-devel@nongnu.org; Wed, 11 Aug 2010 07:13:39 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp01.au.ibm.com (8.14.4/8.13.1) with ESMTP id o7BBAnMu014258 for ; Wed, 11 Aug 2010 21:10:49 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7BBDauc1544298 for ; Wed, 11 Aug 2010 21:13:36 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o7BBDaAD018237 for ; Wed, 11 Aug 2010 21:13:36 +1000 Received: from zephyr ([9.124.35.61]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o7BBDY2o018211; Wed, 11 Aug 2010 21:13:35 +1000 Date: Wed, 11 Aug 2010 16:43:30 +0530 From: Prerna Saxena To: qemu-devel@nongnu.org Message-ID: <20100811164330.2e2b0ebf@zephyr> In-Reply-To: <4C623D40.6020600@linux.vnet.ibm.com> References: <4C5FC2A5.8030907@linux.vnet.ibm.com> <1281360914-9937-1-git-send-email-stefanha@linux.vnet.ibm.com> <4C623D40.6020600@linux.vnet.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.7.5 (GTK+ 2.16.6; i586-redhat-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Mahesh, Salgaonkar , Ananth , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2] trace: Make trace record fields 64-bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Explicitly use 64-bit fields in trace records so that timestamps and magic numbers work for 32-bit host builds. Changelog (from initial patch posted by Stefan): 1) TraceEventID is now uint64_t to take care of same number of tracepoints on both 32 and 64 bit builds. 2) Cast arguments to uintptr_t, and then to uint64_t to bypass warnings. Signed-off-by: Prerna Saxena --- simpletrace.c | 41 ++++++++++++++++++++++++++--------------- simpletrace.h | 13 +++++++------ simpletrace.py | 2 +- tracetool | 6 +++--- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/simpletrace.c b/simpletrace.c index 954cc4e..27b0cab 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -9,18 +9,29 @@ */ #include +#include #include #include #include "trace.h" +/** Trace file header event ID */ +#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with TraceEventIDs */ + +/** Trace file magic number */ +#define HEADER_MAGIC 0xf2b177cb0aa429b4ULL + +/** Trace file version number, bump if format changes */ +#define HEADER_VERSION 0 + +/** Trace buffer entry */ typedef struct { - unsigned long event; - unsigned long timestamp_ns; - unsigned long x1; - unsigned long x2; - unsigned long x3; - unsigned long x4; - unsigned long x5; + uint64_t event; + uint64_t timestamp_ns; + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; } TraceRecord; enum { @@ -42,9 +53,9 @@ void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, static bool write_header(FILE *fp) { TraceRecord header = { - .event = -1UL, /* max avoids conflicting with TraceEventIDs */ - .timestamp_ns = 0xf2b177cb0aa429b4, /* magic number */ - .x1 = 0, /* bump this version number if file format changes */ + .event = HEADER_EVENT_ID, + .timestamp_ns = HEADER_MAGIC, + .x1 = HEADER_VERSION, }; return fwrite(&header, sizeof header, 1, fp) == 1; @@ -160,27 +171,27 @@ void trace0(TraceEventID event) trace(event, 0, 0, 0, 0, 0); } -void trace1(TraceEventID event, unsigned long x1) +void trace1(TraceEventID event, uint64_t x1) { trace(event, x1, 0, 0, 0, 0); } -void trace2(TraceEventID event, unsigned long x1, unsigned long x2) +void trace2(TraceEventID event, uint64_t x1, uint64_t x2) { trace(event, x1, x2, 0, 0, 0); } -void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3) +void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3) { trace(event, x1, x2, x3, 0, 0); } -void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4) +void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4) { trace(event, x1, x2, x3, x4, 0); } -void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) +void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5) { trace(event, x1, x2, x3, x4, x5); } diff --git a/simpletrace.h b/simpletrace.h index 6a2b8d9..00ca439 100644 --- a/simpletrace.h +++ b/simpletrace.h @@ -10,9 +10,10 @@ #define SIMPLETRACE_H #include +#include #include -typedef unsigned int TraceEventID; +typedef uint64_t TraceEventID; typedef struct { const char *tp_name; @@ -20,11 +21,11 @@ typedef struct { } TraceEvent; void trace0(TraceEventID event); -void trace1(TraceEventID event, unsigned long x1); -void trace2(TraceEventID event, unsigned long x1, unsigned long x2); -void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3); -void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); -void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); +void trace1(TraceEventID event, uint64_t x1); +void trace2(TraceEventID event, uint64_t x1, uint64_t x2); +void trace3(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3); +void trace4(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4); +void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5); void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)); void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)); void st_change_trace_event_state(const char *tname, bool tstate); diff --git a/simpletrace.py b/simpletrace.py index 979d911..fdf0eb5 100755 --- a/simpletrace.py +++ b/simpletrace.py @@ -17,7 +17,7 @@ header_event_id = 0xffffffffffffffff header_magic = 0xf2b177cb0aa429b4 header_version = 0 -trace_fmt = 'LLLLLLL' +trace_fmt = '=QQQQQQQ' trace_len = struct.calcsize(trace_fmt) event_re = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+"([^"]*)"') diff --git a/tracetool b/tracetool index c5a5bdc..29473d4 100755 --- a/tracetool +++ b/tracetool @@ -151,11 +151,11 @@ EOF simple_event_num=0 } -cast_args_to_ulong() +cast_args_to_uint64_t() { local arg for arg in $(get_argnames "$1"); do - echo -n "(unsigned long)$arg" + echo -n "(uint64_t)(uintptr_t)$arg" done } @@ -173,7 +173,7 @@ linetoh_simple() trace_args="$simple_event_num" if [ "$argc" -gt 0 ] then - trace_args="$trace_args, $(cast_args_to_ulong "$1")" + trace_args="$trace_args, $(cast_args_to_uint64_t "$1")" fi cat <