Changeset c49b79c


Ignore:
Timestamp:
06/01/15 05:20:33 (9 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master
Children:
77ebdb8
Parents:
4598848
git-author:
Hal Finkel <hfinkel@…> (06/01/15 05:20:33)
git-committer:
Hal Finkel <hfinkel@…> (06/01/15 05:20:33)
Message:

use Getopt::Long, print status messages and usage info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • memlog_analyze

    r4598848 rc49b79c  
    22use strict; 
    33use File::Basename; 
     4use Getopt::Long; 
     5 
     6my $print_raw_proc_name = 0; 
     7my $quiet = 0; 
     8my $help = 0; 
     9 
     10sub print_usage($) { 
     11  my $ec = $_[0]; 
     12  my $usage = <<EOM; 
     13Usage: $0 [options] <memlog file> [<output directory>] 
     14  options: 
     15    --print-symbol-names 
     16      Include symbol names and offsets in the output 
     17    --quiet or -q 
     18      Don't print status messages while running 
     19EOM 
     20 
     21  print $usage; 
     22  exit($ec); 
     23} 
     24 
     25GetOptions("help|?" => \$help, 
     26           "print-symbol-names" => \$print_raw_proc_name, 
     27           "quiet|q" => \$quiet) 
     28  or print_usage(1); 
     29 
     30if ($help) { 
     31  print_usage(0); 
     32} 
    433 
    534my $memlog_fn = $ARGV[0]; 
    635my $out_dir = $ARGV[1] || '.'; 
    736 
    8 my $print_raw_proc_name = 0; 
    9  
    1037if (! -f $memlog_fn) { 
    11   print "Usage: $0 <memlog file> [<output directory>]\n"; 
    12   exit 1; 
     38  print_usage(1); 
    1339} 
    1440 
     
    152178my $pdf_fn = "$out_dir/" . basename($memlog_fn) . ".pdf"; 
    153179 
     180if (!$quiet) { 
     181  print "Creating $txt_fn\n"; 
     182} 
     183 
    154184open(TXT, ">$txt_fn") || die "Can't open $txt_fn: $!"; 
     185 
     186if (!$quiet) { 
     187  print "Creating $dot_fn\n"; 
     188} 
     189 
    155190open(DOT, ">$dot_fn") || die "Can't open $dot_fn: $!"; 
    156191 
     
    355390close(DOT); 
    356391 
     392if (!$quiet) { 
     393  print "Creating $ps_fn\n"; 
     394} 
     395 
    357396system("dot -Tps2 < '$dot_fn' > '$ps_fn'"); 
     397 
     398if (!$quiet) { 
     399  print "Creating $pdf_fn\n"; 
     400} 
     401 
    358402system("ps2pdf '$ps_fn' '$pdf_fn'"); 
    359403 
Note: See TracChangeset for help on using the changeset viewer.