// This runs after the target program exits void fjalar_finish(void) { // If fjalar_smart_disambig is on, then // we must create the .disambig file at the very end after // Fjalar has run though the entire program so that it can // determine whether each pointer variable has only referenced // one element or multiple elements throughout this particular execution if (disambig_writing && fjalar_smart_disambig) { generateDisambigFile(); printf("\nDone generating .disambig file %s\n", fjalar_disambig_filename); fclose(disambig_fp); disambig_fp = 0; } // Make sure to execute this last! fjalar_tool_finish(); }
// Call this AFTER initializeAllFjalarData() so that all relevant data // structures are already initialized. // Try to open a .disambig file for reading, but if it doesn't exist, // create a new file by writing to it. // Pre: fjalar_disambig_filename is non-null void handleDisambigFile() { tl_assert(fjalar_disambig_filename); if ((disambig_fp = fopen(fjalar_disambig_filename, "r"))) { FJALAR_DPRINTF("\n\nREADING %s\n", fjalar_disambig_filename); disambig_writing = False; VG_(printf)( "\nBegin processing disambiguation file \"%s\" ...\n", fjalar_disambig_filename); processDisambigFile(); VG_(printf)( "Done processing disambiguation file \"%s\"\n", fjalar_disambig_filename); } else if ((disambig_fp = fopen(fjalar_disambig_filename, "wx"))) { FJALAR_DPRINTF("\n\nWRITING %s\n", fjalar_disambig_filename); disambig_writing = True; // If we are writing a .disambig file, then we always want to // visit all the struct variables so that we can generate // .disambig entries for them: fjalar_output_struct_vars = True; // If fjalar_smart_disambig is on, then we need to wait until the // END of program execution before printing out the .disambig // information (see fjalar_finish()): if (!fjalar_smart_disambig) { generateDisambigFile(); VG_(printf)("\nDone generating .disambig file %s\n", fjalar_disambig_filename); fclose(disambig_fp); disambig_fp = 0; VG_(exit)(0); } } }