aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-04-30 08:14:37 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-30 08:14:37 -0400
commitbad760089c1ef7fe525c0f268a4078b9cb483903 (patch)
tree4c1d98198a8f0058932144bdff43a6041a0ad694
parent66cf782996f3d57d3cc199f0a2d47a54e2aa5991 (diff)
perf_counter tools: fix infinite loop in perf-report on zeroed event records
Bail out early if a record has zero size - we have no chance to make reliable progress in that case. Print out the offset where this happens, and print the number of bytes we missed out on. Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--Documentation/perf_counter/perf-report.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/Documentation/perf_counter/perf-report.cc b/Documentation/perf_counter/perf-report.cc
index 1727317352bf..933a07544534 100644
--- a/Documentation/perf_counter/perf-report.cc
+++ b/Documentation/perf_counter/perf-report.cc
@@ -13,6 +13,7 @@
13#include <ctype.h> 13#include <ctype.h>
14#include <time.h> 14#include <time.h>
15#include <getopt.h> 15#include <getopt.h>
16#include <assert.h>
16 17
17#include <sys/ioctl.h> 18#include <sys/ioctl.h>
18#include <sys/poll.h> 19#include <sys/poll.h>
@@ -226,7 +227,7 @@ void load_kallsyms(void)
226 while (!feof(file)) { 227 while (!feof(file)) {
227 uint64_t start; 228 uint64_t start;
228 char c; 229 char c;
229 char sym[1024]; 230 char sym[1024000];
230 231
231 if (getline(&line, &n, file) < 0) 232 if (getline(&line, &n, file) < 0)
232 break; 233 break;
@@ -416,12 +417,23 @@ more:
416 417
417 if (head + event->header.size >= page_size * mmap_window) { 418 if (head + event->header.size >= page_size * mmap_window) {
418 unsigned long shift = page_size * (head / page_size); 419 unsigned long shift = page_size * (head / page_size);
420 int ret;
421
422 ret = munmap(buf, page_size * mmap_window);
423 assert(ret == 0);
419 424
420 munmap(buf, page_size * mmap_window);
421 offset += shift; 425 offset += shift;
422 head -= shift; 426 head -= shift;
423 goto remap; 427 goto remap;
424 } 428 }
429
430
431 if (!event->header.size) {
432 fprintf(stderr, "zero-sized event at file offset %ld\n", offset + head);
433 fprintf(stderr, "skipping %ld bytes of events.\n", stat.st_size - offset - head);
434 goto done;
435 }
436
425 head += event->header.size; 437 head += event->header.size;
426 438
427 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) { 439 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
@@ -458,6 +470,8 @@ more:
458 if (offset + head < stat.st_size) 470 if (offset + head < stat.st_size)
459 goto more; 471 goto more;
460 472
473done:
474
461 close(input); 475 close(input);
462 476
463 std::map<std::string, int>::iterator hi = hist.begin(); 477 std::map<std::string, int>::iterator hi = hist.begin();