exclude.c File Reference

#include "arc.h"
#include "assertion.h"
#include "binding.h"
#include "comb.h"
#include "db.h"
#include "defines.h"
#include "exclude.h"
#include "expr.h"
#include "fsm.h"
#include "func_iter.h"
#include "func_unit.h"
#include "instance.h"
#include "line.h"
#include <stdio.h>
#include "link.h"
#include "ovl.h"
#include "profiler.h"
#include "report.h"
#include "vector.h"

Functions

static char * exclude_get_message (const char *eid)
static bool exclude_is_parent_excluded (expression *expr)
static void exclude_expr_assign_and_recalc (expression *expr, func_unit *funit, bool excluded, bool set_line, statistic *stat)
static void exclude_sig_assign_and_recalc (vsignal *sig, bool excluded, statistic *stat)
static void exclude_arc_assign_and_recalc (fsm_table *table, int arc_index, bool exclude, statistic *stat)
static void exclude_add_exclude_reason (char type, int id, char *reason, func_unit *funit)
static void exclude_remove_exclude_reason (char type, int id, func_unit *funit)
bool exclude_is_line_excluded (func_unit *funit, int line)
 Returns TRUE if the specified line is excluded in the given functional unit.
void exclude_set_line_exclude (func_unit *funit, int line, int value, char *reason, statistic *stat)
 Sets the excluded bit for all expressions in the given functional unit with the specified line number and recalculates the summary coverage information.
bool exclude_is_toggle_excluded (func_unit *funit, char *sig_name)
 Returns TRUE if the specified signal is excluded in the given functional unit.
void exclude_set_toggle_exclude (func_unit *funit, const char *sig_name, int value, char type, char *reason, statistic *stat)
 Sets the excluded bit for the specified signal in the given functional unit and recalculates the summary coverage information.
bool exclude_is_comb_excluded (func_unit *funit, int expr_id, int uline_id)
void exclude_set_comb_exclude (func_unit *funit, int expr_id, int uline_id, int value, char *reason, statistic *stat)
 Sets the excluded bit for the specified expression in the given functional unit and recalculates the summary coverage information.
bool exclude_is_fsm_excluded (func_unit *funit, int expr_id, char *from_state, char *to_state)
 Returns TRUE if the specified FSM is excluded in the given functional unit.
void exclude_set_fsm_exclude (func_unit *funit, int expr_id, char *from_state, char *to_state, int value, char *reason, statistic *stat)
 Sets the excluded bit for the specified state transition in the given functional unit and recalculates the summary coverage information.
bool exclude_is_assert_excluded (func_unit *funit, char *inst_name, int expr_id)
 Returns TRUE if given assertion is excluded from coverage.
void exclude_set_assert_exclude (func_unit *funit, char *inst_name, int expr_id, int value, char *reason, statistic *stat)
 Sets the excluded bit for the specified expression in the given functional unit and recalculates the summary coverage information.
static void exclude_usage ()
static bool exclude_parse_args (int argc, int last_arg, const char **argv)
exclude_reasonexclude_find_exclude_reason (char type, int id, func_unit *funit)
 Returns a pointer to the found exclude reason if one is found for the given type and ID; otherwise, returns NULL.
void exclude_db_write (exclude_reason *er, FILE *ofile)
 Outputs the given exclude reason structure to the specified file stream.
void exclude_db_read (char **line, func_unit *curr_funit)
 Reads the given exclude reason from the specified line and stores its information in the curr_funit structure.
void exclude_resolve_reason (exclude_reason *orig_er, func_unit *orig_funit, int resolution, const char *new_reason, long new_timestamp)
void exclude_db_merge (func_unit *base, char **line)
 Reads the given exclude reason from the specified line and merges its information with the base functional unit.
void exclude_merge (func_unit *base, exclude_reason *er)
 Performs exclusion reason merging.
vsignalexclude_find_signal (int id, func_unit **found_funit)
expressionexclude_find_expression (int id, func_unit **found_funit)
int exclude_find_fsm_arc (int id, fsm_table **found_fsm, func_unit **found_funit)
char * exclude_format_reason (const char *old_str)
 Formats the reason string for storage purposes.
static void exclude_handle_exclude_reason (int prev_excluded, const char *id, func_unit *funit)
static void exclude_print_exclusion (const char *id, int excluded, func_unit *funit)
static bool exclude_line_from_id (const char *id)
static bool exclude_toggle_from_id (const char *id)
static bool exclude_memory_from_id (const char *id)
static bool exclude_expr_from_id (const char *id)
static bool exclude_fsm_from_id (const char *id)
static bool exclude_assert_from_id (const char *id)
static bool exclude_apply_exclusions ()
void command_exclude (int argc, int last_arg, const char **argv)
 Allows the user to exclude coverage points from reporting.

Variables

db ** db_list
unsigned int curr_db
isuppl info_suppl
char user_msg [USER_MSG_LENGTH]
int merge_er_value
static char * exclude_cdd = NULL
static str_linkexcl_ids_head = NULL
static str_linkexcl_ids_tail = NULL
static bool exclude_prompt_for_msgs = FALSE
static bool exclude_print = FALSE

Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
6/22/2006

Function Documentation

void command_exclude ( int  argc,
int  last_arg,
const char **  argv 
)

Allows the user to exclude coverage points from reporting.

Performs the exclude command.

Parameters:
argc Number of arguments in command-line to parse
last_arg Index of last parsed argument from list
argv List of arguments from command-line to parse

References bind_perform(), Catch_anonymous, COVERED_HEADER, db_close(), db_read(), db_write(), exclude_apply_exclusions(), exclude_cdd, exclude_parse_args(), FALSE, free_safe, HEADER, NORMAL, print_output(), PROFILE, PROFILE_END, READ_MODE_REPORT_NO_MERGE, str_link_delete_list(), Throw, TRUE, Try, user_msg, and USER_MSG_LENGTH.

Referenced by main().

01884   { PROFILE(COMMAND_EXCLUDE);
01885 
01886   unsigned int   rv;
01887   comp_cdd_cov** comp_cdds    = NULL;
01888   unsigned int   comp_cdd_num = 0;
01889   bool           error        = FALSE;
01890 
01891   /* Output header information */
01892   rv = snprintf( user_msg, USER_MSG_LENGTH, COVERED_HEADER );
01893   assert( rv < USER_MSG_LENGTH );
01894   print_output( user_msg, HEADER, __FILE__, __LINE__ );
01895 
01896   Try {
01897 
01898     unsigned int rv;
01899 
01900     /* Parse score command-line */
01901     if( !exclude_parse_args( argc, last_arg, argv ) ) {
01902 
01903       /* Read in database */
01904       rv = snprintf( user_msg, USER_MSG_LENGTH, "Reading CDD file \"%s\"", exclude_cdd );
01905       assert( rv < USER_MSG_LENGTH );
01906       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01907 
01908       (void)db_read( exclude_cdd, READ_MODE_REPORT_NO_MERGE );
01909       bind_perform( TRUE, 0 );
01910 
01911       /* Apply the specified exclusion IDs */
01912       if( exclude_apply_exclusions() ) {
01913         rv = snprintf( user_msg, USER_MSG_LENGTH, "Writing CDD file \"%s\"", exclude_cdd );
01914         assert( rv < USER_MSG_LENGTH );
01915         print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01916         db_write( exclude_cdd, FALSE, FALSE );
01917       }
01918 
01919     }
01920 
01921   } Catch_anonymous {
01922     error = TRUE;
01923   }
01924 
01925   /* Close down the database */
01926   db_close();
01927     
01928   /* Deallocate other allocated variables */
01929   str_link_delete_list( excl_ids_head );
01930   free_safe( exclude_cdd, (strlen( exclude_cdd ) + 1) );
01931 
01932   if( error ) {
01933     Throw 0;
01934   }
01935       
01936   PROFILE_END;
01937  
01938 }   

static void exclude_add_exclude_reason ( char  type,
int  id,
char *  reason,
func_unit funit 
) [static]

Handle the creation of the exclude reason structure.

Parameters:
type Exclusion ID type
id Exclusion ID number
reason Exclusion reason
funit Functional unit containing sig

References func_unit_s::er_head, func_unit_s::er_tail, malloc_safe, exclude_reason_s::next, and PROFILE.

Referenced by exclude_handle_exclude_reason(), exclude_set_assert_exclude(), exclude_set_comb_exclude(), exclude_set_fsm_exclude(), exclude_set_line_exclude(), and exclude_set_toggle_exclude().

00277   { PROFILE(EXCLUDE_ADD_EXCLUDE_REASON);
00278 
00279   exclude_reason* er;
00280   int             rv;
00281   struct timeval  tv;
00282 
00283   /*
00284    If the coverage point was not previously excluded, allow the user to specify a reason and
00285    store this information in the functional unit.
00286   */
00287   er            = (exclude_reason*)malloc_safe( sizeof( exclude_reason ) );
00288   er->type      = type;
00289   er->id        = id;
00290   er->reason    = reason;
00291   er->next      = NULL;
00292 
00293   /* Add timestamp information */
00294   rv = gettimeofday( &tv, NULL );
00295   assert( rv == 0 );
00296   er->timestamp = tv.tv_sec;
00297 
00298   if( funit->er_head == NULL ) { 
00299     funit->er_head = funit->er_tail = er; 
00300   } else {
00301     funit->er_tail->next = er; 
00302     funit->er_tail       = er; 
00303   }   
00304 
00305 }

static bool exclude_apply_exclusions (  )  [static]
Returns:
Returns TRUE if one or more exclusion IDs were applied; otherwise, returns FALSE.

Applies the user-specified exclusion IDs to the currently opened database.

References exclude_assert_from_id(), exclude_expr_from_id(), exclude_fsm_from_id(), exclude_line_from_id(), exclude_memory_from_id(), exclude_toggle_from_id(), FALSE, FATAL, str_link_s::next, print_output(), PROFILE, PROFILE_END, str_link_s::str, Throw, user_msg, and USER_MSG_LENGTH.

Referenced by command_exclude().

01844                                        { PROFILE(EXCLUDE_APPLY_EXCLUSIONS);
01845 
01846   bool         retval = FALSE;  /* Return value for this function */
01847   str_link*    strl;            /* Pointer to current string link */
01848   unsigned int rv;
01849 
01850   strl = excl_ids_head;
01851   while( strl != NULL ) {
01852     switch( strl->str[0] ) {
01853       case 'L' :  retval |= exclude_line_from_id( strl->str );    break;
01854       case 'T' :  retval |= exclude_toggle_from_id( strl->str );  break;
01855       case 'M' :  retval |= exclude_memory_from_id( strl->str );  break;
01856       case 'E' :  retval |= exclude_expr_from_id( strl->str );    break;
01857       case 'F' :  retval |= exclude_fsm_from_id( strl->str );     break;
01858       case 'A' :  retval |= exclude_assert_from_id( strl->str );  break;
01859       default  :
01860         rv = snprintf( user_msg, USER_MSG_LENGTH, "Illegal exclusion identifier specified (%s)", strl->str );
01861         assert( rv < USER_MSG_LENGTH );
01862         print_output( user_msg, FATAL, __FILE__, __LINE__ );
01863         Throw 0;
01864         /*@-unreachable@*/
01865         break;
01866         /*@=unreachable@*/
01867     }
01868     strl = strl->next;
01869   }
01870 
01871   PROFILE_END;
01872 
01873   return( retval );
01874 
01875 }

static void exclude_arc_assign_and_recalc ( fsm_table table,
int  arc_index,
bool  exclude,
statistic stat 
) [static]

Sets the specified arc entry's exclude bit to the given value and recalculates all affected coverage information for this instance.

Parameters:
table Pointer FSM table
arc_index Specifies the index of the entry containing the transition
exclude Specifies if we are excluding or including coverage
stat Pointer to statistic structure to update

References statistic_s::arc_excluded, statistic_s::arc_hit, fsm_table_s::arcs, asuppl_u::excluded, asuppl_u::hit, asuppl_u::part, PROFILE, PROFILE_END, and fsm_table_arc_s::suppl.

Referenced by exclude_set_fsm_exclude().

00256   { PROFILE(EXCLUDE_ARC_ASSIGN_AND_RECALC);
00257 
00258   /* Set the excluded bit in the specified entry and adjust coverage numbers, if necessary */
00259   table->arcs[arc_index]->suppl.part.excluded = (exclude ? 1 : 0);
00260   if( table->arcs[arc_index]->suppl.part.hit == 0 ) {
00261     stat->arc_hit      += exclude ? 1 : -1;
00262     stat->arc_excluded += exclude ? 1 : -1;
00263   }
00264 
00265   PROFILE_END;
00266 
00267 }

static bool exclude_assert_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the assertion that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References exclude_find_expression(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, esuppl_u::excluded, NORMAL, esuppl_u::part, print_output(), PROFILE, PROFILE_END, expression_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01785   { PROFILE(EXCLUDE_ASSERT_FROM_ID);
01786 
01787   expression* exp;          /* Pointer to found expression */
01788   func_unit*  found_funit;  /* Pointer to functional unit containing exp */
01789 
01790   if( (exp = exclude_find_expression( atoi( id + 1 ), &found_funit )) != NULL ) {
01791 
01792     int          prev_excluded;
01793     unsigned int rv;
01794 
01795     /* Get the previously excluded value */
01796     prev_excluded = exp->suppl.part.excluded;
01797 
01798     /* If the user has specified to print the exclusion, do so */
01799     if( exclude_print ) {
01800 
01801       exclude_print_exclusion( id, prev_excluded, found_funit );
01802 
01803     /* Otherwise, perform the exclusion */
01804     } else {
01805 
01806       /* Output result */
01807       if( prev_excluded == 0 ) {
01808         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01809       } else {
01810         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01811       }
01812       assert( rv < USER_MSG_LENGTH );
01813       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01814 
01815       /* Set the exclude bits in the expression supplemental field */
01816       exp->suppl.part.excluded = (prev_excluded ^ 1);
01817   
01818       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01819       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) {
01820         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01821       }
01822 
01823     }
01824 
01825   } else {
01826 
01827     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find assertion associated with exclusion ID %s", id );
01828     assert( rv < USER_MSG_LENGTH );
01829     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01830 
01831   }
01832 
01833   PROFILE_END;
01834 
01835   return( (exp != NULL) && !exclude_print );
01836 
01837 }

void exclude_db_merge ( func_unit base,
char **  line 
)

Reads the given exclude reason from the specified line and merges its information with the base functional unit.

Reads the given exclude reason structure information from the line read from the CDD file.

Parameters:
base Pointer to base functional unit to merge into
line Pointer to the line read from the CDD file

References func_unit_s::er_head, func_unit_s::er_tail, exclude_find_exclude_reason(), exclude_resolve_reason(), FATAL, exclude_reason_s::id, malloc_safe, merge_er_value, exclude_reason_s::next, print_output(), PROFILE, PROFILE_END, exclude_reason_s::reason, strdup_safe, Throw, exclude_reason_s::timestamp, and exclude_reason_s::type.

Referenced by db_read().

01084   { PROFILE(EXCLUDE_DB_MERGE);
01085 
01086   char   type;        /* Specifies the type of exclusion this structure represents */
01087   int    id;          /* ID of signal/expression/FSM */
01088   int    chars_read;  /* Number of characters read from line */
01089   time_t timestamp;   /* Reason timestamp */
01090   char*  reason;      /* Pointer to the exclusion reason from the CDD file */
01091 
01092   /*@+longintegral@*/
01093   if( sscanf( *line, " %c %d %ld%n", &type, &id, &timestamp, &chars_read ) == 3 ) {
01094   /*@=longintegral@*/
01095 
01096     exclude_reason* er;
01097 
01098     *line = *line + chars_read;
01099 
01100     /* Get the reason string and remove leading whitespace */
01101     while( (*line)[0] == ' ' ) {
01102       (*line)++;
01103     }
01104     reason = *line;
01105     assert( reason != NULL );
01106     assert( reason[0] != '\0' );
01107 
01108     /* If the exclusion reason does not exist in the base CDD, go ahead and add it */
01109     if( (er = exclude_find_exclude_reason( type, id, base )) == NULL ) {
01110 
01111       /* Allocate and initialize the exclude reason structure */
01112       er            = (exclude_reason*)malloc_safe( sizeof( exclude_reason ) );
01113       er->type      = type;
01114       er->id        = id;
01115       er->timestamp = timestamp;
01116       er->reason    = strdup_safe( reason );
01117       er->next      = NULL;
01118 
01119       /* Add the given exclude reason to the current functional unit list */
01120       if( base->er_head == NULL ) {
01121         base->er_head = base->er_tail = er;
01122       } else {
01123         base->er_tail->next = er;
01124         base->er_tail       = er;
01125       }
01126  
01127     /* Otherwise, if the exclusion reason does exist, check for a conflict and handle it */
01128     } else {
01129 
01130       /*
01131        If the exclusion reason string does not match the current string, resolve the conflict appropriately
01132        (otherwise, just use the reason in the base functional unit).
01133       */
01134       if( strcmp( er->reason, reason ) != 0 ) {
01135         exclude_resolve_reason( er, base, merge_er_value, reason, timestamp );
01136       }
01137 
01138     }
01139 
01140   } else {
01141 
01142     print_output( "CDD being read is not compatible with this version of Covered", FATAL, __FILE__, __LINE__ );
01143     Throw 0;
01144 
01145   }
01146 
01147   PROFILE_END;
01148 
01149 }

void exclude_db_read ( char **  line,
func_unit curr_funit 
)

Reads the given exclude reason from the specified line and stores its information in the curr_funit structure.

Reads the given exclude reason structure information from the line read from the CDD file.

Parameters:
line Pointer to the line read from the CDD file
curr_funit Pointer to the current functional unit

References func_unit_s::er_head, func_unit_s::er_tail, FATAL, exclude_reason_s::id, malloc_safe, exclude_reason_s::next, print_output(), PROFILE, PROFILE_END, exclude_reason_s::reason, strdup_safe, Throw, exclude_reason_s::timestamp, and exclude_reason_s::type.

Referenced by db_read().

00929   { PROFILE(EXCLUDE_DB_READ);
00930 
00931   char   type;        /* Specifies the type of exclusion this structure represents */
00932   int    id;          /* ID of signal/expression/FSM */
00933   int    chars_read;  /* Number of characters read from line */
00934   time_t timestamp;   /* Reason timestamp */
00935 
00936   /*@+longintegral@*/
00937   if( sscanf( *line, " %c %d %ld%n", &type, &id, &timestamp, &chars_read ) == 3 ) {
00938   /*@=longintegral@*/
00939 
00940     exclude_reason* er;
00941 
00942     *line = *line + chars_read;
00943 
00944     /* Allocate and initialize the exclude reason structure */
00945     er            = (exclude_reason*)malloc_safe( sizeof( exclude_reason ) );
00946     er->type      = type;
00947     er->id        = id;
00948     er->reason    = NULL;
00949     er->timestamp = timestamp;
00950     er->next      = NULL;
00951 
00952     /* Remove leading whitespace */
00953     while( (*line)[0] == ' ' ) {
00954       (*line)++;
00955     }
00956     er->reason = strdup_safe( *line );
00957 
00958     /* Add the given exclude reason to the current functional unit list */
00959     if( curr_funit->er_head == NULL ) {
00960       curr_funit->er_head = curr_funit->er_tail = er;
00961     } else {
00962       curr_funit->er_tail->next = er;
00963       curr_funit->er_tail       = er;
00964     }
00965 
00966   } else {
00967 
00968     print_output( "CDD being read is not compatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00969     Throw 0;
00970 
00971   }
00972 
00973   PROFILE_END;
00974 
00975 }

void exclude_db_write ( exclude_reason er,
FILE *  ofile 
)

Outputs the given exclude reason structure to the specified file stream.

Writes the given exclude reason to the specified output stream.

Parameters:
er Pointer to exclude reason structure to output
ofile Pointer to output file stream

References DB_TYPE_EXCLUDE, exclude_reason_s::id, PROFILE, PROFILE_END, exclude_reason_s::reason, exclude_reason_s::timestamp, and exclude_reason_s::type.

Referenced by funit_db_write().

00913   { PROFILE(EXCLUDE_DB_WRITE);
00914 
00915   /*@+longintegral@*/
00916   fprintf( ofile, "%d %c %d %ld %s\n", DB_TYPE_EXCLUDE, er->type, er->id, er->timestamp, er->reason );
00917   /*@=longintegral@*/
00918 
00919   PROFILE_END;
00920 
00921 }

static void exclude_expr_assign_and_recalc ( expression expr,
func_unit funit,
bool  excluded,
bool  set_line,
statistic stat 
) [static]

Sets the specified expression's exclude bit to the given value and recalculates all affected coverage information for this instance.

Parameters:
expr Pointer to expression that is being excluded/included
funit Pointer to functional unit containing this expression
excluded Specifies if expression is being excluded or included
set_line Set to TRUE when this function is being called for line exclusion
stat Pointer to statistics structure to update

References statistic_s::assert_excluded, statistic_s::assert_hit, isuppl_u::assert_ovl, statistic_s::comb_excluded, statistic_s::comb_hit, combination_get_tree_stats(), combination_reset_counted_expr_tree(), ESUPPL_IS_ROOT, exclude_is_parent_excluded(), esuppl_u::excluded, expression_s::exec_num, EXP_OP_CASE, EXP_OP_CASEX, EXP_OP_CASEZ, EXP_OP_DEFAULT, EXP_OP_DELAY, EXP_OP_FORK, EXP_OP_JOIN, EXP_OP_NB_CALL, EXP_OP_NOOP, expression_s::line, statistic_s::line_excluded, statistic_s::line_hit, expression_s::op, ovl_is_assertion_module(), ovl_is_coverage_point(), expression_s::parent, statement_s::part, esuppl_u::part, isuppl_u::part, PROFILE, PROFILE_END, expr_stmt_u::stmt, statement_s::suppl, and expression_s::suppl.

Referenced by exclude_set_assert_exclude(), exclude_set_comb_exclude(), and exclude_set_line_exclude().

00105   { PROFILE(EXCLUDE_EXPR_ASSIGN_AND_RECALC);
00106 
00107   unsigned int comb_hit      = 0;  /* Total number of hit combinations within this tree */
00108   unsigned int comb_excluded = 0;  /* Total number of excluded combinations */
00109   unsigned int comb_total    = 0;  /* Total number of combinational logic coverage points within this tree */
00110   int          ulid          = 0;  /* Temporary value */
00111 
00112   /* Now recalculate the coverage information for all metrics if this module is not an OVL module */
00113   if( (info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( funit ) ) {
00114 
00115     /* If this expression is a root expression, recalculate line coverage */
00116     if( ESUPPL_IS_ROOT( expr->suppl ) == 1 ) {
00117       if( (expr->op != EXP_OP_DELAY)   &&
00118           (expr->op != EXP_OP_CASE)    &&
00119           (expr->op != EXP_OP_CASEX)   &&
00120           (expr->op != EXP_OP_CASEZ)   &&
00121           (expr->op != EXP_OP_DEFAULT) &&
00122           (expr->op != EXP_OP_NB_CALL) &&
00123           (expr->op != EXP_OP_FORK)    &&
00124           (expr->op != EXP_OP_JOIN)    &&
00125           (expr->op != EXP_OP_NOOP)    &&
00126           (expr->line != 0) &&
00127           (expr->exec_num == 0) ) {
00128         if( excluded ) {
00129           stat->line_hit++;
00130           stat->line_excluded++;
00131         } else {
00132           stat->line_hit--;
00133           stat->line_excluded--;
00134         }
00135       }
00136     }
00137 
00138     /* Always recalculate combinational coverage */
00139     combination_reset_counted_expr_tree( expr );
00140     if( excluded ) {
00141       combination_get_tree_stats( expr, &ulid, 0, exclude_is_parent_excluded( expr ), &comb_hit, &comb_excluded, &comb_total );
00142       stat->comb_hit      += (comb_total - comb_hit);
00143       stat->comb_excluded += (comb_total - comb_excluded);
00144     } else {
00145       expr->suppl.part.excluded = 0;
00146       combination_get_tree_stats( expr, &ulid, 0, exclude_is_parent_excluded( expr ), &comb_hit, &comb_excluded, &comb_total );
00147       stat->comb_hit      -= (comb_total - comb_hit);
00148       stat->comb_excluded -= (comb_total - comb_excluded);
00149     }
00150 
00151   } else {
00152 
00153     /* If the expression is a coverage point, recalculate the assertion coverage */
00154     if( ovl_is_assertion_module( funit ) && ovl_is_coverage_point( expr ) ) {
00155       if( expr->exec_num == 0 ) {
00156         if( excluded ) {
00157           stat->assert_hit++;
00158           stat->assert_excluded++;
00159         } else {
00160           stat->assert_hit--;
00161           stat->assert_excluded--;
00162         }
00163       }
00164     }
00165 
00166   }
00167 
00168   /* Set the exclude bits in the expression supplemental field */
00169   expr->suppl.part.excluded = excluded ? 1 : 0;
00170   if( (ESUPPL_IS_ROOT( expr->suppl ) == 1) && (expr->parent->stmt != NULL) ) {
00171     expr->parent->stmt->suppl.part.excluded = (excluded && set_line) ? 1 : 0;
00172   }
00173 
00174   PROFILE_END;
00175 
00176 }

static bool exclude_expr_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the expression that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References exclude_find_expression(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, esuppl_u::excluded, NORMAL, esuppl_u::part, print_output(), PROFILE, PROFILE_END, expression_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01660   { PROFILE(EXCLUDE_EXPR_FROM_ID);
01661 
01662   expression* exp;          /* Pointer to found expression */
01663   func_unit*  found_funit;  /* Pointer to functional unit containing exp */
01664   
01665   if( (exp = exclude_find_expression( atoi( id + 1 ), &found_funit )) != NULL ) {
01666   
01667     int          prev_excluded;
01668     unsigned int rv;
01669     
01670     /* Get the previously excluded value */
01671     prev_excluded = exp->suppl.part.excluded;
01672 
01673     /* If the user has specified to print the exclusion, do so */
01674     if( exclude_print ) {
01675 
01676       exclude_print_exclusion( id, prev_excluded, found_funit );
01677 
01678     /* Otherwise, perform the exclusion */
01679     } else {
01680     
01681       /* Output result */
01682       if( prev_excluded == 0 ) {
01683         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01684       } else {
01685         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01686       }
01687       assert( rv < USER_MSG_LENGTH );
01688       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01689 
01690       /* Set the exclude bits in the expression supplemental field */
01691       exp->suppl.part.excluded = (prev_excluded ^ 1);
01692     
01693       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01694       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) { 
01695         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01696       }
01697 
01698     }
01699 
01700   } else {
01701 
01702     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find expression associated with exclusion ID %s", id );
01703     assert( rv < USER_MSG_LENGTH );
01704     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01705 
01706   }
01707 
01708   PROFILE_END;
01709 
01710   return( (exp != NULL) && !exclude_print );
01711 
01712 }

exclude_reason* exclude_find_exclude_reason ( char  type,
int  id,
func_unit funit 
)

Returns a pointer to the found exclude reason if one is found for the given type and ID; otherwise, returns NULL.

Returns:
Returns a pointer to the found exclusion reason that matches the given type and ID; otherwise, returns a value of NULL.

References func_unit_s::er_head, exclude_reason_s::id, exclude_reason_s::next, PROFILE, PROFILE_END, and exclude_reason_s::type.

Referenced by arc_get_transitions(), combination_get_exclude_list(), combination_list_missed(), exclude_db_merge(), exclude_merge(), exclude_print_exclusion(), line_collect(), line_display_verbose(), memory_display_verbose(), memory_get_coverage(), ovl_display_verbose(), ovl_get_coverage(), toggle_display_verbose(), and toggle_get_coverage().

00892   { PROFILE(EXCLUDE_FIND_EXCLUDE_REASON);
00893 
00894   exclude_reason* er;  /* Pointer to current exclude reason structure */
00895 
00896   er = funit->er_head;
00897   while( (er != NULL) && ((er->type != type) || (er->id != id)) ) {
00898     er = er->next;
00899   }
00900 
00901   PROFILE_END;
00902 
00903   return( er );
00904 
00905 }

expression* exclude_find_expression ( int  id,
func_unit **  found_funit 
)
Returns:
Returns pointer to found expression if it was found; otherwise, returns NULL.
Parameters:
id Exclusion ID to search for
found_funit Pointer to functional unit containing found expression

References curr_db, funit_get_curr_module(), inst_link_s::inst, db_s::inst_head, instance_find_expression_by_exclusion_id(), inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by exclude_assert_from_id(), exclude_expr_from_id(), and exclude_line_from_id().

01231   { PROFILE(EXCLUDE_FIND_EXPRESSION);
01232 
01233   inst_link*  instl;       /* Pointer to current instance link */
01234   expression* exp = NULL;  /* Pointer to found expression */
01235 
01236   instl = db_list[curr_db]->inst_head;
01237   while( (instl != NULL) && ((exp = instance_find_expression_by_exclusion_id( instl->inst, id, found_funit )) == NULL) ) {
01238     instl = instl->next;
01239   }
01240 
01241   if( exp != NULL ) {
01242     *found_funit = funit_get_curr_module( *found_funit );
01243   }
01244 
01245   PROFILE_END;
01246 
01247   return( exp );
01248 
01249 }

int exclude_find_fsm_arc ( int  id,
fsm_table **  found_fsm,
func_unit **  found_funit 
)
Returns:
Returns the index of the state transition that was found with the given exclusion ID.
Parameters:
id Exclusion ID to search for
found_fsm Pointer to FSM table that was found
found_funit Pointer to found functional unit

References curr_db, funit_get_curr_module(), inst_link_s::inst, db_s::inst_head, instance_find_fsm_arc_index_by_exclusion_id(), inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by exclude_fsm_from_id().

01258   { PROFILE(EXCLUDE_FIND_FSM_ARC);
01259 
01260   inst_link* instl;  /* Pointer to current instance link */
01261   int        arc_index = -1;
01262 
01263   instl = db_list[curr_db]->inst_head;
01264   while( (instl != NULL) && ((arc_index = instance_find_fsm_arc_index_by_exclusion_id( instl->inst, id, found_fsm, found_funit )) == -1) ) {
01265     instl = instl->next;
01266   }
01267 
01268   if( arc_index != -1 ) {
01269     *found_funit = funit_get_curr_module( *found_funit );
01270   }
01271 
01272   PROFILE_END;
01273 
01274   return( arc_index );
01275 
01276 }

vsignal* exclude_find_signal ( int  id,
func_unit **  found_funit 
)
Returns:
Returns pointer to found signal if it was found; otherwise, returns NULL.
Parameters:
id Exclusion ID to search for
found_funit Pointer to functional unit containing found signal

References curr_db, funit_get_curr_module(), inst_link_s::inst, db_s::inst_head, instance_find_signal_by_exclusion_id(), inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by exclude_memory_from_id(), and exclude_toggle_from_id().

01205   { PROFILE(EXCLUDE_FIND_SIGNAL);
01206 
01207   inst_link* instl;       /* Pointer to current instance link */
01208   vsignal*   sig = NULL;  /* Pointer to found signal */
01209 
01210   instl = db_list[curr_db]->inst_head;
01211   while( (instl != NULL) && ((sig = instance_find_signal_by_exclusion_id( instl->inst, id, found_funit )) == NULL) ) {
01212     instl = instl->next;
01213   }
01214 
01215   if( sig != NULL ) {
01216     *found_funit = funit_get_curr_module( *found_funit );
01217   }
01218 
01219   PROFILE_END;
01220 
01221   return( sig );
01222 
01223 }

char* exclude_format_reason ( const char *  old_str  ) 

Formats the reason string for storage purposes.

Returns:
Returns the reformatted string that removes all newlines and extra spaces.
Parameters:
old_str Pointer to string that needs to be formatted

References FALSE, PROFILE, PROFILE_END, realloc_safe, strdup_safe, and TRUE.

Referenced by exclude_get_message().

01283   { PROFILE(EXCLUDE_FORMAT_REASON);
01284 
01285   char*        msg;                  /* Pointer to the reformatted message */
01286   unsigned int msg_size;             /* Current size of message array */
01287   char         c;                    /* Current character */
01288   bool         sp_just_seen = TRUE;  /* Set to TRUE if a space character was just seen */
01289   char         str[100];             /* Temporary string */
01290   unsigned int i;                    /* Loop iterator */
01291   unsigned int index        = 0;     /* Index into str array to store next character */
01292 
01293   msg      = strdup_safe( "" );
01294   msg_size = 1;
01295   str[0]   = '\0';
01296 
01297   if( old_str != NULL ) {
01298 
01299     for( i=0; i<strlen( old_str ); i++ ) {
01300 
01301       c = old_str[i];
01302 
01303       /* Convert any formatting characters to spaces */
01304       c = ((c == '\n') || (c == '\t') || (c == '\r')) ? ' ' : c;
01305 
01306       /* If the user has specified multiple formatting characters together, ignore all but the first. */
01307       if( (c != ' ') || !sp_just_seen ) {
01308         sp_just_seen = (c == ' ') ? TRUE : FALSE;
01309         str[(index % 99) + 0] = c;
01310         str[(index % 99) + 1] = '\0';
01311         if( ((index + 1) % 99) == 0 ) {
01312           msg = (char*)realloc_safe( msg, msg_size, (msg_size + strlen( str )) );
01313           msg_size += strlen( str );
01314           strcat( msg, str );
01315           str[0] = '\0';
01316         }
01317         index++;
01318       }
01319 
01320     }
01321 
01322   }
01323 
01324   /* Take what's left in the str array and put it into the msg array */
01325   if( strlen( str ) > 0 ) {
01326     msg = (char*)realloc_safe( msg, msg_size, (msg_size + strlen( str )) );
01327     strcat( msg, str );
01328     msg[strlen(msg)] = '\0';
01329   }
01330 
01331   PROFILE_END;
01332 
01333   return( msg );
01334 
01335 } 

static bool exclude_fsm_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the FSM that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References fsm_table_s::arcs, exclude_find_fsm_arc(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, asuppl_u::excluded, NORMAL, asuppl_u::part, print_output(), PROFILE, PROFILE_END, fsm_table_arc_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01722   { PROFILE(EXCLUDE_FSM_FROM_ID);
01723 
01724   int        arc_index;    /* Index of found state transition in arcs array */
01725   fsm_table* found_fsm;    /* Pointer to found FSM structure */
01726   func_unit* found_funit;  /* Pointer to functional unit containing arc */
01727 
01728   if( (arc_index = exclude_find_fsm_arc( atoi( id + 1 ), &found_fsm, &found_funit )) != -1 ) {
01729 
01730     int         prev_excluded;
01731     unsigned int rv;
01732 
01733     /* Get the previously excluded value */
01734     prev_excluded = found_fsm->arcs[arc_index]->suppl.part.excluded;
01735 
01736     /* If the user has specified to print the exclusion, do so */
01737     if( exclude_print ) {
01738 
01739       exclude_print_exclusion( id, prev_excluded, found_funit );
01740 
01741     /* Otherwise, perform the exclusion */
01742     } else {
01743 
01744       /* Output result */
01745       if( prev_excluded == 0 ) {
01746         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01747       } else {
01748         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01749       }
01750       assert( rv < USER_MSG_LENGTH );
01751       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01752 
01753       /* Toggle the exclude bit */
01754       found_fsm->arcs[arc_index]->suppl.part.excluded = (prev_excluded ^ 1);
01755 
01756       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01757       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) {
01758         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01759       }
01760 
01761     }
01762 
01763   } else {
01764 
01765     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find FSM arc associated with exclusion ID %s", id );
01766     assert( rv < USER_MSG_LENGTH );
01767     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01768 
01769   }
01770 
01771   PROFILE_END;
01772 
01773   return( (arc_index != -1) && !exclude_print );
01774 
01775 }

static char * exclude_get_message ( const char *  eid  )  [static]
Returns:
Returns the message specified by the user.
Parameters:
eid Exclusion ID to get message for

References exclude_format_reason(), FALSE, free_safe, NORMAL, print_output(), PROFILE, PROFILE_END, realloc_safe, strdup_safe, TRUE, user_msg, and USER_MSG_LENGTH.

Referenced by exclude_handle_exclude_reason(), and exclude_resolve_reason().

01342   { PROFILE(EXCLUDED_GET_MESSAGE);
01343 
01344   char*        msg;                  /* Pointer to the message from the user */
01345   unsigned int msg_size;             /* The current size of the specified message */
01346   char         c;                    /* Current character */
01347   bool         nl_just_seen = TRUE;  /* Set to TRUE if a newline was just seen */
01348   bool         sp_just_seen = TRUE;  /* Set to TRUE if a space character was just seen */
01349   int          index        = 0;     /* Current string index */
01350   char         str[100];
01351   char*        formatted_msg;        /* Formatted message */
01352   unsigned int rv;
01353 
01354   rv = snprintf( user_msg, USER_MSG_LENGTH, "Please specify a reason for exclusion for exclusion ID %s (Enter a '.' (period) on a newline to end):\n", eid );
01355   assert( rv < USER_MSG_LENGTH );
01356   print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01357 
01358   msg      = strdup_safe( "" );
01359   msg_size = 1;
01360   str[0]   = '\0';
01361 
01362   while( ((c = (char)getchar()) != EOF) && ((c != '.') || !nl_just_seen) ) {
01363 
01364     /* Mark if we have just seen a newline (for the purposes of determining if the user has completed input) */
01365     nl_just_seen = (c == '\n') ? TRUE : FALSE;
01366 
01367     /* Place the read character into the temporary string */
01368     str[(index % 99) + 0] = c;
01369     str[(index % 99) + 1] = '\0';
01370 
01371     /*
01372      If the temporary string has been filled, realloc the msg and append the contents of the the temporary array to this newly
01373      allocated array.
01374     */
01375     if( ((index + 1) % 99) == 0 ) {
01376       msg = (char*)realloc_safe( msg, msg_size, (msg_size + strlen( str )) );
01377       msg_size += strlen( str );
01378       strcat( msg, str );
01379     }
01380 
01381     index++;
01382 
01383   }
01384 
01385   if( strlen( str ) > 0 ) {
01386     msg = (char*)realloc_safe( msg, msg_size, (msg_size + strlen( str )) );
01387     strcat( msg, str );
01388     msg[strlen(msg)-1] = '\0';
01389   }
01390 
01391   print_output( "", NORMAL, __FILE__, __LINE__ );
01392 
01393   /* Now reformat the message */
01394   formatted_msg = exclude_format_reason( msg );
01395 
01396   free_safe( msg, (strlen( msg ) + ((strlen( str ) > 0) ? 2 : 1)) );
01397 
01398   PROFILE_END;
01399 
01400   return( formatted_msg );
01401 
01402 }

static void exclude_handle_exclude_reason ( int  prev_excluded,
const char *  id,
func_unit funit 
) [static]

Handle the creation/deallocation of the exclude reason structure.

Parameters:
prev_excluded Specifies if the coverage point was previously excluded or not
id Exclusion ID
funit Functional unit containing sig

References exclude_add_exclude_reason(), exclude_get_message(), exclude_remove_exclude_reason(), free_safe, PROFILE, and PROFILE_END.

Referenced by exclude_assert_from_id(), exclude_expr_from_id(), exclude_fsm_from_id(), exclude_line_from_id(), exclude_memory_from_id(), and exclude_toggle_from_id().

01411   { PROFILE(EXCLUDE_HANDLE_EXCLUDE_REASON);
01412 
01413   /*
01414    If the coverage point was not previously excluded, allow the user to specify a reason and
01415    store this information in the functional unit.
01416   */
01417   if( prev_excluded == 0 ) { 
01418 
01419     char* str = exclude_get_message( id );
01420 
01421     if( (str != NULL) && (strlen( str ) > 0) ) {
01422       exclude_add_exclude_reason( id[0], atoi( id + 1 ), str, funit );
01423     } else {
01424       free_safe( str, (strlen( str ) + 1) );
01425     }
01426 
01427   /*
01428    If the coverage point was previously excluded, attempt to find the matching exclusion reason, and, if
01429    it is found, remove it from the list.
01430   */
01431   } else {
01432 
01433     exclude_remove_exclude_reason( id[0], atoi( id + 1 ), funit );
01434 
01435   }
01436 
01437   PROFILE_END;
01438 
01439 }

bool exclude_is_assert_excluded ( func_unit funit,
char *  inst_name,
int  expr_id 
)

Returns TRUE if given assertion is excluded from coverage.

Returns:
Returns TRUE if the given assertion is excluded from coverage consideration; otherwise, returns FALSE.
Parameters:
funit Pointer to functional unit containing the assertion to exclude/include
inst_name Name of assertion instance to exclude/include
expr_id Expression ID to exclude/include

References funit_inst_s::child_head, curr_db, esuppl_u::excluded, statement_s::exp, FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), funit_inst_s::funit, expression_s::id, inst_head, inst_link_find_by_funit(), funit_inst_s::name, funit_inst_s::next, esuppl_u::part, PROFILE, PROFILE_END, expression_s::suppl, and TRUE.

00659   { PROFILE(EXCLUDE_IS_ASSERT_EXCLUDED);
00660 
00661   funit_inst* inst;        /* Pointer to found functional unit instance */
00662   funit_inst* curr_child;  /* Pointer to current child functional instance */
00663   exp_link*   expl;        /* Pointer to current expression link */
00664   int         ignore = 0;  /* Number of instances to ignore */
00665   statement*  stmt;        /* Pointer to current statement */
00666 
00667   /* Find the functional unit instance that matches the description */
00668   if( (inst = inst_link_find_by_funit( funit, db_list[curr_db]->inst_head, &ignore )) != NULL ) {
00669 
00670     func_iter fi;
00671 
00672     /* Find child instance */
00673     curr_child = inst->child_head;
00674     while( (curr_child != NULL) && (strcmp( curr_child->name, inst_name ) != 0) ) {
00675       curr_child = curr_child->next;
00676     }
00677     assert( curr_child != NULL );
00678 
00679     /* Initialize the functional unit iterator */
00680     func_iter_init( &fi, curr_child->funit, TRUE, FALSE );
00681 
00682     while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->id != expr_id) );
00683 
00684     /* Deallocate functional unit statement iterator */
00685     func_iter_dealloc( &fi );
00686 
00687   }
00688 
00689   PROFILE_END;
00690 
00691   return( (inst == NULL) || (stmt == NULL) || (stmt->exp->id != expr_id) || (stmt->exp->suppl.part.excluded == 1) );
00692 
00693 }

