Tracing patches for QEMU 1.2
The last pull request from 19 July was not merged. Here it is rebased on qemu.git/master with two additional fixes from Stefan Weil.
The following changes since commit 633decd71119a4293e5e53e6059026c517a8bef0:
Merge remote-tracking branch 'qmp/queue/qmp' into staging (2012-08-13 16:12:35 -0500)
are available in the git repository at:
git://github.com/stefanha/qemu.git tracing
for you to fetch changes up to 4552e41025af4694c55854448c3ae4d95e72c7f6:
trace/simple: Replace asprintf by g_strdup_printf (2012-08-14 13:19:57 +0100)
----------------------------------------------------------------
Harsh Prateek Bora (4):
trace: rename TraceRecordHeader to TraceLogHeader
trace: remove unnecessary write_to_buffer() typecasting
trace: drop unused TraceBufferRecord->next_tbuf_idx field
trace: avoid pointer aliasing in trace_record_finish()
Stefan Weil (2):
trace/simple: Fix compiler warning for 32 bit hosts trace/simple: Replace asprintf by g_strdup_printf
scripts/tracetool/backend/simple.py | 2 +- trace/simple.c | 35 +++++++++++++---------------------- trace/simple.h | 1 - 3 files changed, 14 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/6 trace: rename TraceRecordHeader to TraceLogHeader
From: Harsh Prateek Bora <[email protected]>
The TraceRecordHeader is really the header for the entire trace log file. It's not per-record header so make this obvious by renaming it.
--- trace/simple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
trace/simple.c +2 -2
@@ -70,7 +70,7 @@ typedef struct {uint64_t header_event_id;/* HEADER_EVENT_ID */ uint64_t header_magic;/* HEADER_MAGIC */ uint64_t header_version;/* HEADER_VERSION */ -} TraceRecordHeader; +} TraceLogHeader;static void read_from_buffer (unsigned int idx,void *dataptr,size_t size);
@@ -295,7 +295,7 @@ void st_set_trace_file_enabled(bool enable)flush_trace_file (true);if (enable) { -static const TraceRecordHeader header = { +static const TraceLogHeader header = { .header_event_id =HEADER_EVENT_ID , .header_magic =HEADER_MAGIC ,/* Older log readers will check for version at next location */
Signature · 1 line
1.7.10.4
PATCH 2/6 trace: remove unnecessary write_to_buffer() typecasting
In reply to Stefan HajnocziFrom: Harsh Prateek Bora <[email protected]>
The buffer argument is void* so it is not necessary to cast.
--- trace/simple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
trace/simple.c +3 -3
@@ -235,9 +235,9 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi rec->next_tbuf_idx = new_idx %TRACE_BUF_LEN ; rec_off = idx; - rec_off =write_to_buffer (rec_off, (uint8_t *)&event,sizeof (event)); - rec_off =write_to_buffer (rec_off, (uint8_t *)×tamp_ns,sizeof (timestamp_ns)); - rec_off =write_to_buffer (rec_off, (uint8_t *)&rec_len,sizeof (rec_len)); + rec_off =write_to_buffer (rec_off, &event,sizeof (event)); + rec_off =write_to_buffer (rec_off, ×tamp_ns,sizeof (timestamp_ns)); + rec_off =write_to_buffer (rec_off, &rec_len,sizeof (rec_len)); rec->tbuf_idx = idx; rec->rec_off = (idx +sizeof (TraceRecord)) %TRACE_BUF_LEN ;
Signature · 1 line
1.7.10.4
PATCH 3/6 trace: drop unused TraceBufferRecord->next_tbuf_idx field
In reply to Stefan HajnocziFrom: Harsh Prateek Bora <[email protected]>
--- trace/simple.c | 2 -- trace/simple.h | 1 - 2 files changed, 3 deletions(-)
trace/simple.c +0 -2
@@ -231,8 +231,6 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi } idx = old_idx %TRACE_BUF_LEN ; -/* To check later if threshold crossed */ - rec->next_tbuf_idx = new_idx %TRACE_BUF_LEN ; rec_off = idx; rec_off =write_to_buffer (rec_off, &event,sizeof (event));
trace/simple.h +0 -1
@@ -29,7 +29,6 @@ void st_flush_trace_buffer(void);typedef struct {unsigned int tbuf_idx; -unsigned int next_tbuf_idx;unsigned int rec_off; }TraceBufferRecord ;
Signature · 1 line
1.7.10.4
PATCH 4/6 trace: avoid pointer aliasing in trace_record_finish()
In reply to Stefan HajnocziFrom: Harsh Prateek Bora <[email protected]>
Declaring a TraceRecord on the stack works fine. No need for a uint8_t array and pointer aliasing.
--- trace/simple.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
trace/simple.c +4 -5
@@ -269,12 +269,11 @@ static unsigned int write_to_buffer(unsigned int idx, void *dataptr, size_t sizevoid trace_record_finish (TraceBufferRecord *rec) { -uint8_t temp_rec[sizeof (TraceRecord)]; -TraceRecord *record = (TraceRecord *) temp_rec; -read_from_buffer (rec->tbuf_idx, temp_rec,sizeof (TraceRecord)); +TraceRecord record; +read_from_buffer (rec->tbuf_idx, &record,sizeof (TraceRecord));smp_wmb ();/* write barrier before marking as valid */ - record->event |=TRACE_RECORD_VALID ; -write_to_buffer (rec->tbuf_idx, temp_rec,sizeof (TraceRecord)); + record.event |=TRACE_RECORD_VALID ; +write_to_buffer (rec->tbuf_idx, &record,sizeof (TraceRecord));if ((trace_idx - writeout_idx) >TRACE_BUF_FLUSH_THRESHOLD ) {flush_trace_file (false);
Signature · 1 line
1.7.10.4
PATCH 5/6 trace/simple: Fix compiler warning for 32 bit hosts
In reply to Stefan HajnocziFrom: Stefan Weil <[email protected]>
gcc complains when a 32 bit pointer is casted to a 64 bit integer.
--- scripts/tracetool/backend/simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracetool/backend/simple.py +1 -1
@@ -79,7 +79,7 @@ def c(events): ) # pointer var (not string) elif type_.endswith('*'): - out(' trace_record_write_u64(&rec, (uint64_t)(uint64_t *)%(name)s);', + out(' trace_record_write_u64(&rec, (uintptr_t)(uint64_t *)%(name)s);', name = name, ) # primitive data type
Signature · 1 line
1.7.10.4
PATCH 6/6 trace/simple: Replace asprintf by g_strdup_printf
In reply to Stefan HajnocziFrom: Stefan Weil <[email protected]>
asprintf is not available for all hosts. g_strdup_printf is more portable and simplifies the code because if does not need error handling.
The static variable does not need an explicit assignment to be NULL.
--- trace/simple.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
trace/simple.c +4 -10
@@ -55,7 +55,7 @@ static unsigned int trace_idx;static unsigned int writeout_idx;static uint64_t dropped_events;static FILE *trace_fp; -static char *trace_file_name =NULL ; +static char *trace_file_name;/* * Trace buffer entry */ typedef struct {
@@ -329,18 +329,12 @@ bool st_set_trace_file(const char *file) {st_set_trace_file_enabled (false); -free (trace_file_name); +g_free (trace_file_name);if (!file) { -if (asprintf (&trace_file_name,CONFIG_TRACE_FILE ,getpid ()) <0 ) { - trace_file_name =NULL ; -return false; - } + trace_file_name =g_strdup_printf (CONFIG_TRACE_FILE ,getpid ()); }else { -if (asprintf (&trace_file_name,"%s" , file) <0 ) { - trace_file_name =NULL ; -return false; - } + trace_file_name =g_strdup_printf ("%s" , file); }st_set_trace_file_enabled (true);
Signature · 1 line
1.7.10.4
Quoted 2 lines · Stefan Hajnoczi
The last pull request from 19 July was not merged. Here it is rebased on qemu.git/master with two additional fixes from Stefan Weil.
I'm not sure what you mean:
commit 903f650b0c77827f8d92b35f61419401d648df1e
Merge: 61dc008 90a147a
Author: Anthony Liguori <[email protected]>
Date: Mon Jul 23 13:15:34 2012 -0500
Merge remote-tracking branch 'stefanha/tracing' into staging
* stefanha/tracing:
Update simpletrace.py for new log format Simpletrace v2: Support multiple arguments, strings.
monitor: remove unused do_info_trace
trace: added ability to comment out events in the list
Your pull request was for 90a147a275da3a432bdf00238ebf438eff1d2c1b which is what is being merged here.
What your pull request inaccurate?
Regards,
Anthony Liguori
Quoted 32 lines
The following changes since commit
633decd71119a4293e5e53e6059026c517a8bef0:Merge remote-tracking branch 'qmp/queue/qmp' into staging (2012-08-13 16:12:35 -0500)
are available in the git repository at:
git://github.com/stefanha/qemu.gittracingfor you to fetch changes up to
4552e41025af4694c55854448c3ae4d95e72c7f6:trace/simple: Replace asprintf by
g_strdup_printf(2012-08-14 13:19:57 +0100)----------------------------------------------------------------
Harsh Prateek Bora (4):
trace: rename TraceRecordHeader to TraceLogHeader
trace: remove unnecessarywrite_to_buffer()typecasting
trace: drop unusedTraceBufferRecord->next_tbuf_idxfield
trace: avoid pointer aliasing intrace_record_finish()Stefan Weil (2):
trace/simple: Fix compiler warning for 32 bit hosts trace/simple: Replace asprintf byg_strdup_printfscripts/tracetool/backend/simple.py | 2 +- trace/simple.c | 35 +++++++++++++---------------------- trace/simple.h | 1 - 3 files changed, 14 insertions(+), 24 deletions(-)Signature · 1 line
1.7.10.4
Quoted 21 lines · Anthony Liguori
Quoted 2 lines · Stefan Hajnoczi
The last pull request from 19 July was not merged. Here it is rebased on qemu.git/master with two additional fixes from Stefan Weil.
I'm not sure what you mean:
commit
903f650b0c77827f8d92b35f61419401d648df1e
Merge: 61dc008 90a147a
Author: Anthony Liguori <[email protected]>
Date: Mon Jul 23 13:15:34 2012 -0500Merge remote-tracking branch 'stefanha/tracing' into staging
* stefanha/tracing:
Updatesimpletrace.pyfor new log format Simpletrace v2: Support multiple arguments, strings.
monitor: remove unuseddo_info_trace
trace: added ability to comment out events in the list
Quoted 4 lines
Your pull request was for
90a147a275da3a432bdf00238ebf438eff1d2c1bwhich is what is being merged here.What your pull request inaccurate?
You are right. I was confused and thought I previously sent a pull request with Harsh's cleanup patches when I didn't.
The pull request I raised yesterday (4552e41025af4694c55854448c3ae4d95e72c7f6) is good though.
Sorry,
Stefan