Lines Matching refs:main

301   $main::tmpfile_sym = "/tmp/jeprof$$.sym";
302 $main::tmpfile_ps = "/tmp/jeprof$$";
303 $main::next_tmpfile = 0;
307 $main::source_cache = ();
309 $main::opt_help = 0;
310 $main::opt_version = 0;
312 $main::opt_cum = 0;
313 $main::opt_base = '';
314 $main::opt_addresses = 0;
315 $main::opt_lines = 0;
316 $main::opt_functions = 0;
317 $main::opt_files = 0;
318 $main::opt_lib_prefix = "";
320 $main::opt_text = 0;
321 $main::opt_callgrind = 0;
322 $main::opt_list = "";
323 $main::opt_disasm = "";
324 $main::opt_symbols = 0;
325 $main::opt_gv = 0;
326 $main::opt_evince = 0;
327 $main::opt_web = 0;
328 $main::opt_dot = 0;
329 $main::opt_ps = 0;
330 $main::opt_pdf = 0;
331 $main::opt_gif = 0;
332 $main::opt_svg = 0;
333 $main::opt_raw = 0;
335 $main::opt_nodecount = 80;
336 $main::opt_nodefraction = 0.005;
337 $main::opt_edgefraction = 0.001;
338 $main::opt_maxdegree = 8;
339 $main::opt_focus = '';
340 $main::opt_thread = undef;
341 $main::opt_ignore = '';
342 $main::opt_scale = 0;
343 $main::opt_heapcheck = 0;
344 $main::opt_retain = '';
345 $main::opt_exclude = '';
346 $main::opt_seconds = 30;
347 $main::opt_lib = "";
349 $main::opt_inuse_space = 0;
350 $main::opt_inuse_objects = 0;
351 $main::opt_alloc_space = 0;
352 $main::opt_alloc_objects = 0;
353 $main::opt_show_bytes = 0;
354 $main::opt_drop_negative = 0;
355 $main::opt_interactive = 0;
357 $main::opt_total_delay = 0;
358 $main::opt_contentions = 0;
359 $main::opt_mean_delay = 0;
361 $main::opt_tools = "";
362 $main::opt_debug = 0;
363 $main::opt_test = 0;
366 $main::opt_test_stride = 0;
369 $main::use_symbol_page = 0;
372 %main::tempnames = ();
380 $main::profile_type = ''; # Empty type means "unknown"
382 GetOptions("help!" => \$main::opt_help,
383 "version!" => \$main::opt_version,
384 "cum!" => \$main::opt_cum,
385 "base=s" => \$main::opt_base,
386 "seconds=i" => \$main::opt_seconds,
387 "add_lib=s" => \$main::opt_lib,
388 "lib_prefix=s" => \$main::opt_lib_prefix,
389 "functions!" => \$main::opt_functions,
390 "lines!" => \$main::opt_lines,
391 "addresses!" => \$main::opt_addresses,
392 "files!" => \$main::opt_files,
393 "text!" => \$main::opt_text,
394 "callgrind!" => \$main::opt_callgrind,
395 "list=s" => \$main::opt_list,
396 "disasm=s" => \$main::opt_disasm,
397 "symbols!" => \$main::opt_symbols,
398 "gv!" => \$main::opt_gv,
399 "evince!" => \$main::opt_evince,
400 "web!" => \$main::opt_web,
401 "dot!" => \$main::opt_dot,
402 "ps!" => \$main::opt_ps,
403 "pdf!" => \$main::opt_pdf,
404 "svg!" => \$main::opt_svg,
405 "gif!" => \$main::opt_gif,
406 "raw!" => \$main::opt_raw,
407 "interactive!" => \$main::opt_interactive,
408 "nodecount=i" => \$main::opt_nodecount,
409 "nodefraction=f" => \$main::opt_nodefraction,
410 "edgefraction=f" => \$main::opt_edgefraction,
411 "maxdegree=i" => \$main::opt_maxdegree,
412 "focus=s" => \$main::opt_focus,
413 "thread=s" => \$main::opt_thread,
414 "ignore=s" => \$main::opt_ignore,
415 "scale=i" => \$main::opt_scale,
416 "heapcheck" => \$main::opt_heapcheck,
417 "retain=s" => \$main::opt_retain,
418 "exclude=s" => \$main::opt_exclude,
419 "inuse_space!" => \$main::opt_inuse_space,
420 "inuse_objects!" => \$main::opt_inuse_objects,
421 "alloc_space!" => \$main::opt_alloc_space,
422 "alloc_objects!" => \$main::opt_alloc_objects,
423 "show_bytes!" => \$main::opt_show_bytes,
424 "drop_negative!" => \$main::opt_drop_negative,
425 "total_delay!" => \$main::opt_total_delay,
426 "contentions!" => \$main::opt_contentions,
427 "mean_delay!" => \$main::opt_mean_delay,
428 "tools=s" => \$main::opt_tools,
429 "test!" => \$main::opt_test,
430 "debug!" => \$main::opt_debug,
432 "test_stride=i" => \$main::opt_test_stride,
436 if ($main::opt_help) {
441 if ($main::opt_version) {
447 if ($main::opt_disasm || $main::opt_list || $main::opt_symbols) {
448 $main::opt_functions = 0;
449 $main::opt_lines = 0;
450 $main::opt_addresses = 1;
451 $main::opt_files = 0;
455 if ($main::opt_inuse_space +
456 $main::opt_inuse_objects +
457 $main::opt_alloc_space +
458 $main::opt_alloc_objects > 1) {
464 $main::opt_functions +
465 $main::opt_lines +
466 $main::opt_addresses +
467 $main::opt_files +
473 $main::opt_functions = 1;
478 $main::opt_text +
479 $main::opt_callgrind +
480 ($main::opt_list eq '' ? 0 : 1) +
481 ($main::opt_disasm eq '' ? 0 : 1) +
482 ($main::opt_symbols == 0 ? 0 : 1) +
483 $main::opt_gv +
484 $main::opt_evince +
485 $main::opt_web +
486 $main::opt_dot +
487 $main::opt_ps +
488 $main::opt_pdf +
489 $main::opt_svg +
490 $main::opt_gif +
491 $main::opt_raw +
492 $main::opt_interactive +
499 $main::opt_interactive = 1;
501 $main::opt_text = 1;
505 if ($main::opt_test) {
512 $main::prog = "";
513 @main::pfile_args = ();
518 $main::use_symbol_page = 1;
520 $main::use_symbolized_profile = 1;
521 $main::prog = $UNKNOWN_BINARY; # will be set later from the profile file
525 if ($main::use_symbol_page || $main::use_symbolized_profile) {
527 my %disabled = ('--lines' => $main::opt_lines,
528 '--disasm' => $main::opt_disasm);
534 } elsif ($main::opt_symbols) {
536 $main::prog = shift(@ARGV) || usage("Did not specify program");
538 $main::prog = shift(@ARGV) || usage("Did not specify program");
549 unshift(@main::pfile_args, "$i.$machine$path");
552 unshift(@main::pfile_args, $farg);
556 if ($main::use_symbol_page) {
557 unless (IsProfileURL($main::pfile_args[0])) {
561 $main::prog = FetchProgramName();
562 } elsif (!$main::use_symbolized_profile) { # may not need objtools!
563 ConfigureObjTools($main::prog)
567 @prefix_list = split (',', $main::opt_lib_prefix);
586 if ($main::opt_focus ne '') {
587 $profile = FocusProfile($symbols, $profile, $main::opt_focus);
591 if ($main::opt_ignore ne '') {
592 $profile = IgnoreProfile($symbols, $profile, $main::opt_ignore);
606 if (!$main::opt_interactive) {
607 if ($main::opt_disasm) {
608 PrintDisassembly($libs, $flat, $cumulative, $main::opt_disasm);
609 } elsif ($main::opt_list) {
610 PrintListing($total, $libs, $flat, $cumulative, $main::opt_list, 0);
611 } elsif ($main::opt_text) {
621 } elsif ($main::opt_raw) {
622 PrintSymbolizedProfile($symbols, $profile, $main::prog);
623 } elsif ($main::opt_callgrind) {
626 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
627 if ($main::opt_gv) {
628 RunGV(TempName($main::next_tmpfile, "ps"), "");
629 } elsif ($main::opt_evince) {
630 RunEvince(TempName($main::next_tmpfile, "pdf"), "");
631 } elsif ($main::opt_web) {
632 my $tmp = TempName($main::next_tmpfile, "svg");
639 delete $main::tempnames{$tmp};
658 $main::collected_profile = undef;
659 @main::profile_files = ();
660 $main::op_time = time();
663 if ($main::opt_symbols) {
675 my $data = ReadProfile($main::prog, pop(@main::profile_files));
682 if (scalar(@main::profile_files) > 0) {
683 foreach my $pname (@main::profile_files) {
684 my $data2 = ReadProfile($main::prog, $pname);
692 if ($main::opt_base ne '') {
693 my $base = ReadProfile($main::prog, $main::opt_base);
701 if ($main::use_symbolized_profile) {
703 } elsif ($main::use_symbol_page) {
713 if (!defined($main::opt_thread)) {
718 if (defined($main::opt_thread) &&
719 ($main::opt_thread eq '*' || $main::opt_thread == $thread)) {
756 system(ShellEscape(@GV, "--scale=$main::opt_scale", "--noantialias", $fname)
760 print STDERR ShellEscape(@GV, "-scale", $main::opt_scale) . "\n";
761 system(ShellEscape(@GV, "-scale", "$main::opt_scale", $fname) . $bg);
834 my $save_opt_lines = $main::opt_lines;
841 $main::opt_lines = $save_opt_lines;
863 $main::opt_text = 0;
864 $main::opt_callgrind = 0;
865 $main::opt_disasm = 0;
866 $main::opt_list = 0;
867 $main::opt_gv = 0;
868 $main::opt_evince = 0;
869 $main::opt_cum = 0;
872 $main::opt_text = 1;
891 $main::opt_callgrind = 1;
897 $filename = TempName($main::next_tmpfile, "callgrind");
902 $main::next_tmpfile++;
909 $main::opt_list = 1;
926 $main::opt_disasm = 1;
944 $main::opt_gv = 0;
945 $main::opt_evince = 0;
946 $main::opt_web = 0;
948 $main::opt_gv = 1;
950 $main::opt_evince = 1;
952 $main::opt_web = 1;
968 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
969 if ($main::opt_gv) {
970 RunGV(TempName($main::next_tmpfile, "ps"), " &");
971 } elsif ($main::opt_evince) {
972 RunEvince(TempName($main::next_tmpfile, "pdf"), " &");
973 } elsif ($main::opt_web) {
974 RunWeb(TempName($main::next_tmpfile, "svg"));
976 $main::next_tmpfile++;
1084 $main::opt_lines = 1;
1086 $main::opt_cum = 1;
1104 my $file = "$main::tmpfile_ps.$fnum.$ext";
1105 $main::tempnames{$file} = 1;
1170 if ($main::profile_type eq 'heap') {
1173 } elsif ($main::profile_type eq 'growth') {
1176 } elsif ($main::profile_type eq 'contention') {
1185 if (defined($main::collected_profile)) {
1187 open(SRC, "<$main::collected_profile");
1214 my $s = $main::opt_cum ? $cumulative : $flat;
1227 if ($main::opt_addresses) {
1275 if ($main::opt_interactive) {
1402 my $libs = ParseLibraries($main::prog, $map, $pcs);
1431 $fname = TempName($main::next_tmpfile, "html");
1432 $main::next_tmpfile++;
1440 $main::prog, Unparse($total), Units());
1876 if (!defined($main::source_cache{$file})) {
1877 if (100 < scalar keys(%main::source_cache)) {
1879 $main::source_cache = ();
1885 $main::source_cache{$file} = []; # Cache the negative result
1896 $main::source_cache{$file} = $lines;
1899 my $lines = $main::source_cache{$file};
2029 my $nodelimit = int($main::opt_nodefraction * $local_total);
2030 my $edgelimit = int($main::opt_edgefraction * $local_total);
2031 my $nodecount = $main::opt_nodecount;
2061 if ($main::opt_gv) {
2062 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "ps"));
2064 } elsif ($main::opt_evince) {
2065 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "pdf"));
2067 } elsif ($main::opt_ps) {
2069 } elsif ($main::opt_pdf) {
2071 } elsif ($main::opt_web || $main::opt_svg) {
2073 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "svg"));
2075 } elsif ($main::opt_gif) {
2087 if ($main::opt_pdf) {
2131 if ($main::opt_heapcheck) {
2197 } elsif ($outdegree{$src} >= $main::opt_maxdegree ||
2198 $indegree{$dst} >= $main::opt_maxdegree) {
2213 if ($w < 1 && ($main::opt_web || $main::opt_svg)) {
2242 if ($main::opt_web || $main::opt_svg) {
2244 RewriteSvg(TempName($main::next_tmpfile, "svg"));
2292 if ($main::opt_svg) {
2595 my $id = $main::uniqueid{$key};
2597 $id = keys(%main::uniqueid) + 1;
2598 $main::uniqueid{$key} = $id;
2619 if ($main::opt_disasm || $main::opt_list) {
2653 if ($main::opt_addresses) {
2655 } elsif ($main::opt_lines) {
2661 } elsif ($main::opt_functions) {
2667 } elsif ($main::opt_files) {
2700 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2701 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2704 if ($main::opt_show_bytes) {
2710 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2739 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2740 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2743 if ($main::opt_show_bytes) {
2749 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2853 if ($main::opt_retain eq '' && $main::opt_exclude eq '') {
2869 if ($main::opt_retain ne '' && $sym !~ m/$main::opt_retain/) {
2872 if ($main::opt_exclude ne '' && $sym =~ m/$main::opt_exclude/) {
2893 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2955 } elsif ($main::profile_type eq 'contention') {
2968 } elsif ($main::profile_type eq 'cpu') {
2984 if ($main::profile_type eq 'cpu') {
3193 if ($v < 0 && $main::opt_drop_negative) {
3198 if (!$main::opt_drop_negative) {
3303 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3308 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3374 if ($main::prog ne $UNKNOWN_BINARY && $main::prog ne $value) {
3376 $main::prog, $value);
3378 $main::prog = $value;
3397 if ($main::opt_retain ne '') {
3398 push(@params, sprintf("retain=%s", URLEncode($main::opt_retain)));
3400 if ($main::opt_exclude ne '') {
3401 push(@params, sprintf("exclude=%s", URLEncode($main::opt_exclude)));
3424 open(POSTFILE, ">$main::tmpfile_sym");
3434 $command_line = ShellEscape(@URL_FETCHER, "-d", "\@$main::tmpfile_sym",
3439 . " < " . ShellEscape($main::tmpfile_sym));
3488 $binary_shortname, $main::op_time, $host);
3516 $url .= sprintf("seconds=%d", $main::opt_seconds);
3517 $fetch_timeout = $main::opt_seconds * 1.01 + 60;
3519 $main::profile_type = 'cpu';
3528 $main::profile_type = 'heap';
3530 $main::profile_type = 'growth';
3532 $main::profile_type = 'contention';
3551 …print STDERR "Gathering CPU profile from $url for $main::opt_seconds seconds to\n ${real_profile}…
3562 $main::collected_profile = $real_profile;
3563 return $main::collected_profile;
3569 my $items = scalar(@main::pfile_args);
3573 $main::profile_files[0] = FetchDynamicProfile($main::prog, $main::pfile_args[0], 0, 1);
3579 my $count = scalar(@main::pfile_args);
3581 $main::profile_files[$i] = FetchDynamicProfile($main::prog, $main::pfile_args[$i], 1, 0);
3585 $main::collected_profile = join(" \\\n ", @main::profile_files);
3615 if ($position < scalar(@main::pfile_args)) {
3616 FetchDynamicProfile($main::prog, $main::pfile_args[$position], 0, 0);
3646 if ($main::opt_test_stride > 0) {
3647 $self->{stride} = $main::opt_test_stride;
3848 if (!$main::use_symbolized_profile) {
3864 $main::profile_type = '';
3867 $main::profile_type = 'growth';
3870 $main::profile_type = 'heap';
3873 $main::profile_type = 'heap';
3876 $main::profile_type = 'contention';
3882 $main::profile_type = 'contention';
3886 $main::profile_type = 'cpu';
3894 $main::profile_type = 'cpu';
4014 if ($main::opt_inuse_space) {
4016 } elsif ($main::opt_inuse_objects) {
4018 } elsif ($main::opt_alloc_space) {
4020 } elsif ($main::opt_alloc_objects) {
4312 if ($main::opt_total_delay) {
4314 } elsif ($main::opt_contentions) {
4316 } elsif ($main::opt_mean_delay) {
4572 return if $main::use_symbol_page; # We don't need libraries info.
4641 if($main::opt_debug) { printf STDERR "$start:$finish ($offset) $lib\n"; }
4646 if ($main::opt_lib ne "") {
4647 my $text = ParseTextSectionHeader($main::opt_lib);
4652 push(@{$result}, [$main::opt_lib, $start, $finish, $start]);
4685 if ($main::opt_debug and $main::opt_test) {
4717 if ($main::opt_debug and $main::opt_test) { print STDERR "$r\n"; }
4927 open(ADDRESSES, ">$main::tmpfile_sym") || error("$main::tmpfile_sym: $!\n");
4940 system("cat", $main::tmpfile_sym);
4942 system("$cmd < " . ShellEscape($main::tmpfile_sym));
4946 open(SYMBOLS, "$cmd <" . ShellEscape($main::tmpfile_sym) . " |")
5160 my $tools = $main::opt_tools || $ENV{"JEPROF_TOOLS"} || "";
5187 if ($main::opt_debug) { print STDERR "Using '$path' for '$tool'.\n"; }
5205 unlink($main::tmpfile_sym);
5206 unlink(keys %main::tempnames);
5210 if ((scalar(@main::profile_files) > 0) &&
5211 defined($main::collected_profile)) {
5212 if (scalar(@main::profile_files) == 1) {
5213 print STDERR "Dynamically gathered profile is in $main::collected_profile\n";
5218 print STDERR " $main::prog \\\n";
5219 print STDERR " $main::collected_profile\n";
5297 if ($main::opt_debug) { print STDERR "Using Image $1\n"; }
5300 if ($main::opt_debug) { print STDERR "Using PDB $1\n"; }
5423 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5442 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5475 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5494 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5526 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5545 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }