6912fdb
commit f10342a88c4b591b80444b5e2ff8ec063ef58fa4
6912fdb
Author: William Cohen <wcohen@redhat.com>
6912fdb
Date:   Mon Jul 1 16:12:23 2013 -0400
6912fdb
6912fdb
    Clean up option handling in papi_cost
6912fdb
    
6912fdb
    The papi_cost used strstr to seach for the substring that matched the
6912fdb
    option.  this is pretty inexact.  Made sure that the options matched
6912fdb
    exactly and the option argments for -b and -t were greater than 0.
6912fdb
    Also make papi_cost print out the help if there was an option that it
6912fdb
    didn't understand.
6912fdb
    
6912fdb
    Signed-off-by: William Cohen <wcohen@redhat.com>
6912fdb
6912fdb
diff --git a/src/utils/cost.c b/src/utils/cost.c
6912fdb
index 44b338d..5f7aa54 100644
6912fdb
--- a/src/utils/cost.c
6912fdb
+++ b/src/utils/cost.c
6912fdb
@@ -182,35 +182,34 @@ main( int argc, char **argv )
6912fdb
 
6912fdb
 	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */
6912fdb
 
6912fdb
-	for ( i = 0; i < argc; i++ ) {
6912fdb
-		if ( argv[i] ) {
6912fdb
-			if ( strstr( argv[i], "-b" ) ) {
6912fdb
-				bins = atoi( argv[i + 1] );
6912fdb
-				if ( bins )
6912fdb
-					i++;
6912fdb
-				else {
6912fdb
-					printf( "-b requires a bin count!\n" );
6912fdb
-					exit( 1 );
6912fdb
-				}
6912fdb
-			}
6912fdb
-			if ( strstr( argv[i], "-d" ) )
6912fdb
-				show_dist = 1;
6912fdb
-			if ( strstr( argv[i], "-h" ) ) {
6912fdb
-				print_help(  );
6912fdb
+	for ( i = 1; i < argc; i++ ) {
6912fdb
+		if ( !strcmp( argv[i], "-b" ) ) {
6912fdb
+			i++;
6912fdb
+			if ( i >= argc || (bins = atoi( argv[i] ) > 0 ) ) {
6912fdb
+				printf( "-b requires a positive bin count!\n" );
6912fdb
 				exit( 1 );
6912fdb
 			}
6912fdb
-			if ( strstr( argv[i], "-s" ) )
6912fdb
-				show_std_dev = 1;
6912fdb
-			if ( strstr( argv[i], "-t" ) ) {
6912fdb
-				num_iters = ( int ) atol( argv[i + 1] );
6912fdb
-				if ( num_iters )
6912fdb
-					i++;
6912fdb
-				else {
6912fdb
-					printf( "-t requires a threshold value!\n" );
6912fdb
-					exit( 1 );
6912fdb
-				}
6912fdb
+		}
6912fdb
+		else if ( !strcmp( argv[i], "-d" ) )
6912fdb
+			show_dist = 1;
6912fdb
+		else if ( !strcmp( argv[i], "-h" ) ) {
6912fdb
+			print_help(  );
6912fdb
+			exit( 1 );
6912fdb
+		}
6912fdb
+		else if ( !strcmp( argv[i], "-s" ) )
6912fdb
+			show_std_dev = 1;
6912fdb
+		else if ( !strcmp( argv[i], "-t" ) ) {
6912fdb
+			i++;
6912fdb
+			if ( i >= argc || (num_iters = ( int ) atol( argv[i] ) > 0) ) {
6912fdb
+				printf( "-t requires a positive threshold value!\n" );
6912fdb
+				exit( 1 );
6912fdb
 			}
6912fdb
 		}
6912fdb
+		else {
6912fdb
+			/* If not a valid option, print out some help information */
6912fdb
+			print_help( );
6912fdb
+			exit( 1 );
6912fdb
+		}
6912fdb
 	}
6912fdb
 
6912fdb
 	printf( "Cost of execution for PAPI start/stop, read and accum.\n" );
6912fdb
6912fdb
commit b5adc5614855fbd024fc5d5cd73a0305c87af5aa
6912fdb
Author: William Cohen <wcohen@redhat.com>
6912fdb
Date:   Mon Jul 1 16:12:25 2013 -0400
6912fdb
6912fdb
    Clean up option handling for papi_native_avail
6912fdb
    
6912fdb
    Corrected the help to reflect the name of the option "--noumasks".
6912fdb
    Print error message if the "-i", "-e", and "-x" option arguments are invalid.
6912fdb
    Avoid using strstr() for "-h", use strcmp instead.
6912fdb
    Also check for "--help" option.
6912fdb
    
6912fdb
    Signed-off-by: William Cohen <wcohen@redhat.com>
6912fdb
6912fdb
diff --git a/src/utils/native_avail.c b/src/utils/native_avail.c
6912fdb
index 5c303da..dcd4d99 100644
6912fdb
--- a/src/utils/native_avail.c
6912fdb
+++ b/src/utils/native_avail.c
6912fdb
@@ -23,7 +23,7 @@
6912fdb
   * 
  • -e EVENTNAME display detailed information about named native event
  • 6912fdb
       * 
  • -i EVENTSTR include only event names that contain EVENTSTR
  • 6912fdb
       * 
  • -x EVENTSTR exclude any event names that contain EVENTSTR
  • 6912fdb
    -  * 
  • --nomasks suppress display of Unit Mask information
  • 6912fdb
    +  * 
  • --noumasks suppress display of Unit Mask information
  • 6912fdb
       * 
    6912fdb
       *
    6912fdb
       * Processor-specific options
    6912fdb
    @@ -75,7 +75,7 @@ print_help( char **argv )
    6912fdb
     	printf( "   -e EVENTNAME display detailed information about named native event\n" );
    6912fdb
     	printf( "   -i EVENTSTR  include only event names that contain EVENTSTR\n" );
    6912fdb
     	printf( "   -x EVENTSTR  exclude any event names that contain EVENTSTR\n" );
    6912fdb
    -	printf( "   --nomasks    suppress display of Unit Mask information\n" );
    6912fdb
    +	printf( "   --noumasks   suppress display of Unit Mask information\n" );
    6912fdb
     	printf( "\nProcessor-specific options\n");
    6912fdb
     	printf( "  --darr        display events supporting Data Address Range Restriction\n" );
    6912fdb
     	printf( "  --dear        display Data Event Address Register events only\n" );
    6912fdb
    @@ -122,20 +122,29 @@ parse_args( int argc, char **argv, command_flags_t * f )
    6912fdb
     			f->details = 1;
    6912fdb
     		else if ( !strcmp( argv[i], "-e" ) ) {
    6912fdb
     			f->named = 1;
    6912fdb
    -			f->name = argv[i + 1];
    6912fdb
    -			if ( no_str_arg( f->name ) ) f->help = 1;
    6912fdb
     			i++;
    6912fdb
    +			f->name = argv[i];
    6912fdb
    +			if ( i >= argc || no_str_arg( f->name ) ) {
    6912fdb
    +				printf( "Invalid argument for -e\n");
    6912fdb
    +				exit(1);
    6912fdb
    +			}
    6912fdb
     		} else if ( !strcmp( argv[i], "-i" ) ) {
    6912fdb
     			f->include = 1;
    6912fdb
    -			f->istr = argv[i + 1];
    6912fdb
    -			if ( no_str_arg( f->istr ) ) f->help = 1;
    6912fdb
     			i++;
    6912fdb
    +			f->istr = argv[i];
    6912fdb
    +			if ( i >= argc || no_str_arg( f->istr ) ) {
    6912fdb
    +				printf( "Invalid argument for -i\n");
    6912fdb
    +				exit(1);
    6912fdb
    +			}
    6912fdb
     		} else if ( !strcmp( argv[i], "-x" ) ) {
    6912fdb
     			f->xclude = 1;
    6912fdb
    -			f->xstr = argv[i + 1];
    6912fdb
    -			if ( no_str_arg( f->xstr ) ) f->help = 1;
    6912fdb
     			i++;
    6912fdb
    -		} else if ( strstr( argv[i], "-h" ) )
    6912fdb
    +			f->xstr = argv[i];
    6912fdb
    +			if ( i >= argc || no_str_arg( f->xstr ) ) {
    6912fdb
    +				printf( "Invalid argument for -x\n");
    6912fdb
    +				exit(1);
    6912fdb
    +			}
    6912fdb
    +		} else if ( !strcmp( argv[i], "-h" ) || !strcmp( argv[i], "--help" ) )
    6912fdb
     			f->help = 1;
    6912fdb
     		else {
    6912fdb
     			printf( "%s is not supported\n", argv[i] );
    6912fdb
    6912fdb
    commit 8933be9b144bba5e98be892452c7eb44cedbf2af
    6912fdb
    Author: William Cohen <wcohen@redhat.com>
    6912fdb
    Date:   Mon Jul 1 16:12:24 2013 -0400
    6912fdb
    6912fdb
        Clean up option handling in papi_decode
    6912fdb
        
    6912fdb
        papi_decode used strstr() to match options; this can lead to inexact
    6912fdb
        matchs. The code should used strcmp instead.  Make sure command name
    6912fdb
        is not processed as an option.  Also print help iformation is some
    6912fdb
        argument is not understood.
    6912fdb
        
    6912fdb
        Signed-off-by: William Cohen <wcohen@redhat.com>
    6912fdb
    6912fdb
    diff --git a/src/utils/decode.c b/src/utils/decode.c
    6912fdb
    index 3ab7607..ce7cef8 100644
    6912fdb
    --- a/src/utils/decode.c
    6912fdb
    +++ b/src/utils/decode.c
    6912fdb
    @@ -66,11 +66,14 @@ main( int argc, char **argv )
    6912fdb
     	PAPI_event_info_t info;
    6912fdb
     
    6912fdb
     	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */
    6912fdb
    -	for ( i = 0; i < argc; i++ )
    6912fdb
    +	for ( i = 1; i < argc; i++ )
    6912fdb
     		if ( argv[i] ) {
    6912fdb
    -			if ( strstr( argv[i], "-a" ) )
    6912fdb
    +			if ( !strcmp( argv[i], "-a" ) )
    6912fdb
     				print_avail_only = PAPI_PRESET_ENUM_AVAIL;
    6912fdb
    -			if ( strstr( argv[i], "-h" ) ) {
    6912fdb
    +			else if ( !strcmp( argv[i], "-h" ) ) {
    6912fdb
    +				print_help(  );
    6912fdb
    +				exit( 1 );
    6912fdb
    +			} else {
    6912fdb
     				print_help(  );
    6912fdb
     				exit( 1 );
    6912fdb
     			}
    6912fdb
    6912fdb
    commit d94ac43aee03c03abf143bdc0f62f704e2c26f99
    6912fdb
    Author: William Cohen <wcohen@redhat.com>
    6912fdb
    Date:   Mon Jul 1 16:12:22 2013 -0400
    6912fdb
    6912fdb
        Improve option matching in papi_component and add "--help" option
    6912fdb
        
    6912fdb
        Signed-off-by: William Cohen <wcohen@redhat.com>
    6912fdb
    6912fdb
    diff --git a/src/utils/component.c b/src/utils/component.c
    6912fdb
    index 6eb6a11..e69872b 100644
    6912fdb
    --- a/src/utils/component.c
    6912fdb
    +++ b/src/utils/component.c
    6912fdb
    @@ -55,7 +55,7 @@ parse_args( int argc, char **argv, command_flags_t * f )
    6912fdb
     	for ( i = 1; i < argc; i++ ) {
    6912fdb
     		if ( !strcmp( argv[i], "-d" ) ) {
    6912fdb
     			f->details = 1;
    6912fdb
    -		} else if ( strstr( argv[i], "-h" ) )
    6912fdb
    +		} else if ( !strcmp( argv[i], "-h" ) || !strcmp( argv[i], "--help" ) )
    6912fdb
     			f->help = 1;
    6912fdb
     		else
    6912fdb
     			printf( "%s is not supported\n", argv[i] );
    6912fdb
    6912fdb
    commit bb63fe5c270fc970d4fc1a592369472b03d1a928
    6912fdb
    Author: William Cohen <wcohen@redhat.com>
    6912fdb
    Date:   Mon Jul 1 16:12:21 2013 -0400
    6912fdb
    6912fdb
        Add options to papi_command_line man page and improve opt handling
    6912fdb
        
    6912fdb
        Add options mention in the -h to the man page.  Also improve the matching
    6912fdb
        of the options.
    6912fdb
        
    6912fdb
        Signed-off-by: William Cohen <wcohen@redhat.com>
    6912fdb
    6912fdb
    diff --git a/src/utils/command_line.c b/src/utils/command_line.c
    6912fdb
    index 8eb995a..7fecc07 100644
    6912fdb
    --- a/src/utils/command_line.c
    6912fdb
    +++ b/src/utils/command_line.c
    6912fdb
    @@ -17,7 +17,11 @@
    6912fdb
       *		and if they give reasonable results for known work.
    6912fdb
       *
    6912fdb
       *	@section Options
    6912fdb
    -  *		This utility has no command line options.
    6912fdb
    +  * 
      6912fdb
      +  *		
    • -u Display output values as unsigned integers
    • 6912fdb
      +  *		
    • -x Display output values as hexadecimal
    • 6912fdb
      +  *		
    • -h Display help information about this utility.
    • 6912fdb
      +  *	
      6912fdb
         *
      6912fdb
         *	@section Bugs
      6912fdb
         *		There are no known bugs in this utility. 
      6912fdb
      @@ -78,12 +82,12 @@ main( int argc, char **argv )
      6912fdb
       		test_fail_exit( __FILE__, __LINE__, "malloc", PAPI_ESYS );
      6912fdb
       
      6912fdb
       	for ( num_events = 0, i = 1; i < argc; i++ ) {
      6912fdb
      -		if ( strstr( argv[i], "-h" ) ) {
      6912fdb
      +		if ( !strcmp( argv[i], "-h" ) ) {
      6912fdb
       			print_help( argv );
      6912fdb
       			exit( 1 );
      6912fdb
      -		} else if ( strstr( argv[i], "-u" ) ) {
      6912fdb
      +		} else if ( !strcmp( argv[i], "-u" ) ) {
      6912fdb
       			u_format = 1;
      6912fdb
      -		} else if ( strstr( argv[i], "-x" ) ) {
      6912fdb
      +		} else if ( !strcmp( argv[i], "-x" ) ) {
      6912fdb
       			hex_format = 1;
      6912fdb
       		} else {
      6912fdb
       			if ( ( retval = PAPI_add_named_event( EventSet, argv[i] ) ) != PAPI_OK ) {
      6912fdb
      6912fdb
      commit 09059c8223e43c2aaa13aafda094d30a8b220321
      6912fdb
      Author: William Cohen <wcohen@redhat.com>
      6912fdb
      Date:   Mon Jul 1 16:12:20 2013 -0400
      6912fdb
      6912fdb
          Add information for papi_version to be complete
      6912fdb
          
      6912fdb
          Signed-off-by: William Cohen <wcohen@redhat.com>
      6912fdb
      6912fdb
      diff --git a/doc/Makefile b/doc/Makefile
      6912fdb
      index 98d1733..7b52a23 100644
      6912fdb
      --- a/doc/Makefile
      6912fdb
      +++ b/doc/Makefile
      6912fdb
      @@ -11,7 +11,7 @@ man: man/man1 man/man3
      6912fdb
       man/man3: ../src/papi.h 
      6912fdb
       	doxygen Doxyfile-man3
      6912fdb
       
      6912fdb
      -man/man1: ../src/utils/avail.c ../src/utils/clockres.c  ../src/utils/command_line.c ../src/utils/component.c ../src/utils/cost.c ../src/utils/decode.c ../src/utils/error_codes.c ../src/utils/event_chooser.c ../src/utils/event_info.c ../src/utils/mem_info.c ../src/utils/multiplex_cost.c ../src/utils/native_avail.c
      6912fdb
      +man/man1: ../src/utils/avail.c ../src/utils/clockres.c  ../src/utils/command_line.c ../src/utils/component.c ../src/utils/cost.c ../src/utils/decode.c ../src/utils/error_codes.c ../src/utils/event_chooser.c ../src/utils/event_info.c ../src/utils/mem_info.c ../src/utils/multiplex_cost.c ../src/utils/native_avail.c  ../src/utils/version.c
      6912fdb
       	doxygen Doxyfile-man1
      6912fdb
        
      6912fdb
       clean:
      6912fdb
      diff --git a/src/utils/version.c b/src/utils/version.c
      6912fdb
      index 231f1cc..43932fb 100644
      6912fdb
      --- a/src/utils/version.c
      6912fdb
      +++ b/src/utils/version.c
      6912fdb
      @@ -1,3 +1,21 @@
      6912fdb
      +/**
      6912fdb
      +  * file version.c
      6912fdb
      +  *	@brief papi_version utility.
      6912fdb
      +  * @page papi_version
      6912fdb
      +  *	@section Name
      6912fdb
      +  *	papi_version - provides version information for papi.
      6912fdb
      +  * 
      6912fdb
      +  *	@section Synopsis
      6912fdb
      +  *	papi_version
      6912fdb
      +  *
      6912fdb
      +  *	@section Description
      6912fdb
      +  *	papi_version is a PAPI utility program that reports version
      6912fdb
      +  *	information about the current PAPI installation.
      6912fdb
      +  *
      6912fdb
      +  *	@section Bugs
      6912fdb
      +  *	There are no known bugs in this utility. 
      6912fdb
      +  *	If you find a bug, it should be reported to the PAPI Mailing List at <ptools-perfapi@ptools.org>.
      6912fdb
      +  */
      6912fdb
       /* This utility displays the current PAPI version number */
      6912fdb
       
      6912fdb
       #include <stdlib.h>