bool exclude_is_comb_excluded ( func_unit funit,
int  expr_id,
int  uline_id 
)
Returns:
Returns TRUE if specified underlined expression is excluded from coverage; otherwise, returns FALSE.
Parameters:
funit Pointer to functional unit containing the expression to exclude/include
expr_id Expression ID of the root expression to exclude/include
uline_id Underline ID of expression to exclude/include

References esuppl_u::excluded, statement_s::exp, expression_find_uline_id(), FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), expression_s::id, esuppl_u::part, PROFILE, PROFILE_END, expression_s::suppl, and TRUE.

00479   { PROFILE(EXCLUDE_IS_COMB_EXCLUDED);
00480 
00481   func_iter   fi;      /* Functional unit iterator */
00482   statement*  stmt;    /* Pointer to found statement */
00483   expression* subexp;  /* Pointer to found expression */
00484 
00485   /* Find the matching root expression */
00486   func_iter_init( &fi, funit, TRUE, FALSE );
00487   while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->id != expr_id) );
00488   func_iter_dealloc( &fi );
00489 
00490   if( stmt != NULL ) {
00491     subexp = expression_find_uline_id( stmt->exp, uline_id );
00492   }
00493 
00494   PROFILE_END;
00495 
00496   return( (stmt == NULL) || (subexp == NULL) || (subexp->suppl.part.excluded == 1) );
00497 
00498 }

bool exclude_is_fsm_excluded ( func_unit funit,
int  expr_id,
char *  from_state,
char *  to_state 
)

Returns TRUE if the specified FSM is excluded in the given functional unit.

