aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xentrace/xentrace.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-11 09:46:21 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-11 09:46:21 +0000
commitd37035e9f9ee9dc1fddd3fc8fd541b91504b3d43 (patch)
tree2b00b4b25c7ad724983251f2184ba9eb70cb137b /tools/xentrace/xentrace.c
parent4be9201e8c34104b15ac2eda6b8c3092d7baa191 (diff)
downloadxen-d37035e9f9ee9dc1fddd3fc8fd541b91504b3d43.tar.gz
xen-d37035e9f9ee9dc1fddd3fc8fd541b91504b3d43.tar.bz2
xen-d37035e9f9ee9dc1fddd3fc8fd541b91504b3d43.zip
xentrace: Allow xentrace to handle >4G of trace data.
It was previously assert'ing when it hit 4G. Also, because the trace buffer is not a power of 2 in size, using modulo arithmetic to address the buffer does not work when the index wraps around 2^32. This patch fixes both issues, and as a side effect, removes all integer division from the hypervisor side of the trace mechanism. Signed-off-by: Michael A Fetterman <Michael.Fetterman@cl.cam.ac.uk>
Diffstat (limited to 'tools/xentrace/xentrace.c')
-rw-r--r--tools/xentrace/xentrace.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
index 26415bdb7d..bd276cc3ed 100644
--- a/tools/xentrace/xentrace.c
+++ b/tools/xentrace/xentrace.c
@@ -362,9 +362,18 @@ int monitor_tbufs(int outfd)
if ( cons == prod )
continue;
- assert(prod > cons);
+ assert(cons < 2*data_size);
+ assert(prod < 2*data_size);
+
+ // NB: if (prod<cons), then (prod-cons)%data_size will not yield
+ // the correct answer because data_size is not a power of 2.
+ if ( prod < cons )
+ window_size = (prod + 2*data_size) - cons;
+ else
+ window_size = prod - cons;
+ assert(window_size > 0);
+ assert(window_size <= data_size);
- window_size = prod - cons;
start_offset = cons % data_size;
end_offset = prod % data_size;