model_server/subsystem/src/autosubsys.cxx
//
// This function finds all unreferenced code and places it on the
// provided array. We do a tree search down from main (specifically,
// what find_main() returns), mark those as alive, and deem everything
// else dead. 
This function finds all unreferenced code and places it on the
provided array. We do a tree search down from main (specifically,
what find_main() returns), mark those as alive, and deem everything
else dead.
This function finds all unreferenced code and places it on the provided array . We do a tree search down from main ( specifically what find_main () returns ) mark those as alive and deem everything else dead .
int allentity::getdead(symbolArr roots, objArr* dead, weight *w, int n) {
  Initialize(allentity::getdead);
  if (roots.size() == 0) {
    Log("Warning! No roots, hence no dormant code analysis performed.\n");
    ReturnValue(0);
  }
  FILE* dump_file = NULL;
  const char* dump_filename = OSapi_getenv("DIS_DORMANT_DUMP_FILE");
  if (dump_filename) {
     dump_file = OSapi_fopen(dump_filename, "w");
  }
  symbolPtr root;
  ForEachS(root, roots) {
     if (root.xrisnotnull()) {
	EntityPtr ent = item(root);
	if (ent) {
	   ent->setundead();
	   ent->find_live_code(w, n, 0, dump_file);
	}
     }
  }
  if (dump_file) {
     OSapi_fprintf(dump_file, "\nDORMANT:\n\n");
  }
  Obj *el;
  ForEach(el, *this) {
     if (EntityPtr(el)->isdead()) {
	dead->insert_last(el);
	if (dump_file) {
	   OSapi_fprintf(dump_file, "\t%s\n", EntityPtr(el)->get_name());
	}
     }
  }
  if (dump_file) {
     OSapi_fclose(dump_file);
  }
  ReturnValue(1);
}
int allentity :: getdead ( symbolArr roots , objArr * dead , weight * w , int n ) { Initialize ( allentity :: getdead ) ; if ( roots . size ( ) == 0 ) { Log ( " \n " ) ; ReturnValue ( 0 ) ; } FILE * dump_file = NULL ; const char * dump_filename = OSapi_getenv ( " " ) ; if ( dump_filename ) { dump_file = OSapi_fopen ( dump_filename , " " ) ; } symbolPtr root ; ForEachS ( root , roots ) { if ( root . xrisnotnull ( ) ) { EntityPtr ent = item ( root ) ; if ( ent ) { ent -> setundead ( ) ; ent -> find_live_code ( w , n , 0 , dump_file ) ; } } } if ( dump_file ) { OSapi_fprintf ( dump_file , " \n \n \n " ) ; } Obj * el ; ForEach ( el , * this ) { if ( EntityPtr ( el ) -> isdead ( ) ) { dead -> insert_last ( el ) ; if ( dump_file ) { OSapi_fprintf ( dump_file , " \t \n " , EntityPtr ( el ) -> get_name ( ) ) ; } } } if ( dump_file ) { OSapi_fclose ( dump_file ) ; } ReturnValue ( 1 ) ; }
This function finds all unreferenced code and places it on the
provided array.
This function finds all unreferenced code and places it on the provided array .
// First, we may need to transform the root (which is based on a // browser selection or a member of a batch-specified group) from // a reference xrefSymbol to its definition; otherwise, the item() // call may fail to find it, since the hashing was based on the // definition xrefSymbol.