Returns:
Returns TRUE if the given FSM state transition was excluded from coverage; otherwise, returns FALSE.
Parameters:
funit Pointer to functional unit containing FSM to exclude/include
expr_id Expression ID of FSM
from_state String form of the from_state value
to_state String form of the to_state value

References arc_find_arc(), arc_find_from_state(), arc_find_to_state(), fsm_table_s::arcs, asuppl_u::excluded, FALSE, func_unit_s::fsm_head, expression_s::id, fsm_link_s::next, asuppl_u::part, PROFILE, PROFILE_END, fsm_table_arc_s::suppl, fsm_s::table, fsm_link_s::table, fsm_s::to_state, vector_dealloc(), and vector_from_string().

00556   { PROFILE(EXCLUDE_IS_FSM_EXCLUDED);
00557 
00558   fsm_link* curr_fsm;     /* Pointer to current FSM structure */
00559   int       found_index;  /* Index of found state transition */
00560 
00561   /* Find the corresponding table */
00562   curr_fsm = funit->fsm_head;
00563   while( (curr_fsm != NULL) && (curr_fsm->table->to_state->id != expr_id) ) {
00564     curr_fsm = curr_fsm->next;
00565   }
00566 
00567   if( curr_fsm != NULL ) {
00568 
00569     vector* from_vec;
00570     vector* to_vec;
00571     int     from_base, to_base;
00572 
00573     /* Convert from/to state strings into vector values */
00574     vector_from_string( &from_state, FALSE, &from_vec, &from_base );
00575     vector_from_string( &to_state, FALSE, &to_vec, &to_base );
00576 
00577     /* Find the arc entry and perform the exclusion assignment and coverage recalculation */
00578     found_index = arc_find_arc( curr_fsm->table->table, arc_find_from_state( curr_fsm->table->table, from_vec ), arc_find_to_state( curr_fsm->table->table, to_vec ) );
00579 
00580     /* Deallocate vectors */
00581     vector_dealloc( from_vec );
00582     vector_dealloc( to_vec );
00583 
00584   }
00585 
00586   PROFILE_END;
00587 
00588   return( (curr_fsm == NULL) || (found_index == -1) || (curr_fsm->table->table->arcs[found_index]->suppl.part.excluded == 1) );
00589 
00590 }

bool exclude_is_line_excluded ( func_unit funit,
int  line 
)

Returns TRUE if the specified line is excluded in the given functional unit.

Returns:
Returns TRUE if the specified line is excluded in the given functional unit; otherwise, returns FALSE.
Parameters:
funit Pointer to functional unit to check
line Line number of line to check

References statement_s::exp, FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), expression_s::line, statement_s::part, PROFILE, PROFILE_END, statement_s::suppl, and TRUE.

00351   { PROFILE(EXCLUDE_IS_LINE_EXCLUDED);
00352 
00353   func_iter  fi;    /* Functional unit iterator */
00354   statement* stmt;  /* Pointer to current statement */
00355 
00356   func_iter_init( &fi, funit, TRUE, FALSE );
00357   while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->line != line) );
00358   func_iter_dealloc( &fi );
00359 
00360   PROFILE_END;
00361 
00362   return( (stmt == NULL) || (stmt->suppl.part.excluded == 1) );
00363 
00364 }

static bool exclude_is_parent_excluded ( expression expr  )  [static]
Returns:
Returns TRUE if a parent expression of this expression was found to be excluded from coverage; otherwise, returns FALSE.
Parameters:
expr Pointer to current expression to evaluate

References ESUPPL_EXCLUDED, ESUPPL_IS_ROOT, expr_stmt_u::expr, expression_s::parent, and expression_s::suppl.

Referenced by exclude_expr_assign_and_recalc().

00087   {
00088 
00089   return( (expr != NULL) &&
00090           ((ESUPPL_EXCLUDED( expr->suppl ) == 1) ||
00091            ((ESUPPL_IS_ROOT( expr->suppl ) == 0) && exclude_is_parent_excluded( expr->parent->expr ))) );
00092 
00093 }

bool exclude_is_toggle_excluded ( func_unit funit,
char *  sig_name 
)

Returns TRUE if the specified signal is excluded in the given functional unit.

Returns:
Returns TRUE if the specified signal is excluded from coverage consideration; otherwise, returns FALSE.
Parameters:
funit Pointer to functional unit to check
sig_name Name of signal to search for

References ssuppl_u::excluded, FALSE, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), vsignal_s::name, ssuppl_u::part, PROFILE, PROFILE_END, vsignal_s::suppl, and TRUE.

00414   { PROFILE(EXCLUDE_IS_TOGGLE_EXCLUDED);
00415 
00416   func_iter fi;   /* Functional unit iterator */
00417   vsignal*  sig;  /* Pointer to current signal */
00418 
00419   func_iter_init( &fi, funit, FALSE, TRUE );
00420   while( ((sig = func_iter_get_next_signal( &fi )) != NULL) && (strcmp( sig->name, sig_name ) != 0) );
00421   func_iter_dealloc( &fi );
00422 
00423   PROFILE_END;
00424 
00425   return( (sig == NULL) || (sig->suppl.part.excluded == 1) );
00426 
00427 }

static bool exclude_line_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the line that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References ESUPPL_IS_ROOT, exclude_find_expression(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, esuppl_u::excluded, NORMAL, expression_s::parent, esuppl_u::part, statement_s::part, print_output(), PROFILE, PROFILE_END, expr_stmt_u::stmt, statement_s::suppl, expression_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01477   { PROFILE(EXCLUDE_LINE_FROM_ID);
01478 
01479   expression* exp;          /* Pointer to found expression */
01480   func_unit*  found_funit;  /* Pointer to functional unit containing found expression */
01481 
01482   if( (exp = exclude_find_expression( atoi( id + 1 ), &found_funit )) != NULL ) {
01483 
01484     int          prev_excluded;
01485     unsigned int rv;
01486 
01487     assert( ESUPPL_IS_ROOT( exp->suppl ) == 1 );
01488 
01489     /* Get the previously excluded value */
01490     prev_excluded = exp->parent->stmt->suppl.part.excluded;
01491 
01492     /* If the user wants to print the information do so */
01493     if( exclude_print ) {
01494 
01495       exclude_print_exclusion( id, prev_excluded, found_funit );
01496 
01497     /* Otherwise, perform the exclusion */
01498     } else {
01499 
01500       /* Output result */
01501       if( prev_excluded == 0 ) {
01502         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01503       } else {
01504         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01505       }
01506       assert( rv < USER_MSG_LENGTH );
01507       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01508   
01509       /* Set the exclude bits in the expression supplemental field */
01510       exp->suppl.part.excluded               = (prev_excluded ^ 1);
01511       exp->parent->stmt->suppl.part.excluded = (prev_excluded ^ 1);
01512 
01513       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01514       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) {
01515         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01516       }
01517 
01518     }
01519 
01520   } else {
01521 
01522     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find line associated with exclusion ID %s", id );
01523     assert( rv < USER_MSG_LENGTH );
01524     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01525 
01526   }
01527 
01528   PROFILE_END;
01529 
01530   return( (exp != NULL) && !exclude_print );
01531 
01532 }

static bool exclude_memory_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the memory that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References exclude_find_signal(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, ssuppl_u::excluded, NORMAL, ssuppl_u::part, print_output(), PROFILE, PROFILE_END, vsignal_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01601   { PROFILE(EXCLUDE_MEMORY_FROM_ID);
01602 
01603   vsignal*   sig;          /* Pointer to found signal */
01604   func_unit* found_funit;  /* Pointer to functional unit containing sig */
01605   
01606   if( (sig = exclude_find_signal( atoi( id + 1 ), &found_funit )) != NULL ) {
01607   
01608     int          prev_excluded = sig->suppl.part.excluded;
01609     unsigned int rv;
01610     
01611     /* If the user has specified to print the exclusion, do so */
01612     if( exclude_print ) {
01613 
01614       exclude_print_exclusion( id, prev_excluded, found_funit );
01615 
01616     /* Otherwise, perform the exclusion */
01617     } else {
01618 
01619       /* Output result */
01620       if( prev_excluded == 0 ) {
01621         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01622       } else {
01623         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01624       }
01625       assert( rv < USER_MSG_LENGTH );
01626       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01627 
01628       /* Set the exclude bits in the expression supplemental field */
01629       sig->suppl.part.excluded = (prev_excluded ^ 1);
01630    
01631       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01632       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) {
01633         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01634       }
01635 
01636     }
01637   
01638   } else {
01639 
01640     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find memory associated with exclusion ID %s", id );
01641     assert( rv < USER_MSG_LENGTH );
01642     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01643 
01644   }
01645 
01646   PROFILE_END;
01647 
01648   return( (sig != NULL) && !exclude_print );
01649 
01650 }

void exclude_merge ( func_unit base,
exclude_reason er 
)

Performs exclusion reason merging.

Reads the given exclude reason structure information from the line read from the CDD file.

Parameters:
base Pointer to base functional unit to merge into
er Pointer to exclusion reason to merge

References func_unit_s::er_head, func_unit_s::er_tail, exclude_find_exclude_reason(), exclude_resolve_reason(), exclude_reason_s::id, malloc_safe, merge_er_value, exclude_reason_s::next, PROFILE, PROFILE_END, exclude_reason_s::reason, strdup_safe, exclude_reason_s::timestamp, and exclude_reason_s::type.

Referenced by funit_merge().

01157   { PROFILE(EXCLUDE_MERGE);
01158 
01159   exclude_reason* found_er;
01160 
01161   /* If the exclusion reason does not exist in the base CDD, go ahead and add it */
01162   if( (found_er = exclude_find_exclude_reason( er->type, er->id, base )) == NULL ) {
01163 
01164     exclude_reason* new_er;
01165  
01166     /* Allocate and initialize the exclude reason structure */
01167     new_er            = (exclude_reason*)malloc_safe( sizeof( exclude_reason ) );
01168     new_er->type      = er->type;
01169     new_er->id        = er->id;
01170     new_er->timestamp = er->timestamp;
01171     new_er->reason    = strdup_safe( er->reason );
01172     new_er->next      = NULL;
01173 
01174     /* Add the given exclude reason to the current functional unit list */
01175     if( base->er_head == NULL ) {
01176       base->er_head = base->er_tail = new_er;
01177     } else {
01178       base->er_tail->next = new_er;
01179       base->er_tail       = new_er;
01180     }
01181 
01182   /* Otherwise, if the exclusion reason does exist, check for a conflict and handle it */
01183   } else {
01184 
01185     /*
01186      If the exclusion reason string does not match the current string, resolve the conflict appropriately
01187      (otherwise, just use the reason in the base functional unit).
01188     */
01189     if( strcmp( found_er->reason, er->reason ) != 0 ) {
01190       exclude_resolve_reason( found_er, base, merge_er_value, er->reason, er->timestamp );
01191     }
01192 
01193   }
01194 
01195   PROFILE_END;
01196 
01197 }

static bool exclude_parse_args ( int  argc,
int  last_arg,
const char **  argv 
) [static]
Returns:
Returns TRUE if the help option was parsed.
Exceptions:
anonymous Throw Throw Throw

