void AnalysisDriver::printLeastProgressedTasks(const RangeSetTable &rsTable,
		const set<size_t> taskStates, const ReducedStateVector &redVector)
{
	if (mpiState.isRoot())
	{
		cout << "Number of states with LP-tasks: " << taskStates.size() << endl;

		set<size_t>::const_iterator it;
		for (it = taskStates.begin(); it != taskStates.end(); ++it) {
			State s = redVector.vec[*it];
			RangeSet rs = rsTable.getRangeOfTasks(*it);
			cout << "STATE " << *it << ", tasks: " << rs.toString() << endl;
		}

		// Print state names
		string name;
		cout << "States: " << endl;
		cout << "-------" << endl;
		for (size_t i=0; i < redVector.vec.size(); ++i) {
			State s = redVector.vec[i];
			factory->findAndGetName(name, s);
			cout << i << ": " << name << endl;
		}

		// Print location of tasks
		cout << "Task locations: " << endl;
		cout << "---------------" << endl;
		for (size_t i=0; i < redVector.vec.size(); ++i) {
			State s = redVector.vec[i];
			RangeSet r = rsTable.getRangeOfTasks(i);
			cout << i << ": " << r.toString() << endl;
		}
	}
}
void AnalysisDriver::dumpOutputForGUI(const DependencyMatrix &matrix,
		const ReducedStateVector &redVector,
		const RangeSetTable &rsTable)
{

	bool doNotDump = false;
        bool r = false;
        r = AUTConfig::getBoolParameter("AUT_DO_NOT_DUMP", doNotDump);
        if(doNotDump)
        {
             // to resolve problem in BGQ - in BGQ we can not execute shell command to resolve functionname and address
             return;

        }
	bool usedcallpath = AUTConfig::getBoolParameter("AUT_USE_CALL_PATH", usedcallpath);
	if(usedcallpath)
	{
		cout<< "Stack created using callpath, support for filename and line number will be provided later" << endl;
		return;
	}
#if STATE_TRACKER_DEBUG
	cout << "Writing dump file..." << endl;
#endif

	string fileData("");

	fileData += "#START_DEPENDENCY_GRAPH\n";
	fileData += matrix.toCSVFormat();
	fileData += "#END_DEPENDENCY_GRAPH\n";

	fileData += "#START_STATES\n";
	string name;
	for (size_t i=0; i < redVector.vec.size(); ++i) {
		State s = redVector.vec[i];
		factory->findAndGetName(name, s);

		// eliminate first '|'
		name.erase(0,1);

		// get state id
		char stateId[5];
		itoa((int)i, stateId);

		fileData += string(stateId) + string(":") + name + string("\n");
	}
	fileData += "#END_STATES\n";

	fileData += "#START_TASK_LOC\n";
	for (size_t i=0; i < redVector.vec.size(); ++i) {
		State s = redVector.vec[i];
		RangeSet r = rsTable.getRangeOfTasks(i);
                //cout << "Original state was: " << s.getId() << "\n";
		// get state id
		char stateId[5];
		itoa((int)i, stateId);

		// get range set
		string rSet(r.toString());
		rSet.erase(0,1);
		rSet.erase(rSet.length()-1, 1);
		
		// get number of tasks
		unsigned int n = r.getNumberOfTasks();
		char tasks[128];
		sprintf(tasks, "%d", n);

		fileData += string(stateId) + string(":") + rSet + string(":") + string(tasks) + string("\n");
	}
	fileData += "#END_TASK_LOC\n";
	fileData += "#START_SOURCE_CODE_LINES\n";
	name = "";
	for (size_t i=0; i < redVector.vec.size(); ++i) {
		State s = redVector.vec[i];
		factory->findAndGetName(name, s);
		// eliminate first '|'
		name.erase(0,1);
		vector<string> tokens;
		Tokenize(name, tokens, "|");
		string setOfLines("");
		for (size_t j=0; j < tokens.size(); ++j) {
			//cout << tokens[j] << endl;
			FileAndFunction f = Backtrace::findFileAndFunctionFromObject(tokens[j]);
			if(f.fileNameAndLine.empty())
			{
				continue;
			}
			string line = f.fileNameAndLine.substr(0, f.fileNameAndLine.size()-1);
			setOfLines += line + "|" + f.functionName;
			if (f.fromTool)
				setOfLines += "|*\n";
			else
				setOfLines += "\n";
		}

		// get state id
		char stateId[5];
		itoa((int)i, stateId);

		fileData += string(stateId) + string(",") + setOfLines;
	}
	fileData += "#END_SOURCE_CODE_LINES\n";

	fileData += "#START_STATE_TYPES\n";
        name = "";
        for (size_t i=0; i < redVector.vec.size(); ++i) {
                State s = redVector.vec[i];
                factory->findAndGetName(name, s);

                name.erase(0,1);
                vector<string> tokens;
                Tokenize(name, tokens, "|");
                bool compState = false;

                for (size_t j=0; j < tokens.size(); ++j) {
                        FileAndFunction f = Backtrace::findFileAndFunctionFromObject(tokens[j]);
			if(f.functionName.empty())
			{
			      continue;
			}

			if (f.functionName.find("transitionAfterMPICall") != string::npos) {
				compState = true;
				break;
			}
                }

                char stateId[5];
                itoa((int)i, stateId);

                fileData += string(stateId) + string(":");
		if (compState)
			fileData += "COMPUTATION_CODE\n";
		else
			fileData += "COMMUNICATION_CODE\n";

        }
        fileData += "#END_STATE_TYPES\n";

	string fileName = writeFile(fileData, "dump");
        cout << "Name of the output file: " << fileName << endl;

	//printf("Pointer of _r_debug.r_map: %p\n",_r_debug.r_map);
        //struct link_map *map = _r_debug.r_map;
        //while(map)
        //{
        //        printf("Name: '%s' l_addr: %lx l_ld: %lx\n", map->l_name, map->l_addr, map->l_ld);
        //        map = map->l_next;
        //}

}