obfuscate.h File Reference

Contains functions for internal obfuscation. More...

Go to the source code of this file.

Defines

#define obf_sig(x)   (obf_mode ? obfuscate_name(x,'s') : x)
#define obf_funit(x)   (obf_mode ? obfuscate_name(x,'f') : x)
#define obf_file(x)   (obf_mode ? obfuscate_name(x,'v') : x)
#define obf_inst(x)   (obf_mode ? obfuscate_name(x,'i') : x)

Functions

void obfuscate_set_mode (bool value)
 Sets the global 'obf_mode' variable to the specified value.
char * obfuscate_name (const char *real_name, char prefix)
 Gets an obfuscated name for the given actual name.
void obfuscate_dealloc ()
 Deallocates all memory associated with obfuscation.

Variables

bool obf_mode

Detailed Description

Contains functions for internal obfuscation.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
9/16/2006

Define Documentation

#define obf_file (  )     (obf_mode ? obfuscate_name(x,'v') : x)
#define obf_funit (  )     (obf_mode ? obfuscate_name(x,'f') : x)
#define obf_inst (  )     (obf_mode ? obfuscate_name(x,'i') : x)

Used for obfuscating instance names. Improves performance when obfuscation mode is not turned on.

Referenced by combination_instance_summary(), covered_parse_instance(), db_add_instance(), db_add_override_param(), db_assign_symbol(), db_set_vcd_scope(), db_vcd_upscope(), gen_item_resolve(), gen_item_stringify(), and ovl_display_verbose().

#define obf_sig (  )     (obf_mode ? obfuscate_name(x,'s') : x)

Function Documentation

void obfuscate_dealloc (  ) 

Deallocates all memory associated with obfuscation.

References PROFILE, PROFILE_END, and tree_dealloc().

Referenced by main().

00109                          { PROFILE(OBFUSCATE_DEALLOC);
00110 
00111   tree_dealloc( obf_tree );
00112 
00113   PROFILE_END;
00114 
00115 }

char* obfuscate_name ( const char *  real_name,
char  prefix 
)

Gets an obfuscated name for the given actual name.

Returns:
Returns the obfuscated name for this object.

Looks up the given real name in the obfuscation tree. If it exists, simply return the given name; otherwise, create a new element in the tree to represent this new name.

Parameters:
real_name Name of actual object in design
prefix Character representing the prefix of the obfuscated name

References FALSE, free_safe, malloc_safe, obf_curr_id, PROFILE, PROFILE_END, tree_add(), tree_find(), and tnode_s::value.

00070   { PROFILE(OBFUSCATE_NAME);
00071 
00072   tnode*       obfnode;    /* Pointer to obfuscated tree node */
00073   char*        key;        /* Temporary name used for searching */
00074   char         tname[30];  /* Temporary name used for sizing obfuscation ID */
00075   unsigned int rv;         /* Return value from snprintf calls */
00076   unsigned int slen;       /* String length */
00077 
00078   /* Create temporary name */
00079   slen = strlen( real_name ) + 3;
00080   key = (char*)malloc_safe( slen );
00081   rv = snprintf( key, slen, "%s-%c", real_name, prefix );
00082   assert( rv < slen );
00083 
00084   /* If the name was not previously obfuscated, create a new obfuscated entry in the tree and return the new name */
00085   if( (obfnode = tree_find( key, obf_tree )) == NULL ) {
00086 
00087     /* Create obfuscated name */
00088     rv = snprintf( tname, 30, "%c%04d", prefix, obf_curr_id );
00089     assert( rv < 30 );
00090     obf_curr_id++;
00091 
00092     /* Add the obfuscated name to the tree and get the pointer to the new node */
00093     obfnode = tree_add( key, tname, FALSE, &obf_tree );
00094 
00095   }
00096 
00097   /* Deallocate key string */
00098   free_safe( key, (strlen( key ) + 1) );
00099 
00100   PROFILE_END;
00101 
00102   return( obfnode->value );
00103 
00104 }

void obfuscate_set_mode ( bool  value  ) 

Sets the global 'obf_mode' variable to the specified value.

Parameters:
value Boolean value to set obfuscation mode to

References obf_mode, PROFILE, and PROFILE_END.

Referenced by main().

00052   { PROFILE(OBFUSCATE_SET_MODE);
00053 
00054   obf_mode = value;
00055 
00056   PROFILE_END;
00057 
00058 }


Variable Documentation

Specifies obfuscation mode.

Referenced by obfuscate_set_mode().

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