Parses the exclude argument list, placing all parsed values into global variables. If an argument is found that is not valid for the score operation, an error message is displayed to the user.

Parameters:
argc Number of arguments in argument list argv
last_arg Index of last parsed argument from list
argv Argument list passed to this program

References Catch_anonymous, check_option_value(), exclude_cdd, exclude_print, exclude_prompt_for_msgs, exclude_usage(), FALSE, FATAL, file_exists(), free_safe, print_output(), read_command_file(), str_link_add(), strdup_safe, Throw, TRUE, Try, user_msg, and USER_MSG_LENGTH.

Referenced by command_exclude().

00799   {
00800 
00801   int  i;
00802   bool help_found = FALSE;
00803 
00804   i = last_arg + 1;
00805 
00806   while( (i < argc) && !help_found ) {
00807 
00808     if( strncmp( "-h", argv[i], 2 ) == 0 ) {
00809 
00810       exclude_usage();
00811       help_found = TRUE;
00812 
00813     } else if( strncmp( "-f", argv[i], 2 ) == 0 ) {
00814 
00815       if( check_option_value( argc, argv, i ) ) {
00816         char**       arg_list = NULL;
00817         int          arg_num  = 0;
00818         unsigned int j;
00819         i++;
00820         Try {
00821           read_command_file( argv[i], &arg_list, &arg_num );
00822           help_found = exclude_parse_args( arg_num, -1, (const char**)arg_list );
00823         } Catch_anonymous {
00824           for( j=0; j<arg_num; j++ ) {
00825             free_safe( arg_list[j], (strlen( arg_list[j] ) + 1) );
00826           }
00827           free_safe( arg_list, (sizeof( char* ) * arg_num) );
00828           Throw 0;
00829         }
00830         for( j=0; j<arg_num; j++ ) {
00831           free_safe( arg_list[j], (strlen( arg_list[j] ) + 1) );
00832         }
00833         free_safe( arg_list, (sizeof( char* ) * arg_num) );
00834       } else {
00835         Throw 0;
00836       }
00837 
00838     } else if( strncmp( "-m", argv[i], 2 ) == 0 ) {
00839 
00840       exclude_prompt_for_msgs = TRUE;
00841 
00842     } else if( strncmp( "-p", argv[i], 2 ) == 0 ) {
00843 
00844       exclude_print = TRUE;
00845 
00846     } else if( strncmp( "-", argv[i], 1 ) == 0 ) {
00847 
00848       unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unknown exclude option (%s) specified.", argv[i] );
00849       assert( rv < USER_MSG_LENGTH );
00850       print_output( user_msg, FATAL, __FILE__, __LINE__ );
00851       Throw 0;
00852 
00853     } else if( (i + 1) == argc ) {
00854 
00855       /* Check to make sure that the user has specified at least one exclusion ID */
00856       if( excl_ids_head == NULL ) {
00857         print_output( "At least one exclusion ID must be specified", FATAL, __FILE__, __LINE__ );
00858         Throw 0;
00859       }
00860 
00861       if( file_exists( argv[i] ) ) {
00862         exclude_cdd = strdup_safe( argv[i] );
00863       } else {
00864         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Specified CDD file (%s) does not exist", argv[i] );
00865         assert( rv < USER_MSG_LENGTH );
00866         print_output( user_msg, FATAL, __FILE__, __LINE__ );
00867         Throw 0;
00868       }
00869 
00870     } else {
00871 
00872       (void)str_link_add( strdup_safe( argv[i] ), &excl_ids_head, &excl_ids_tail );
00873 
00874     }
00875 
00876     i++;
00877 
00878   }
00879 
00880   return( help_found );
00881 
00882 }

static void exclude_print_exclusion ( const char *  id,
int  excluded,
func_unit funit 
) [static]

Prints the exclusion information to standard output.

Parameters:
id Exclusion ID to output
excluded Specifies the current value of the exclusion is exclude (1) or include (0)
funit Pointer to functional unit containing the excluded structure

References exclude_find_exclude_reason(), FALSE, PROFILE, PROFILE_END, exclude_reason_s::reason, and report_output_exclusion_reason().

Referenced by exclude_assert_from_id(), exclude_expr_from_id(), exclude_fsm_from_id(), exclude_line_from_id(), exclude_memory_from_id(), and exclude_toggle_from_id().

01448   { PROFILE(EXCLUDE_PRINT_EXCLUSION);
01449 
01450   printf( "Exclusion ID: %s, Status: %s\n", id, ((excluded == 1) ? "EXCLUDED" : "INCLUDED") );
01451 
01452   /* Only output an exclusion message if we are currently excluded */
01453   if( excluded == 1 ) {
01454 
01455     exclude_reason* er = exclude_find_exclude_reason( id[0], atoi( id + 1 ), funit );
01456 
01457     if( er != NULL ) {
01458       report_output_exclusion_reason( stdout, 2, er->reason, FALSE );
01459     } else {
01460       report_output_exclusion_reason( stdout, 2, "No exclusion information has been specified.", FALSE );
01461     }
01462 
01463   }
01464 
01465   PROFILE_END;
01466 
01467 }

static void exclude_remove_exclude_reason ( char  type,
int  id,
func_unit funit 
) [static]

Handles the deallocation of the exclude reason structure.

Parameters:
type Exclusion ID type
id Exclusion ID number
funit Functional unit containing sig

References func_unit_s::er_head, func_unit_s::er_tail, free_safe, exclude_reason_s::id, exclude_reason_s::next, PROFILE, PROFILE_END, exclude_reason_s::reason, and exclude_reason_s::type.

Referenced by exclude_handle_exclude_reason(), exclude_resolve_reason(), exclude_set_assert_exclude(), exclude_set_comb_exclude(), exclude_set_fsm_exclude(), exclude_set_line_exclude(), and exclude_set_toggle_exclude().

00314   { PROFILE(EXCLUDE_REMOVE_EXCLUDE_REASON);
00315 
00316   exclude_reason* last_er = NULL;
00317   exclude_reason* er      = funit->er_head;
00318 
00319   /*
00320    If the coverage point was previously excluded, attempt to find the matching exclusion reason, and, if
00321    it is found, remove it from the list.
00322   */
00323   while( (er != NULL) && ((er->type != type) || (er->id != id)) ) {
00324     last_er = er; 
00325     er      = er->next;
00326   }
00327 
00328   if( er != NULL ) { 
00329     if( last_er == NULL ) { 
00330       funit->er_head = er->next;
00331       if( er->next == NULL ) {
00332         funit->er_tail = NULL;
00333       }
00334     } else {
00335       last_er->next = er->next;
00336     }
00337     free_safe( er->reason, (strlen( er->reason ) + 1) );
00338     free_safe( er, sizeof( exclude_reason ) );
00339   }
00340 
00341   PROFILE_END;
00342 
00343 }

void exclude_resolve_reason ( exclude_reason orig_er,
func_unit orig_funit,
int  resolution,
const char *  new_reason,
long  new_timestamp 
)

Resolves an exclusion reason conflict according to the merge option specified by the user.

Parameters:
orig_er Pointer to the original exclusion reason structure
orig_funit Pointer to the original functional unit
resolution Type of resolution to perform
new_reason Reason from new CDD file
new_timestamp Timestamp from new CDD file

References db_gen_exclusion_id(), exclude_get_message(), exclude_remove_exclude_reason(), FALSE, free_safe, exclude_reason_s::id, MERGE_ER_ALL, MERGE_ER_FIRST, MERGE_ER_LAST, MERGE_ER_NEW, MERGE_ER_NONE, MERGE_ER_OLD, PROFILE, PROFILE_END, realloc_safe, exclude_reason_s::reason, report_output_exclusion_reason(), strdup_safe, Throw, exclude_reason_s::timestamp, and exclude_reason_s::type.

Referenced by exclude_db_merge(), and exclude_merge().

00986   { PROFILE(EXCLUDE_RESOLVE_REASON);
00987 
00988   unsigned int slen;
00989   char*        eid;
00990   char         answer;
00991   char         c;
00992  
00993   switch( resolution ) {
00994 
00995     case MERGE_ER_NONE :
00996       eid = db_gen_exclusion_id( orig_er->type, orig_er->id );
00997       printf( "Exclusion reason conflict for %s\n", eid );
00998       printf( "  Exclusion reason #1:\n" );
00999       report_output_exclusion_reason( stdout, 4, orig_er->reason, FALSE );
01000       printf( "  Exclusion reason #2:\n" );
01001       report_output_exclusion_reason( stdout, 4, new_reason, FALSE );
01002       do {
01003         printf( "Choose an exclusion reason to use (none, 1, 2, both, rewrite, abort): " );
01004         answer = (char)getchar();
01005         while( ((c = (char)getchar()) != EOF) && (c != '\n') );
01006       } while( (answer != 'n') && (answer != '1') && (answer != '2') && (answer != 'b') && (answer != 'r') && (answer != 'a') );
01007       switch( answer ) {
01008         case 'n' :
01009           exclude_remove_exclude_reason( orig_er->type, orig_er->id, orig_funit );
01010           break;
01011         case '1' :
01012           /* No need to do anything */
01013           break;
01014         case '2' :
01015           exclude_resolve_reason( orig_er, orig_funit, MERGE_ER_LAST, new_reason, new_timestamp );
01016           break;
01017         case 'b' :
01018           exclude_resolve_reason( orig_er, orig_funit, MERGE_ER_ALL, new_reason, new_timestamp );
01019           break;
01020         case 'r' :
01021           free_safe( orig_er->reason, (strlen( orig_er->reason ) + 1) );
01022           orig_er->reason = exclude_get_message( eid );
01023           break;
01024         case 'a' :
01025           Throw 0;
01026           /*@-unreachable@*/
01027           break;
01028           /*@=unreachable@*/
01029       }
01030       free_safe( eid, (strlen( eid ) + 1) );
01031       break;
01032 
01033     case MERGE_ER_FIRST :
01034       /* Do nothing.  The first message is already in the base. */
01035       break;
01036 
01037     case MERGE_ER_LAST :
01038       free_safe( orig_er->reason, (strlen( orig_er->reason ) + 1) );
01039       orig_er->reason = strdup_safe( new_reason );
01040       break;
01041 
01042     case MERGE_ER_ALL :
01043       slen = strlen( orig_er->reason ) + 1 + strlen( new_reason ) + 1;
01044       if( orig_er->reason[strlen( orig_er->reason ) - 1] != '.' ) {
01045         slen++;
01046       }
01047       orig_er->reason = (char*)realloc_safe( orig_er->reason, (strlen( orig_er->reason ) + 1), slen );
01048       if( orig_er->reason[strlen( orig_er->reason ) - 1] != '.' ) {
01049         strcat( orig_er->reason, "." );
01050       }
01051       strcat( orig_er->reason, " " );
01052       strcat( orig_er->reason, new_reason );
01053       break;
01054 
01055     case MERGE_ER_NEW :
01056       if( orig_er->timestamp < new_timestamp ) {
01057         free_safe( orig_er->reason, (strlen( orig_er->reason ) + 1) );
01058         orig_er->reason = strdup_safe( new_reason );
01059       }
01060       break;
01061 
01062     case MERGE_ER_OLD :
01063       if( orig_er->timestamp > new_timestamp ) {
01064         free_safe( orig_er->reason, (strlen( orig_er->reason ) + 1) );
01065         orig_er->reason = strdup_safe( new_reason );
01066       }
01067       break;
01068 
01069     default :
01070       assert( 0 );
01071       break;
01072   }
01073 
01074   PROFILE_END;
01075 
01076 }

void exclude_set_assert_exclude ( func_unit funit,
char *  inst_name,
int  expr_id,
int  value,
char *  reason,
statistic stat 
)

Sets the excluded bit for the specified expression in the given functional unit and recalculates the summary coverage information.

Finds the expression and functional unit instance for the given name, type and sig_name and calls the exclude_expr_assign_and_recalc function for the matching expression, setting the excluded bit of the expression and recalculating the summary coverage information.

Parameters:
funit Pointer to functional unit
inst_name Name of child instance to find in given functional unit
expr_id Expression ID of expression to set exclude value for
value Specifies if we should exclude (1) or include (0) the specified line
reason Reason for the exclusion (if value is 1)
stat Pointer to statistic structure to update

References funit_inst_s::child_head, curr_db, exclude_add_exclude_reason(), exclude_expr_assign_and_recalc(), exclude_remove_exclude_reason(), statement_s::exp, FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), funit_inst_s::funit, expression_s::id, inst_head, inst_link_find_by_funit(), funit_inst_s::name, funit_inst_s::next, PROFILE, PROFILE_END, and TRUE.

00707   { PROFILE(EXCLUDE_SET_ASSERT_EXCLUDE);
00708 
00709   funit_inst* inst;        /* Pointer to found functional unit instance */
00710   funit_inst* curr_child;  /* Pointer to current child functional instance */
00711   exp_link*   expl;        /* Pointer to current expression link */
00712   int         ignore = 0;  /* Number of instances to ignore */
00713 
00714   /* Find the functional unit instance that matches the description */
00715   if( (inst = inst_link_find_by_funit( funit, db_list[curr_db]->inst_head, &ignore )) != NULL ) {
00716    
00717     func_iter  fi;
00718     statement* stmt;
00719 
00720     /* Find child instance */
00721     curr_child = inst->child_head;
00722     while( (curr_child != NULL) && (strcmp( curr_child->name, inst_name ) != 0) ) {
00723       curr_child = curr_child->next;
00724     }
00725     assert( curr_child != NULL );
00726 
00727     /* Initialize the functional unit iterator */
00728     func_iter_init( &fi, curr_child->funit, TRUE, FALSE );
00729 
00730     while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->id != expr_id) );
00731 
00732     assert( stmt != NULL );
00733 
00734     /* Find the signal that matches the given signal name and sets its excluded bit */
00735     if( stmt->exp->id == expr_id ) {
00736 
00737       /* Exclude/include the assertion and recalculate the summary information */
00738       exclude_expr_assign_and_recalc( stmt->exp, curr_child->funit, (value == 1), FALSE, stat );
00739 
00740       /* Handle the exclusion reason */
00741       if( value == 1 ) {
00742         if( reason != NULL ) {
00743           exclude_add_exclude_reason( 'A', stmt->exp->id, reason, curr_child->funit );
00744         }
00745       } else {
00746         exclude_remove_exclude_reason( 'A', stmt->exp->id, curr_child->funit );
00747       }
00748 
00749     }
00750 
00751     /* Deallocate functional unit statement iterator */
00752     func_iter_dealloc( &fi );
00753 
00754   }
00755 
00756   PROFILE_END;
00757 
00758 }

void exclude_set_comb_exclude ( func_unit funit,
int  expr_id,
int  uline_id,
int  value,
char *  reason,
statistic stat 
)

Sets the excluded bit for the specified expression in the given functional unit and recalculates the summary coverage information.

Finds the expression and functional unit instance for the given name, type and sig_name and calls the exclude_expr_assign_and_recalc function for the matching expression, setting the excluded bit of the expression and recalculating the summary coverage information.

Parameters:
funit Pointer to functional unit
expr_id Expression ID of root expression to set exclude value for
uline_id Underline ID of expression to set exclude value for
value Specifies if we should exclude (1) or include (0) the specified line
reason Reason for the exclusion (if value is 1)
stat Pointer to statistic structure to update

References exclude_add_exclude_reason(), exclude_expr_assign_and_recalc(), exclude_remove_exclude_reason(), statement_s::exp, expression_find_uline_id(), FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), expression_s::id, PROFILE, PROFILE_END, and TRUE.

00512   { PROFILE(EXCLUDE_SET_COMB_EXCLUDE);
00513 
00514   func_iter  fi;    /* Functional unit iterator */
00515   statement* stmt;  /* Pointer to current statement */
00516 
00517   /* Find the root expression */
00518   func_iter_init( &fi, funit, TRUE, FALSE );
00519   while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->id != expr_id) );
00520   func_iter_dealloc( &fi );
00521 
00522   if( stmt != NULL ) {
00523 
00524     expression* subexp;
00525 
00526     if( (subexp = expression_find_uline_id( stmt->exp, uline_id )) != NULL ) {
00527 
00528       /* Exclude/include the expression and recalculate the summary information */
00529       exclude_expr_assign_and_recalc( subexp, funit, (value == 1), FALSE, stat );
00530 
00531       /* Handle the exclusion reason */
00532       if( value == 1 ) {
00533         if( reason != NULL ) {
00534           exclude_add_exclude_reason( 'E', subexp->id, reason, funit );
00535         }
00536       } else {
00537         exclude_remove_exclude_reason( 'E', subexp->id, funit );
00538       }
00539 
00540     }
00541 
00542   }
00543 
00544   PROFILE_END;
00545 
00546 }

void exclude_set_fsm_exclude ( func_unit funit,
int  expr_id,
char *  from_state,
char *  to_state,
int  value,
char *  reason,
statistic stat 
)

Sets the excluded bit for the specified state transition in the given functional unit and recalculates the summary coverage information.

Finds the FSM table associated with the specified expr_id and sets the include/exclude status of the given from_state/to_state transition appropriately.

Parameters:
funit Pointer to functional unit
expr_id Expression ID of output state variable
from_state String containing input state value
to_state String containing output state value
value Specifies if we should exclude (1) or include (0) the specified line
reason Reason for the exclusion (if value is 1)
stat Pointer to statistics structure to update

References arc_find_arc(), arc_find_from_state(), arc_find_to_state(), exclude_add_exclude_reason(), exclude_arc_assign_and_recalc(), exclude_remove_exclude_reason(), FALSE, func_unit_s::fsm_head, fsm_table_s::id, expression_s::id, fsm_link_s::next, PROFILE, PROFILE_END, fsm_s::table, fsm_link_s::table, fsm_s::to_state, vector_dealloc(), and vector_from_string().

00604   { PROFILE(EXCLUDE_SET_FSM_EXCLUDE);
00605 
00606   fsm_link* curr_fsm;
00607 
00608   /* Find the corresponding table */
00609   curr_fsm = funit->fsm_head;
00610   while( (curr_fsm != NULL) && (curr_fsm->table->to_state->id != expr_id) ) {
00611     curr_fsm = curr_fsm->next;
00612   }
00613 
00614   if( curr_fsm != NULL ) {
00615 
00616     vector* from_vec;
00617     vector* to_vec;
00618     int     found_index;
00619     int     from_base, to_base;
00620 
00621     /* Convert from/to state strings into vector values */
00622     vector_from_string( &from_state, FALSE, &from_vec, &from_base );
00623     vector_from_string( &to_state, FALSE, &to_vec, &to_base );
00624 
00625     /* Find the arc entry and perform the exclusion assignment and coverage recalculation */
00626     if( (found_index = arc_find_arc( curr_fsm->table->table, arc_find_from_state( curr_fsm->table->table, from_vec ), arc_find_to_state( curr_fsm->table->table, to_vec ) )) != -1 ) {
00627 
00628       /* Handle the exclusion and recalculate the summary values */
00629       exclude_arc_assign_and_recalc( curr_fsm->table->table, found_index, (value == 1), stat );
00630  
00631       /* Handle the exclusion reason */
00632       if( value == 1 ) {
00633         if( reason != NULL ) {
00634           exclude_add_exclude_reason( 'F', (curr_fsm->table->table->id + found_index), reason, funit );
00635         }
00636       } else {
00637         exclude_remove_exclude_reason( 'F', (curr_fsm->table->table->id + found_index), funit );
00638       }
00639 
00640     }
00641 
00642     /* Deallocate vectors */
00643     vector_dealloc( from_vec );
00644     vector_dealloc( to_vec );
00645 
00646   }
00647 
00648   PROFILE_END;
00649 
00650 }

void exclude_set_line_exclude ( func_unit funit,
int  line,
int  value,
char *  reason,
statistic stat 
)

Sets the excluded bit for all expressions in the given functional unit with the specified line number and recalculates the summary coverage information.

Finds the expression(s) and functional unit instance for the given name, type and line number and calls the exclude_expr_assign_and_recalc function for each matching expression, setting the excluded bit of the expression and recalculating the summary coverage information.

Parameters:
funit Pointer to functional unit
line Line number of expression that needs to be set
value Specifies if we should exclude (1) or include (0) the specified line
reason Reason for the exclusion if value is 1
stat Pointer to statistics structure to update

References exclude_add_exclude_reason(), exclude_expr_assign_and_recalc(), exclude_remove_exclude_reason(), statement_s::exp, FALSE, func_iter_dealloc(), func_iter_get_next_statement(), func_iter_init(), expression_s::id, expression_s::line, PROFILE, PROFILE_END, and TRUE.

00377   { PROFILE(EXCLUDE_SET_LINE_EXCLUDE);
00378 
00379   func_iter  fi;    /* Functional unit iterator */
00380   statement* stmt;  /* Pointer to current statement */
00381 
00382   func_iter_init( &fi, funit, TRUE, FALSE );
00383 
00384   do {
00385     while( ((stmt = func_iter_get_next_statement( &fi )) != NULL) && (stmt->exp->line != line) );
00386     if( stmt != NULL ) {
00387 
00388       exclude_expr_assign_and_recalc( stmt->exp, funit, (value == 1), TRUE, stat );
00389 
00390       /* Handle the exclusion reason */
00391       if( value == 1 ) {
00392         if( reason != NULL ) {
00393           exclude_add_exclude_reason( 'L', stmt->exp->id, reason, funit );
00394         } 
00395       } else {
00396         exclude_remove_exclude_reason( 'L', stmt->exp->id, funit );
00397       }
00398 
00399     }
00400   } while( stmt != NULL );
00401 
00402   func_iter_dealloc( &fi );
00403 
00404   PROFILE_END;
00405 
00406 }

void exclude_set_toggle_exclude ( func_unit funit,
const char *  sig_name,
int  value,
char  type,
char *  reason,
statistic stat 
)

Sets the excluded bit for the specified signal in the given functional unit and recalculates the summary coverage information.

Finds the signal and functional unit instance for the given name, type and sig_name and calls the exclude_sig_assign_and_recalc function for the matching signal, setting the excluded bit of the signal and recalculating the summary coverage information.

