aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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;