xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* tools: fix SIGFPE in gtraceview
@ 2010-01-29  8:09 Yu Zhiguo
  0 siblings, 0 replies; only message in thread
From: Yu Zhiguo @ 2010-01-29  8:09 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel@lists.xensource.com

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

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-01-29  8:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-29  8:09 tools: fix SIGFPE in gtraceview Yu Zhiguo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).