Parameters:
funit Pointer to functional unit
sig_name Name of signal to set the toggle exclusion for
value Specifies if we should exclude (1) or include (0) the specified line
type Exclusion ID type (T=toggle, M=memory)
reason Reason for exclusion (if value is 1)
stat Pointer to statistics structure to update

References exclude_add_exclude_reason(), exclude_remove_exclude_reason(), exclude_sig_assign_and_recalc(), FALSE, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), vsignal_s::id, vsignal_s::name, PROFILE, PROFILE_END, and TRUE.

00441   { PROFILE(EXCLUDE_SET_TOGGLE_EXCLUDE);
00442 
00443   func_iter fi;   /* Functional unit iterator */
00444   vsignal*  sig;  /* Pointer to current signal */
00445 
00446   /* Find the signal that matches the given signal name, if it exists */
00447   func_iter_init( &fi, funit, FALSE, TRUE );
00448   while( ((sig = func_iter_get_next_signal( &fi )) != NULL) && (strcmp( sig->name, sig_name ) != 0) );
00449   func_iter_dealloc( &fi );
00450 
00451   /* Set its exclude bit if it exists */
00452   if( sig != NULL ) {
00453 
00454     /* Exclude/include the signal and recalculate the summary information */
00455     exclude_sig_assign_and_recalc( sig, (value == 1), stat );
00456 
00457     /* Handle the exclusion reason */
00458     if( value == 1 ) {
00459       if( reason != NULL ) {
00460         exclude_add_exclude_reason( type, sig->id, reason, funit ); 
00461       }
00462     } else {
00463       exclude_remove_exclude_reason( type, sig->id, funit );
00464     }
00465       
00466   }
00467 
00468   PROFILE_END;
00469 
00470 }

static void exclude_sig_assign_and_recalc ( vsignal sig,
bool  excluded,
statistic stat 
) [static]

Sets the specified signal's exclude bit to the given value and recalculates all affected coverage information for this instance.

Parameters:
sig Pointer to signal that is being excluded/included
excluded Specifies if signal is being excluded or included
stat Pointer to statistic structure to update

References ssuppl_u::excluded, statistic_s::mem_excluded, statistic_s::mem_rd_hit, statistic_s::mem_tog01_hit, statistic_s::mem_tog10_hit, statistic_s::mem_wr_hit, memory_get_stat(), ssuppl_u::part, PROFILE, PROFILE_END, SSUPPL_TYPE_MEM, vsignal_s::suppl, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_excluded, TRUE, ssuppl_u::type, vsignal_s::value, vector_toggle_count(), and vector_s::width.

Referenced by exclude_set_toggle_exclude().

00186   { PROFILE(EXCLUDE_SIG_ASSIGN_AND_RECALC);
00187 
00188   /* First, set the exclude bit in the signal supplemental field */
00189   sig->suppl.part.excluded = excluded ? 1 : 0;
00190 
00191   /* If the signal is a memory, we need to update the memory coverage numbers */
00192   if( sig->suppl.part.type == SSUPPL_TYPE_MEM ) {
00193 
00194     unsigned int wr_hit       = 0;  /* Number of addressable elements written */
00195     unsigned int rd_hit       = 0;  /* Number of addressable elements read */
00196     unsigned int ae_total     = 0;  /* Number of addressable elements in this memory */
00197     unsigned int tog01_hit    = 0;  /* Number of bits toggling from 0->1 */
00198     unsigned int tog10_hit    = 0;  /* Number of bits toggling from 1->0 */
00199     unsigned int tog_total    = 0;  /* Total number of toggle bits */
00200     unsigned int mem_excluded = 0;  /* Number of excluded memory coverage points */
00201     bool         cov_found;
00202 
00203     /* Get the stats for the current memory */
00204     memory_get_stat( sig, &wr_hit, &rd_hit, &ae_total, &tog01_hit, &tog10_hit, &tog_total, &mem_excluded, &cov_found, TRUE );
00205 
00206     /* Recalculate the total and hit values for memory coverage */
00207     if( excluded ) {
00208       stat->mem_wr_hit    += (ae_total  - wr_hit);
00209       stat->mem_rd_hit    += (ae_total  - rd_hit);
00210       stat->mem_tog01_hit += (tog_total - tog01_hit);
00211       stat->mem_tog10_hit += (tog_total - tog10_hit);
00212       stat->mem_excluded  += ((ae_total * 2) + (tog_total * 2));
00213     } else {
00214       stat->mem_wr_hit    -= (ae_total  - wr_hit);
00215       stat->mem_rd_hit    -= (ae_total  - rd_hit);
00216       stat->mem_tog01_hit -= (tog_total - tog01_hit);
00217       stat->mem_tog10_hit -= (tog_total - tog10_hit);
00218       stat->mem_excluded  -= ((ae_total * 2) + (tog_total * 2));
00219     }
00220 
00221   /* Otherwise, the toggle coverage numbers should be adjusted */
00222   } else {
00223 
00224     unsigned int hit01 = 0;  /* Number of bits transitioning from 0 -> 1 */
00225     unsigned int hit10 = 0;  /* Number of bits transitioning from 1 -> 0 */
00226 
00227     /* Get the total hit01 and hit10 information */
00228     vector_toggle_count( sig->value, &hit01, &hit10 );
00229 
00230     /* Recalculate the total and hit values for toggle coverage */
00231     if( excluded ) {
00232       stat->tog01_hit    += (sig->value->width - hit01);
00233       stat->tog10_hit    += (sig->value->width - hit10);
00234       stat->tog_excluded += (sig->value->width * 2);
00235     } else {
00236       stat->tog01_hit    -= (sig->value->width - hit01);
00237       stat->tog10_hit    -= (sig->value->width - hit10);
00238       stat->tog_excluded -= (sig->value->width * 2);
00239     }
00240 
00241   }
00242 
00243   PROFILE_END;
00244 
00245 }

static bool exclude_toggle_from_id ( const char *  id  )  [static]
Returns:
Returns TRUE if the exclusion ID was found and the exclusion applied; otherwise, returns FALSE.

Finds the signal that matches the given exclusion ID and toggles its exclusion value, providing a reason for exclusion if it is excluding the coverage point and the -m option was specified on the command-line.

Parameters:
id String version of exclusion ID

References exclude_find_signal(), exclude_handle_exclude_reason(), exclude_print, exclude_print_exclusion(), exclude_prompt_for_msgs, ssuppl_u::excluded, NORMAL, ssuppl_u::part, print_output(), PROFILE, PROFILE_END, vsignal_s::suppl, user_msg, USER_MSG_LENGTH, and WARNING.

Referenced by exclude_apply_exclusions().

01542   { PROFILE(EXCLUDE_TOGGLE_FROM_ID);
01543 
01544   vsignal*   sig;          /* Pointer to found signal */
01545   func_unit* found_funit;  /* Pointer to functional unit containing sig */
01546   
01547   if( (sig = exclude_find_signal( atoi( id + 1 ), &found_funit )) != NULL ) {
01548   
01549     int          prev_excluded = sig->suppl.part.excluded;
01550     unsigned int rv;
01551 
01552     /* If the user wants to print the information do so */
01553     if( exclude_print ) {
01554 
01555       exclude_print_exclusion( id, prev_excluded, found_funit );
01556 
01557     /* Otherwise, perform the exclusion */
01558     } else {
01559 
01560       /* Output result */
01561       if( prev_excluded == 0 ) {
01562         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Excluding %s", id );
01563       } else {
01564         rv = snprintf( user_msg, USER_MSG_LENGTH, "  Including %s", id );
01565       }
01566       assert( rv < USER_MSG_LENGTH );
01567       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01568     
01569       /* Set the exclude bits in the expression supplemental field */
01570       sig->suppl.part.excluded = (prev_excluded ^ 1);
01571     
01572       /* If we are excluding and the -m option was specified, get an exclusion reason from the user */
01573       if( exclude_prompt_for_msgs || (prev_excluded == 1) ) { 
01574         exclude_handle_exclude_reason( prev_excluded, id, found_funit );
01575       }
01576 
01577     }
01578 
01579   } else {
01580 
01581     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find toggle signal associated with exclusion ID %s", id );
01582     assert( rv < USER_MSG_LENGTH );
01583     print_output( user_msg, WARNING, __FILE__, __LINE__ );
01584 
01585   }
01586 
01587   PROFILE_END;
01588 
01589   return( (sig != NULL) && !exclude_print );
01590 
01591 }

static void exclude_usage (  )  [static]

Outputs usage information to standard output for exclude command.

Referenced by exclude_parse_args().

00765                             {
00766 
00767   printf( "\n" );
00768   printf( "Usage:  covered exclude (-h | ([<options>] <exclusion_ids>+ <database_file>)\n" );
00769   printf( "\n" );
00770   printf( "   -h                           Displays this help information.\n" );
00771   printf( "\n" );
00772   printf( "   Options:\n" );
00773   printf( "      -f <filename>             Name of file containing additional arguments to parse.\n" );
00774   printf( "      -m                        Allows a message to be associated with an exclusion.\n" );
00775   printf( "                                  The message should describe the reason why a coverage point\n" );
00776   printf( "                                  is being excluded.  If a coverage point is being included for\n" );
00777   printf( "                                  coverage (i.e., it was previously excluded from coverage), no\n" );
00778   printf( "                                  message prompt will be specified.\n" );
00779   printf( "      -p                        Outputs the status of the exclusion ID and an exclusion message\n" );
00780   printf( "                                  if one exists.  No excluding will occur if this option is set.\n" );
00781   printf( "\n" );
00782 
00783 }


Variable Documentation

unsigned int curr_db

Index of current database in db_list array that is being handled.

Array of database pointers storing all currently loaded databases.

str_link* excl_ids_head = NULL [static]

Pointer to the head of the list of exclusion IDs to toggle exclusion/inclusion mode of.

str_link* excl_ids_tail = NULL [static]

Pointer to the tail of the list of exclusion IDs to toggle exclusion/inclusion mode of.

char* exclude_cdd = NULL [static]

Name of CDD file that will be read, modified with exclusion modifications and written back.

Referenced by command_exclude(), and exclude_parse_args().

bool exclude_print = FALSE [static]

If set to TRUE, prints the status and exclusion reason for the given exclusion ID. Set to TRUE via the -p option.

Referenced by exclude_assert_from_id(), exclude_expr_from_id(), exclude_fsm_from_id(), exclude_line_from_id(), exclude_memory_from_id(), exclude_parse_args(), and exclude_toggle_from_id().

bool exclude_prompt_for_msgs = FALSE [static]

If set to TRUE, causes a message prompt to be displayed for each coverage point that will be excluded from coverage.

Referenced by exclude_assert_from_id(), exclude_expr_from_id(), exclude_fsm_from_id(), exclude_line_from_id(), exclude_memory_from_id(), exclude_parse_args(), and exclude_toggle_from_id().

Informational line for the CDD file.

Specifies the value of the -er option.

Referenced by exclude_db_merge(), exclude_merge(), and merge_parse_args().

char user_msg[USER_MSG_LENGTH]

Holds some output that will be displayed via the print_output command. This is created globally so that memory does not need to be reallocated for each function that wishes to use it.

Generated on Sun Nov 21 00:55:37 2010 for Covered by  doxygen 1.6.3