|
|
29e444 |
commit 7da6d9ed266105e0ebefd01a4b6bf08bf56257c3
|
|
|
29e444 |
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
|
|
|
29e444 |
Date: Tue Feb 26 14:24:40 2013 +0530
|
|
|
29e444 |
|
|
|
29e444 |
Fix FPE in memusagestat when malloc utilization is zero
|
|
|
29e444 |
|
|
|
29e444 |
[BZ #15160]
|
|
|
29e444 |
|
|
|
29e444 |
Draw graphs for heap and stack only if MAXSIZE_HEAP and MAXSIZE_STACK
|
|
|
29e444 |
are non-zero.
|
|
|
29e444 |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/malloc/memusagestat.c glibc-2.17-c758a686/malloc/memusagestat.c
|
|
|
29e444 |
index f561e0d..7bbd009 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/malloc/memusagestat.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/malloc/memusagestat.c
|
|
|
29e444 |
@@ -319,17 +319,26 @@ main (int argc, char *argv[])
|
|
|
29e444 |
|
|
|
29e444 |
for (line = 1; line <= 3; ++line)
|
|
|
29e444 |
{
|
|
|
29e444 |
- cnt = ((ysize - 40) * (maxsize_heap / 4 * line / heap_scale)) /
|
|
|
29e444 |
- (maxsize_heap / heap_scale);
|
|
|
29e444 |
- gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
|
|
|
29e444 |
- ysize - 20 - cnt, red);
|
|
|
29e444 |
- snprintf (buf, sizeof (buf), heap_format, maxsize_heap / 4 * line /
|
|
|
29e444 |
- heap_scale);
|
|
|
29e444 |
- gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
|
|
|
29e444 |
- ysize - 26 - cnt, (unsigned char *) buf, red);
|
|
|
29e444 |
-
|
|
|
29e444 |
- cnt2 = ((ysize - 40) * (maxsize_stack / 4 * line / stack_scale)) /
|
|
|
29e444 |
- (maxsize_stack / stack_scale);
|
|
|
29e444 |
+ if (maxsize_heap > 0)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ cnt = (((ysize - 40) * (maxsize_heap / 4 * line / heap_scale))
|
|
|
29e444 |
+ / (maxsize_heap / heap_scale));
|
|
|
29e444 |
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
|
|
|
29e444 |
+ ysize - 20 - cnt, red);
|
|
|
29e444 |
+ snprintf (buf, sizeof (buf), heap_format,
|
|
|
29e444 |
+ maxsize_heap / 4 * line / heap_scale);
|
|
|
29e444 |
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
|
|
|
29e444 |
+ ysize - 26 - cnt, (unsigned char *) buf, red);
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+ else
|
|
|
29e444 |
+ cnt = 0;
|
|
|
29e444 |
+
|
|
|
29e444 |
+ if (maxsize_stack > 0)
|
|
|
29e444 |
+ cnt2 = (((ysize - 40) * (maxsize_stack / 4 * line / stack_scale))
|
|
|
29e444 |
+ / (maxsize_stack / stack_scale));
|
|
|
29e444 |
+ else
|
|
|
29e444 |
+ cnt2 = 0;
|
|
|
29e444 |
+
|
|
|
29e444 |
if (cnt != cnt2)
|
|
|
29e444 |
gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
|
|
|
29e444 |
ysize - 20 - cnt2, green);
|
|
|
29e444 |
@@ -372,7 +381,7 @@ main (int argc, char *argv[])
|
|
|
29e444 |
ysize - 14, yellow);
|
|
|
29e444 |
previously = now;
|
|
|
29e444 |
|
|
|
29e444 |
- if (also_total)
|
|
|
29e444 |
+ if (also_total && maxsize_heap > 0)
|
|
|
29e444 |
{
|
|
|
29e444 |
size_t new3;
|
|
|
29e444 |
|
|
|
29e444 |
@@ -386,21 +395,27 @@ main (int argc, char *argv[])
|
|
|
29e444 |
last_total = new3;
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
- // assert (entry.heap <= maxsize_heap);
|
|
|
29e444 |
- new[0] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
- * entry.heap) / maxsize_heap);
|
|
|
29e444 |
- gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
|
|
|
29e444 |
- last_heap, 40 + ((xsize - 80) * cnt) / total, new[0],
|
|
|
29e444 |
- red);
|
|
|
29e444 |
- last_heap = new[0];
|
|
|
29e444 |
-
|
|
|
29e444 |
- // assert (entry.stack <= maxsize_stack);
|
|
|
29e444 |
- new[1] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
- * entry.stack) / maxsize_stack);
|
|
|
29e444 |
- gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
|
|
|
29e444 |
- last_stack, 40 + ((xsize - 80) * cnt) / total, new[1],
|
|
|
29e444 |
- green);
|
|
|
29e444 |
- last_stack = new[1];
|
|
|
29e444 |
+ if (maxsize_heap > 0)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ new[0] = ((ysize - 20)
|
|
|
29e444 |
+ - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
+ * entry.heap) / maxsize_heap));
|
|
|
29e444 |
+ gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
|
|
|
29e444 |
+ last_heap, 40 + ((xsize - 80) * cnt) / total,
|
|
|
29e444 |
+ new[0], red);
|
|
|
29e444 |
+ last_heap = new[0];
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+
|
|
|
29e444 |
+ if (maxsize_stack > 0)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ new[1] = ((ysize - 20)
|
|
|
29e444 |
+ - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
+ * entry.stack) / maxsize_stack));
|
|
|
29e444 |
+ gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
|
|
|
29e444 |
+ last_stack, 40 + ((xsize - 80) * cnt) / total,
|
|
|
29e444 |
+ new[1], green);
|
|
|
29e444 |
+ last_stack = new[1];
|
|
|
29e444 |
+ }
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
cnt = 0;
|
|
|
29e444 |
@@ -448,7 +463,7 @@ main (int argc, char *argv[])
|
|
|
29e444 |
next_tick += MAX (1, total / 20);
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
- if (also_total)
|
|
|
29e444 |
+ if (also_total && maxsize_heap > 0)
|
|
|
29e444 |
{
|
|
|
29e444 |
size_t new3;
|
|
|
29e444 |
|
|
|
29e444 |
@@ -459,16 +474,24 @@ main (int argc, char *argv[])
|
|
|
29e444 |
last_total = new3;
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
- new[0] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
- * entry.heap) / maxsize_heap);
|
|
|
29e444 |
- gdImageLine (im_out, last_xpos, last_heap, xpos, new[0], red);
|
|
|
29e444 |
- last_heap = new[0];
|
|
|
29e444 |
+ if (maxsize_heap > 0)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ new[0] = ((ysize - 20)
|
|
|
29e444 |
+ - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
+ * entry.heap) / maxsize_heap));
|
|
|
29e444 |
+ gdImageLine (im_out, last_xpos, last_heap, xpos, new[0], red);
|
|
|
29e444 |
+ last_heap = new[0];
|
|
|
29e444 |
+ }
|
|
|
29e444 |
|
|
|
29e444 |
- // assert (entry.stack <= maxsize_stack);
|
|
|
29e444 |
- new[1] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
- * entry.stack) / maxsize_stack);
|
|
|
29e444 |
- gdImageLine (im_out, last_xpos, last_stack, xpos, new[1], green);
|
|
|
29e444 |
- last_stack = new[1];
|
|
|
29e444 |
+ if (maxsize_stack > 0)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ new[1] = ((ysize - 20)
|
|
|
29e444 |
+ - ((((unsigned long long int) (ysize - 40))
|
|
|
29e444 |
+ * entry.stack) / maxsize_stack));
|
|
|
29e444 |
+ gdImageLine (im_out, last_xpos, last_stack, xpos, new[1],
|
|
|
29e444 |
+ green);
|
|
|
29e444 |
+ last_stack = new[1];
|
|
|
29e444 |
+ }
|
|
|
29e444 |
|
|
|
29e444 |
last_xpos = xpos;
|
|
|
29e444 |
}
|