[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] tools: fix SIGFPE in gtraceview



If there are 0 or 1 valid record in xentrace file,
SIGFPE will occur. Fix it.

Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>

diff --git a/tools/misc/gtraceview.c b/tools/misc/gtraceview.c
--- a/tools/misc/gtraceview.c
+++ b/tools/misc/gtraceview.c
@@ -209,6 +209,11 @@
     if (load_file(fname))
         exit(EXIT_FAILURE);
 
+    if (!data_cur) {
+        fprintf(stderr, "file %s doesn't contain any valid record\n", fname);
+        exit(EXIT_FAILURE);
+    }
+
     if (mode_init())
         exit(EXIT_FAILURE);
 
@@ -939,14 +944,15 @@
     struct cpu cur_state[MAX_CPU_NR];
     uint64_t tsc = start_time;
     struct state *state;
-    uint64_t number, temp;
+    uint64_t number, temp = 0;
     int state_cur = 0;
 
     for (i = 0; i < max_cpu_num; i++)
         cur_state[i].flag = FLAG_UNKNOWN;
 
     /* allocate spaces, it may be huge... */
-    temp = (data[data_cur-1].tsc - start_time)/time_scale;
+    if (time_scale)
+        temp = (data[data_cur-1].tsc - start_time)/time_scale;
     number = 10000UL;
     if (temp < number)
         number = temp;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.