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