Lines Matching refs:main
302 $main::tmpfile_sym = "/tmp/jeprof$$.sym";
303 $main::tmpfile_ps = "/tmp/jeprof$$";
304 $main::next_tmpfile = 0;
308 $main::source_cache = ();
310 $main::opt_help = 0;
311 $main::opt_version = 0;
313 $main::opt_cum = 0;
314 $main::opt_base = '';
315 $main::opt_addresses = 0;
316 $main::opt_lines = 0;
317 $main::opt_functions = 0;
318 $main::opt_files = 0;
319 $main::opt_lib_prefix = "";
321 $main::opt_text = 0;
322 $main::opt_callgrind = 0;
323 $main::opt_list = "";
324 $main::opt_disasm = "";
325 $main::opt_symbols = 0;
326 $main::opt_gv = 0;
327 $main::opt_evince = 0;
328 $main::opt_web = 0;
329 $main::opt_dot = 0;
330 $main::opt_ps = 0;
331 $main::opt_pdf = 0;
332 $main::opt_gif = 0;
333 $main::opt_svg = 0;
334 $main::opt_raw = 0;
336 $main::opt_nodecount = 80;
337 $main::opt_nodefraction = 0.005;
338 $main::opt_edgefraction = 0.001;
339 $main::opt_maxdegree = 8;
340 $main::opt_focus = '';
341 $main::opt_thread = undef;
342 $main::opt_ignore = '';
343 $main::opt_scale = 0;
344 $main::opt_heapcheck = 0;
345 $main::opt_retain = '';
346 $main::opt_exclude = '';
347 $main::opt_seconds = 30;
348 $main::opt_lib = "";
350 $main::opt_inuse_space = 0;
351 $main::opt_inuse_objects = 0;
352 $main::opt_alloc_space = 0;
353 $main::opt_alloc_objects = 0;
354 $main::opt_show_bytes = 0;
355 $main::opt_drop_negative = 0;
356 $main::opt_interactive = 0;
358 $main::opt_total_delay = 0;
359 $main::opt_contentions = 0;
360 $main::opt_mean_delay = 0;
362 $main::opt_tools = "";
363 $main::opt_debug = 0;
364 $main::opt_test = 0;
367 $main::opt_test_stride = 0;
370 $main::use_symbol_page = 0;
373 %main::tempnames = ();
381 $main::profile_type = ''; # Empty type means "unknown"
383 GetOptions("help!" => \$main::opt_help,
384 "version!" => \$main::opt_version,
385 "cum!" => \$main::opt_cum,
386 "base=s" => \$main::opt_base,
387 "seconds=i" => \$main::opt_seconds,
388 "add_lib=s" => \$main::opt_lib,
389 "lib_prefix=s" => \$main::opt_lib_prefix,
390 "functions!" => \$main::opt_functions,
391 "lines!" => \$main::opt_lines,
392 "addresses!" => \$main::opt_addresses,
393 "files!" => \$main::opt_files,
394 "text!" => \$main::opt_text,
395 "callgrind!" => \$main::opt_callgrind,
396 "list=s" => \$main::opt_list,
397 "disasm=s" => \$main::opt_disasm,
398 "symbols!" => \$main::opt_symbols,
399 "gv!" => \$main::opt_gv,
400 "evince!" => \$main::opt_evince,
401 "web!" => \$main::opt_web,
402 "dot!" => \$main::opt_dot,
403 "ps!" => \$main::opt_ps,
404 "pdf!" => \$main::opt_pdf,
405 "svg!" => \$main::opt_svg,
406 "gif!" => \$main::opt_gif,
407 "raw!" => \$main::opt_raw,
408 "interactive!" => \$main::opt_interactive,
409 "nodecount=i" => \$main::opt_nodecount,
410 "nodefraction=f" => \$main::opt_nodefraction,
411 "edgefraction=f" => \$main::opt_edgefraction,
412 "maxdegree=i" => \$main::opt_maxdegree,
413 "focus=s" => \$main::opt_focus,
414 "thread=s" => \$main::opt_thread,
415 "ignore=s" => \$main::opt_ignore,
416 "scale=i" => \$main::opt_scale,
417 "heapcheck" => \$main::opt_heapcheck,
418 "retain=s" => \$main::opt_retain,
419 "exclude=s" => \$main::opt_exclude,
420 "inuse_space!" => \$main::opt_inuse_space,
421 "inuse_objects!" => \$main::opt_inuse_objects,
422 "alloc_space!" => \$main::opt_alloc_space,
423 "alloc_objects!" => \$main::opt_alloc_objects,
424 "show_bytes!" => \$main::opt_show_bytes,
425 "drop_negative!" => \$main::opt_drop_negative,
426 "total_delay!" => \$main::opt_total_delay,
427 "contentions!" => \$main::opt_contentions,
428 "mean_delay!" => \$main::opt_mean_delay,
429 "tools=s" => \$main::opt_tools,
430 "test!" => \$main::opt_test,
431 "debug!" => \$main::opt_debug,
433 "test_stride=i" => \$main::opt_test_stride,
437 if ($main::opt_help) {
442 if ($main::opt_version) {
448 if ($main::opt_disasm || $main::opt_list || $main::opt_symbols) {
449 $main::opt_functions = 0;
450 $main::opt_lines = 0;
451 $main::opt_addresses = 1;
452 $main::opt_files = 0;
456 if ($main::opt_inuse_space +
457 $main::opt_inuse_objects +
458 $main::opt_alloc_space +
459 $main::opt_alloc_objects > 1) {
465 $main::opt_functions +
466 $main::opt_lines +
467 $main::opt_addresses +
468 $main::opt_files +
474 $main::opt_functions = 1;
479 $main::opt_text +
480 $main::opt_callgrind +
481 ($main::opt_list eq '' ? 0 : 1) +
482 ($main::opt_disasm eq '' ? 0 : 1) +
483 ($main::opt_symbols == 0 ? 0 : 1) +
484 $main::opt_gv +
485 $main::opt_evince +
486 $main::opt_web +
487 $main::opt_dot +
488 $main::opt_ps +
489 $main::opt_pdf +
490 $main::opt_svg +
491 $main::opt_gif +
492 $main::opt_raw +
493 $main::opt_interactive +
500 $main::opt_interactive = 1;
502 $main::opt_text = 1;
506 if ($main::opt_test) {
513 $main::prog = "";
514 @main::pfile_args = ();
519 $main::use_symbol_page = 1;
521 $main::use_symbolized_profile = 1;
522 $main::prog = $UNKNOWN_BINARY; # will be set later from the profile file
526 if ($main::use_symbol_page || $main::use_symbolized_profile) {
528 my %disabled = ('--lines' => $main::opt_lines,
529 '--disasm' => $main::opt_disasm);
535 } elsif ($main::opt_symbols) {
537 $main::prog = shift(@ARGV) || usage("Did not specify program");
539 $main::prog = shift(@ARGV) || usage("Did not specify program");
550 unshift(@main::pfile_args, "$i.$machine$path");
553 unshift(@main::pfile_args, $farg);
557 if ($main::use_symbol_page) {
558 unless (IsProfileURL($main::pfile_args[0])) {
562 $main::prog = FetchProgramName();
563 } elsif (!$main::use_symbolized_profile) { # may not need objtools!
564 ConfigureObjTools($main::prog)
568 @prefix_list = split (',', $main::opt_lib_prefix);
587 if ($main::opt_focus ne '') {
588 $profile = FocusProfile($symbols, $profile, $main::opt_focus);
592 if ($main::opt_ignore ne '') {
593 $profile = IgnoreProfile($symbols, $profile, $main::opt_ignore);
607 if (!$main::opt_interactive) {
608 if ($main::opt_disasm) {
609 PrintDisassembly($libs, $flat, $cumulative, $main::opt_disasm);
610 } elsif ($main::opt_list) {
611 PrintListing($total, $libs, $flat, $cumulative, $main::opt_list, 0);
612 } elsif ($main::opt_text) {
622 } elsif ($main::opt_raw) {
623 PrintSymbolizedProfile($symbols, $profile, $main::prog);
624 } elsif ($main::opt_callgrind) {
627 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
628 if ($main::opt_gv) {
629 RunGV(TempName($main::next_tmpfile, "ps"), "");
630 } elsif ($main::opt_evince) {
631 RunEvince(TempName($main::next_tmpfile, "pdf"), "");
632 } elsif ($main::opt_web) {
633 my $tmp = TempName($main::next_tmpfile, "svg");
640 delete $main::tempnames{$tmp};
659 $main::collected_profile = undef;
660 @main::profile_files = ();
661 $main::op_time = time();
664 if ($main::opt_symbols) {
676 my $data = ReadProfile($main::prog, pop(@main::profile_files));
683 if (scalar(@main::profile_files) > 0) {
684 foreach my $pname (@main::profile_files) {
685 my $data2 = ReadProfile($main::prog, $pname);
693 if ($main::opt_base ne '') {
694 my $base = ReadProfile($main::prog, $main::opt_base);
702 if ($main::use_symbolized_profile) {
704 } elsif ($main::use_symbol_page) {
714 if (!defined($main::opt_thread)) {
719 if (defined($main::opt_thread) &&
720 ($main::opt_thread eq '*' || $main::opt_thread == $thread)) {
757 system(ShellEscape(@GV, "--scale=$main::opt_scale", "--noantialias", $fname)
761 print STDERR ShellEscape(@GV, "-scale", $main::opt_scale) . "\n";
762 system(ShellEscape(@GV, "-scale", "$main::opt_scale", $fname) . $bg);
835 my $save_opt_lines = $main::opt_lines;
842 $main::opt_lines = $save_opt_lines;
864 $main::opt_text = 0;
865 $main::opt_callgrind = 0;
866 $main::opt_disasm = 0;
867 $main::opt_list = 0;
868 $main::opt_gv = 0;
869 $main::opt_evince = 0;
870 $main::opt_cum = 0;
873 $main::opt_text = 1;
892 $main::opt_callgrind = 1;
898 $filename = TempName($main::next_tmpfile, "callgrind");
903 $main::next_tmpfile++;
910 $main::opt_list = 1;
927 $main::opt_disasm = 1;
945 $main::opt_gv = 0;
946 $main::opt_evince = 0;
947 $main::opt_web = 0;
949 $main::opt_gv = 1;
951 $main::opt_evince = 1;
953 $main::opt_web = 1;
969 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
970 if ($main::opt_gv) {
971 RunGV(TempName($main::next_tmpfile, "ps"), " &");
972 } elsif ($main::opt_evince) {
973 RunEvince(TempName($main::next_tmpfile, "pdf"), " &");
974 } elsif ($main::opt_web) {
975 RunWeb(TempName($main::next_tmpfile, "svg"));
977 $main::next_tmpfile++;
1085 $main::opt_lines = 1;
1087 $main::opt_cum = 1;
1105 my $file = "$main::tmpfile_ps.$fnum.$ext";
1106 $main::tempnames{$file} = 1;
1171 if ($main::profile_type eq 'heap') {
1174 } elsif ($main::profile_type eq 'growth') {
1177 } elsif ($main::profile_type eq 'contention') {
1186 if (defined($main::collected_profile)) {
1188 open(SRC, "<$main::collected_profile");
1215 my $s = $main::opt_cum ? $cumulative : $flat;
1228 if ($main::opt_addresses) {
1276 if ($main::opt_interactive) {
1403 my $libs = ParseLibraries($main::prog, $map, $pcs);
1432 $fname = TempName($main::next_tmpfile, "html");
1433 $main::next_tmpfile++;
1441 $main::prog, Unparse($total), Units());
1877 if (!defined($main::source_cache{$file})) {
1878 if (100 < scalar keys(%main::source_cache)) {
1880 $main::source_cache = ();
1886 $main::source_cache{$file} = []; # Cache the negative result
1897 $main::source_cache{$file} = $lines;
1900 my $lines = $main::source_cache{$file};
2030 my $nodelimit = int($main::opt_nodefraction * $local_total);
2031 my $edgelimit = int($main::opt_edgefraction * $local_total);
2032 my $nodecount = $main::opt_nodecount;
2062 if ($main::opt_gv) {
2063 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "ps"));
2065 } elsif ($main::opt_evince) {
2066 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "pdf"));
2068 } elsif ($main::opt_ps) {
2070 } elsif ($main::opt_pdf) {
2072 } elsif ($main::opt_web || $main::opt_svg) {
2074 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "svg"));
2076 } elsif ($main::opt_gif) {
2088 if ($main::opt_pdf) {
2132 if ($main::opt_heapcheck) {
2198 } elsif ($outdegree{$src} >= $main::opt_maxdegree ||
2199 $indegree{$dst} >= $main::opt_maxdegree) {
2214 if ($w < 1 && ($main::opt_web || $main::opt_svg)) {
2243 if ($main::opt_web || $main::opt_svg) {
2245 RewriteSvg(TempName($main::next_tmpfile, "svg"));
2293 if ($main::opt_svg) {
2596 my $id = $main::uniqueid{$key};
2598 $id = keys(%main::uniqueid) + 1;
2599 $main::uniqueid{$key} = $id;
2620 if ($main::opt_disasm || $main::opt_list) {
2654 if ($main::opt_addresses) {
2656 } elsif ($main::opt_lines) {
2662 } elsif ($main::opt_functions) {
2668 } elsif ($main::opt_files) {
2701 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2702 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2705 if ($main::opt_show_bytes) {
2711 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2740 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2741 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2744 if ($main::opt_show_bytes) {
2750 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2854 if ($main::opt_retain eq '' && $main::opt_exclude eq '') {
2870 if ($main::opt_retain ne '' && $sym !~ m/$main::opt_retain/) {
2873 if ($main::opt_exclude ne '' && $sym =~ m/$main::opt_exclude/) {
2894 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2958 } elsif ($main::profile_type eq 'contention') {
2971 } elsif ($main::profile_type eq 'cpu') {
2987 if ($main::profile_type eq 'cpu') {
3196 if ($v < 0 && $main::opt_drop_negative) {
3201 if (!$main::opt_drop_negative) {
3306 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3311 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3377 if ($main::prog ne $UNKNOWN_BINARY && $main::prog ne $value) {
3379 $main::prog, $value);
3381 $main::prog = $value;
3400 if ($main::opt_retain ne '') {
3401 push(@params, sprintf("retain=%s", URLEncode($main::opt_retain)));
3403 if ($main::opt_exclude ne '') {
3404 push(@params, sprintf("exclude=%s", URLEncode($main::opt_exclude)));
3427 open(POSTFILE, ">$main::tmpfile_sym");
3437 $command_line = ShellEscape(@URL_FETCHER, "-d", "\@$main::tmpfile_sym",
3442 . " < " . ShellEscape($main::tmpfile_sym));
3491 $binary_shortname, $main::op_time, $host);
3519 $url .= sprintf("seconds=%d", $main::opt_seconds);
3520 $fetch_timeout = $main::opt_seconds * 1.01 + 60;
3522 $main::profile_type = 'cpu';
3531 $main::profile_type = 'heap';
3533 $main::profile_type = 'growth';
3535 $main::profile_type = 'contention';
3554 …print STDERR "Gathering CPU profile from $url for $main::opt_seconds seconds to\n ${real_profile}…
3565 $main::collected_profile = $real_profile;
3566 return $main::collected_profile;
3572 my $items = scalar(@main::pfile_args);
3576 $main::profile_files[0] = FetchDynamicProfile($main::prog, $main::pfile_args[0], 0, 1);
3582 my $count = scalar(@main::pfile_args);
3584 $main::profile_files[$i] = FetchDynamicProfile($main::prog, $main::pfile_args[$i], 1, 0);
3588 $main::collected_profile = join(" \\\n ", @main::profile_files);
3618 if ($position < scalar(@main::pfile_args)) {
3619 FetchDynamicProfile($main::prog, $main::pfile_args[$position], 0, 0);
3649 if ($main::opt_test_stride > 0) {
3650 $self->{stride} = $main::opt_test_stride;
3851 if (!$main::use_symbolized_profile) {
3867 $main::profile_type = '';
3870 $main::profile_type = 'growth';
3873 $main::profile_type = 'heap';
3876 $main::profile_type = 'heap';
3879 $main::profile_type = 'contention';
3885 $main::profile_type = 'contention';
3889 $main::profile_type = 'cpu';
3897 $main::profile_type = 'cpu';
4017 if ($main::opt_inuse_space) {
4019 } elsif ($main::opt_inuse_objects) {
4021 } elsif ($main::opt_alloc_space) {
4023 } elsif ($main::opt_alloc_objects) {
4315 if ($main::opt_total_delay) {
4317 } elsif ($main::opt_contentions) {
4319 } elsif ($main::opt_mean_delay) {
4575 return if $main::use_symbol_page; # We don't need libraries info.
4654 if($main::opt_debug) { printf STDERR "$start:$finish ($offset) $lib\n"; }
4659 if ($main::opt_lib ne "") {
4660 my $text = ParseTextSectionHeader($main::opt_lib);
4665 push(@{$result}, [$main::opt_lib, $start, $finish, $start]);
4698 if ($main::opt_debug and $main::opt_test) {
4730 if ($main::opt_debug and $main::opt_test) { print STDERR "$r\n"; }
4940 open(ADDRESSES, ">$main::tmpfile_sym") || error("$main::tmpfile_sym: $!\n");
4953 system("cat", $main::tmpfile_sym);
4955 system("$cmd < " . ShellEscape($main::tmpfile_sym));
4959 open(SYMBOLS, "$cmd <" . ShellEscape($main::tmpfile_sym) . " |")
5173 my $tools = $main::opt_tools || $ENV{"JEPROF_TOOLS"} || "";
5200 if ($main::opt_debug) { print STDERR "Using '$path' for '$tool'.\n"; }
5218 unlink($main::tmpfile_sym);
5219 unlink(keys %main::tempnames);
5223 if ((scalar(@main::profile_files) > 0) &&
5224 defined($main::collected_profile)) {
5225 if (scalar(@main::profile_files) == 1) {
5226 print STDERR "Dynamically gathered profile is in $main::collected_profile\n";
5231 print STDERR " $main::prog \\\n";
5232 print STDERR " $main::collected_profile\n";
5310 if ($main::opt_debug) { print STDERR "Using Image $1\n"; }
5313 if ($main::opt_debug) { print STDERR "Using PDB $1\n"; }
5436 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5455 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5488 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5507 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5539 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5558 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }