Lines Matching defs:Main
296 $main::tmpfile_sym = "/tmp/pprof$$.sym";
297 $main::tmpfile_ps = "/tmp/pprof$$";
298 $main::next_tmpfile = 0;
302 $main::source_cache = ();
304 $main::opt_help = 0;
305 $main::opt_version = 0;
307 $main::opt_cum = 0;
308 $main::opt_base = '';
309 $main::opt_addresses = 0;
310 $main::opt_lines = 0;
311 $main::opt_functions = 0;
312 $main::opt_files = 0;
313 $main::opt_lib_prefix = "";
315 $main::opt_text = 0;
316 $main::opt_callgrind = 0;
317 $main::opt_list = "";
318 $main::opt_disasm = "";
319 $main::opt_symbols = 0;
320 $main::opt_gv = 0;
321 $main::opt_evince = 0;
322 $main::opt_web = 0;
323 $main::opt_dot = 0;
324 $main::opt_ps = 0;
325 $main::opt_pdf = 0;
326 $main::opt_gif = 0;
327 $main::opt_svg = 0;
328 $main::opt_raw = 0;
330 $main::opt_nodecount = 80;
331 $main::opt_nodefraction = 0.005;
332 $main::opt_edgefraction = 0.001;
333 $main::opt_maxdegree = 8;
334 $main::opt_focus = '';
335 $main::opt_ignore = '';
336 $main::opt_scale = 0;
337 $main::opt_heapcheck = 0;
338 $main::opt_seconds = 30;
339 $main::opt_lib = "";
341 $main::opt_inuse_space = 0;
342 $main::opt_inuse_objects = 0;
343 $main::opt_alloc_space = 0;
344 $main::opt_alloc_objects = 0;
345 $main::opt_show_bytes = 0;
346 $main::opt_drop_negative = 0;
347 $main::opt_interactive = 0;
349 $main::opt_total_delay = 0;
350 $main::opt_contentions = 0;
351 $main::opt_mean_delay = 0;
353 $main::opt_tools = "";
354 $main::opt_debug = 0;
355 $main::opt_test = 0;
358 $main::opt_test_stride = 0;
361 $main::use_symbol_page = 0;
364 %main::tempnames = ();
372 $main::profile_type = ''; # Empty type means "unknown"
374 GetOptions("help!" => \$main::opt_help,
375 "version!" => \$main::opt_version,
376 "cum!" => \$main::opt_cum,
377 "base=s" => \$main::opt_base,
378 "seconds=i" => \$main::opt_seconds,
379 "add_lib=s" => \$main::opt_lib,
380 "lib_prefix=s" => \$main::opt_lib_prefix,
381 "functions!" => \$main::opt_functions,
382 "lines!" => \$main::opt_lines,
383 "addresses!" => \$main::opt_addresses,
384 "files!" => \$main::opt_files,
385 "text!" => \$main::opt_text,
386 "callgrind!" => \$main::opt_callgrind,
387 "list=s" => \$main::opt_list,
388 "disasm=s" => \$main::opt_disasm,
389 "symbols!" => \$main::opt_symbols,
390 "gv!" => \$main::opt_gv,
391 "evince!" => \$main::opt_evince,
392 "web!" => \$main::opt_web,
393 "dot!" => \$main::opt_dot,
394 "ps!" => \$main::opt_ps,
395 "pdf!" => \$main::opt_pdf,
396 "svg!" => \$main::opt_svg,
397 "gif!" => \$main::opt_gif,
398 "raw!" => \$main::opt_raw,
399 "interactive!" => \$main::opt_interactive,
400 "nodecount=i" => \$main::opt_nodecount,
401 "nodefraction=f" => \$main::opt_nodefraction,
402 "edgefraction=f" => \$main::opt_edgefraction,
403 "maxdegree=i" => \$main::opt_maxdegree,
404 "focus=s" => \$main::opt_focus,
405 "ignore=s" => \$main::opt_ignore,
406 "scale=i" => \$main::opt_scale,
407 "heapcheck" => \$main::opt_heapcheck,
408 "inuse_space!" => \$main::opt_inuse_space,
409 "inuse_objects!" => \$main::opt_inuse_objects,
410 "alloc_space!" => \$main::opt_alloc_space,
411 "alloc_objects!" => \$main::opt_alloc_objects,
412 "show_bytes!" => \$main::opt_show_bytes,
413 "drop_negative!" => \$main::opt_drop_negative,
414 "total_delay!" => \$main::opt_total_delay,
415 "contentions!" => \$main::opt_contentions,
416 "mean_delay!" => \$main
417 "tools=s" => \$main::opt_tools,
418 "test!" => \$main::opt_test,
419 "debug!" => \$main::opt_debug,
421 "test_stride=i" => \$main::opt_test_stride,
425 if ($main::opt_help) {
430 if ($main::opt_version) {
436 if ($main::opt_disasm || $main::opt_list || $main::opt_symbols) {
437 $main::opt_functions = 0;
438 $main::opt_lines = 0;
439 $main::opt_addresses = 1;
440 $main::opt_files = 0;
444 if ($main::opt_inuse_space +
445 $main::opt_inuse_objects +
446 $main::opt_alloc_space +
447 $main::opt_alloc_objects > 1) {
453 $main::opt_functions +
454 $main::opt_lines +
455 $main::opt_addresses +
456 $main::opt_files +
462 $main::opt_functions = 1;
467 $main::opt_text +
468 $main::opt_callgrind +
469 ($main::opt_list eq '' ? 0 : 1) +
470 ($main::opt_disasm eq '' ? 0 : 1) +
471 ($main::opt_symbols == 0 ? 0 : 1) +
472 $main::opt_gv +
473 $main::opt_evince +
474 $main::opt_web +
475 $main::opt_dot +
476 $main::opt_ps +
477 $main::opt_pdf +
478 $main::opt_svg +
479 $main::opt_gif +
480 $main::opt_raw +
481 $main::opt_interactive +
488 $main::opt_interactive = 1;
490 $main::opt_text = 1;
494 if ($main::opt_test) {
501 $main::prog = "";
502 @main::pfile_args = ();
507 $main::use_symbol_page = 1;
509 $main::use_symbolized_profile = 1;
510 $main::prog = $UNKNOWN_BINARY; # will be set later from the profile file
514 if ($main::use_symbol_page || $main::use_symbolized_profile) {
516 my %disabled = ('--lines' => $main::opt_lines,
517 '--disasm' => $main::opt_disasm);
521 # Set $main::prog later...
523 } elsif ($main::opt_symbols) {
525 $main::prog = shift(@ARGV) || usage("Did not specify program");
527 $main::prog = shift(@ARGV) || usage("Did not specify program");
538 unshift(@main::pfile_args, "$i.$machine$path");
541 unshift(@main::pfile_args, $farg);
545 if ($main::use_symbol_page) {
546 unless (IsProfileURL($main::pfile_args[0])) {
550 $main::prog = FetchProgramName();
551 } elsif (!$main::use_symbolized_profile) { # may not need objtools!
552 ConfigureObjTools($main::prog)
556 @prefix_list = split (',', $main::opt_lib_prefix);
565 sub Main() {
567 $main::collected_profile = undef;
568 @main::profile_files = ();
569 $main::op_time = time();
572 if ($main::opt_symbols) {
584 my $data = ReadProfile($main::prog, pop(@main::profile_files));
587 my $libs = $data->{libs}; # Info about main program and shared libraries
591 if (scalar(@main::profile_files) > 0) {
592 foreach my $pname (@main::profile_files) {
593 my $data2 = ReadProfile($main::prog, $pname);
601 if ($main::opt_base ne '') {
602 my $base = ReadProfile($main::prog, $main::opt_base);
613 if ($main::use_symbolized_profile) {
615 } elsif ($main::use_symbol_page) {
629 if ($main::opt_focus ne '') {
630 $profile = FocusProfile($symbols, $profile, $main::opt_focus);
634 if ($main::opt_ignore ne '') {
635 $profile = IgnoreProfile($symbols, $profile, $main::opt_ignore);
649 if (!$main::opt_interactive) {
650 if ($main::opt_disasm) {
651 PrintDisassembly($libs, $flat, $cumulative, $main::opt_disasm);
652 } elsif ($main::opt_list) {
653 PrintListing($total, $libs, $flat, $cumulative, $main::opt_list, 0);
654 } elsif ($main::opt_text) {
662 } elsif ($main::opt_raw) {
663 PrintSymbolizedProfile($symbols, $profile, $main::prog);
664 } elsif ($main::opt_callgrind) {
667 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
668 if ($main::opt_gv) {
669 RunGV(TempName($main::next_tmpfile, "ps"), "");
670 } elsif ($main::opt_evince) {
671 RunEvince(TempName($main::next_tmpfile, "pdf"), "");
672 } elsif ($main::opt_web) {
673 my $tmp = TempName($main::next_tmpfile, "svg");
680 delete $main::tempnames{$tmp};
702 Main();
726 system(ShellEscape(@GV, "--scale=$main::opt_scale", "--noantialias", $fname)
730 print STDERR ShellEscape(@GV, "-scale", $main::opt_scale) . "\n";
731 system(ShellEscape(@GV, "-scale", "$main::opt_scale", $fname) . $bg);
804 my $save_opt_lines = $main::opt_lines;
811 $main::opt_lines = $save_opt_lines;
833 $main::opt_text = 0;
834 $main::opt_callgrind = 0;
835 $main::opt_disasm = 0;
836 $main::opt_list = 0;
837 $main::opt_gv = 0;
838 $main::opt_evince = 0;
839 $main::opt_cum = 0;
842 $main::opt_text = 1;
861 $main::opt_callgrind = 1;
867 $filename = TempName($main::next_tmpfile, "callgrind");
872 $main::next_tmpfile++;
879 $main::opt_list = 1;
896 $main::opt_disasm = 1;
914 $main::opt_gv = 0;
915 $main::opt_evince = 0;
916 $main::opt_web = 0;
918 $main::opt_gv = 1;
920 $main::opt_evince = 1;
922 $main::opt_web = 1;
938 if (PrintDot($main::prog, $symbols, $profile, $flat, $cumulative, $total)) {
939 if ($main::opt_gv) {
940 RunGV(TempName($main::next_tmpfile, "ps"), " &");
941 } elsif ($main::opt_evince) {
942 RunEvince(TempName($main::next_tmpfile, "pdf"), " &");
943 } elsif ($main::opt_web) {
944 RunWeb(TempName($main::next_tmpfile, "svg"));
946 $main::next_tmpfile++;
1054 $main::opt_lines = 1;
1056 $main::opt_cum = 1;
1074 my $file = "$main::tmpfile_ps.$fnum.$ext";
1075 $main::tempnames{$file} = 1;
1142 if (defined($main::collected_profile)) {
1144 open(SRC, "<$main::collected_profile");
1165 my $s = $main::opt_cum ? $cumulative : $flat;
1178 if ($main::opt_addresses) {
1226 if ($main::opt_interactive) {
1260 # Print disassembly for all all routines that match $main::opt_disasm
1353 my $libs = ParseLibraries($main::prog, $map, $pcs);
1382 $fname = TempName($main::next_tmpfile, "html");
1383 $main::next_tmpfile++;
1391 $main::prog, Unparse($total), Units());
1827 if (!defined($main::source_cache{$file})) {
1828 if (100 < scalar keys(%main::source_cache)) {
1830 $main::source_cache = ();
1836 $main::source_cache{$file} = []; # Cache the negative result
1847 $main::source_cache{$file} = $lines;
1850 my $lines = $main::source_cache{$file};
1980 my $nodelimit = int($main::opt_nodefraction * $local_total);
1981 my $edgelimit = int($main::opt_edgefraction * $local_total);
1982 my $nodecount = $main::opt_nodecount;
2012 if ($main::opt_gv) {
2013 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "ps"));
2015 } elsif ($main::opt_evince) {
2016 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "pdf"));
2018 } elsif ($main::opt_ps) {
2020 } elsif ($main::opt_pdf) {
2022 } elsif ($main::opt_web || $main::opt_svg) {
2024 my $escaped_outfile = ShellEscape(TempName($main::next_tmpfile, "svg"));
2026 } elsif ($main::opt_gif) {
2038 if ($main::opt_pdf) {
2082 if ($main::opt_heapcheck) {
2148 } elsif ($outdegree{$src} >= $main::opt_maxdegree ||
2149 $indegree{$dst} >= $main::opt_maxdegree) {
2164 if ($w < 1 && ($main::opt_web || $main::opt_svg)) {
2193 if ($main::opt_web || $main::opt_svg) {
2195 RewriteSvg(TempName($main::next_tmpfile, "svg"));
2243 if ($main::opt_svg) {
2546 my $id = $main::uniqueid{$key};
2548 $id = keys(%main::uniqueid) + 1;
2549 $main::uniqueid{$key} = $id;
2570 if ($main::opt_disasm || $main::opt_list) {
2604 if ($main::opt_addresses) {
2606 } elsif ($main::opt_lines) {
2612 } elsif ($main::opt_functions) {
2618 } elsif ($main::opt_files) {
2651 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2652 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2655 if ($main::opt_show_bytes) {
2661 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2690 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2691 if ($main::opt_inuse_objects || $main::opt_alloc_objects) {
2694 if ($main::opt_show_bytes) {
2700 } elsif ($main::profile_type eq 'contention' && !$main::opt_contentions) {
2807 if ($main::profile_type eq 'heap' || $main::profile_type eq 'growth') {
2868 } elsif ($main::profile_type eq 'contention') {
2881 } elsif ($main::profile_type eq 'cpu') {
2897 if ($main::profile_type eq 'cpu') {
3103 if ($v < 0 && $main::opt_drop_negative) {
3108 if (!$main::opt_drop_negative) {
3213 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3218 my ($host, $baseURL, $path) = ParseProfileURL($main::pfile_args[0]);
3266 # $main::prog to have the correct program name.
3284 if ($main::prog ne $UNKNOWN_BINARY && $main::prog ne $value) {
3286 $main::prog, $value);
3288 $main::prog = $value;
3313 open(POSTFILE, ">$main::tmpfile_sym");
3322 $command_line = ShellEscape(@URL_FETCHER, "-d", "\@$main::tmpfile_sym",
3326 . " < " . ShellEscape($main::tmpfile_sym));
3375 $binary_shortname, $main::op_time, $host);
3403 $url .= sprintf("seconds=%d", $main::opt_seconds);
3404 $fetch_timeout = $main::opt_seconds * 1.01 + 60;
3428 print STDERR "Gathering CPU profile from $url for $main::opt_seconds seconds to\n ${real_profile}\n";
3439 $main::collected_profile = $real_profile;
3440 return $main::collected_profile;
3446 my $items = scalar(@main::pfile_args);
3450 $main::profile_files[0] = FetchDynamicProfile($main::prog, $main::pfile_args[0], 0, 1);
3456 my $count = scalar(@main::pfile_args);
3458 $main::profile_files[$i] = FetchDynamicProfile($main::prog, $main::pfile_args[$i], 1, 0);
3462 $main::collected_profile = join(" \\\n ", @main::profile_files);
3492 if ($position < scalar(@main::pfile_args)) {
3493 FetchDynamicProfile($main::prog, $main::pfile_args[$position], 0, 0);
3523 if ($main::opt_test_stride > 0) {
3524 $self->{stride} = $main::opt_test_stride;
3722 if (!$main::use_symbolized_profile) {
3733 $main::profile_type = '';
3735 $main::profile_type = 'growth';
3738 $main::profile_type = 'heap';
3741 $main::profile_type = 'contention';
3747 $main::profile_type = 'contention';
3751 $main::profile_type = 'cpu';
3759 $main::profile_type = 'cpu';
3782 if ($main::use_symbolized_profile) {
3855 if ($j > 0 && !$main::use_symbolized_profile) {
3888 if ($main::opt_inuse_space) {
3890 } elsif ($main::opt_inuse_objects) {
3892 } elsif ($main::opt_alloc_space) {
3894 } elsif ($main::opt_alloc_objects) {
4082 if ($main::opt_total_delay) {
4084 } elsif ($main::opt_contentions) {
4086 } elsif ($main::opt_mean_delay) {
4342 return if $main::use_symbol_page; # We don't need libraries info.
4411 if($main::opt_debug) { printf STDERR "$start:$finish ($offset) $lib\n"; }
4416 if ($main::opt_lib ne "") {
4417 my $text = ParseTextSectionHeader($main::opt_lib);
4422 push(@{$result}, [$main::opt_lib, $start, $finish, $start]);
4426 # Append special entry for the main program. This covers
4428 # of the library ranges will be treated as coming from the main
4455 if ($main::opt_debug and $main::opt_test) {
4487 if ($main::opt_debug and $main::opt_test) { print STDERR "$r\n"; }
4508 # if ($main::opt_debug) { print STDERR "AddressSub $addr1 - $addr2 = "; }
4540 # if ($main::opt_debug) { print STDERR "$r\n"; }
4563 # if ($main::opt_debug) { print STDERR "AddressInc $addr1 = "; }
4571 # if ($main::opt_debug) { print STDERR "$r\n"; }
4583 # if ($main::opt_debug) { print STDERR "$r\n"; }
4593 # if ($main::opt_debug) { print STDERR "$r\n"; }
4608 # addresses of libraries may overlap with the addresses of the main
4639 # in case there are overlaps in libraries and the main binary.
4697 open(ADDRESSES, ">$main::tmpfile_sym") || error("$main::tmpfile_sym: $!\n");
4710 system("cat", $main::tmpfile_sym);
4712 system("$cmd < " . ShellEscape($main::tmpfile_sym));
4716 open(SYMBOLS, "$cmd <" . ShellEscape($main::tmpfile_sym) . " |")
4930 my $tools = $main::opt_tools || $ENV{"PPROF_TOOLS"} || "";
4957 if ($main::opt_debug) { print STDERR "Using '$path' for '$tool'.\n"; }
4975 unlink($main::tmpfile_sym);
4976 unlink(keys %main::tempnames);
4980 if ((scalar(@main::profile_files) > 0) &&
4981 defined($main::collected_profile)) {
4982 if (scalar(@main::profile_files) == 1) {
4983 print STDERR "Dynamically gathered profile is in $main::collected_profile\n";
4988 print STDERR " $main::prog \\\n";
4989 print STDERR " $main::collected_profile\n";
5067 if ($main::opt_debug) { print STDERR "Using Image $1\n"; }
5070 if ($main::opt_debug) { print STDERR "Using PDB $1\n"; }
5193 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5212 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5245 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5264 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5296 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }
5315 if ($main::opt_debug and $main::opt_test) { print STDERR "@{$row}\n"; }