WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] tools: fix SIGFPE in gtraceview

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] tools: fix SIGFPE in gtraceview
From: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
Date: Fri, 29 Jan 2010 16:09:26 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 29 Jan 2010 00:09:14 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 3.0a1 (Windows/2008050715)
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] tools: fix SIGFPE in gtraceview, Yu Zhiguo <=