示例#1
0
void DeepScanner::teardown()
{
	m_repeater.stop();

	m_report.setProgress(0.9);
	m_report.setSubtaskDescription(L"Calculating content and link groups...");
	m_master.DeepScanner_progress(m_report);

	calculateGroups();

	m_report.setProgress(1.0);
	m_report.setSubtaskDescription(L"Finished...");
	m_master.DeepScanner_progress(m_report);
}
示例#2
0
RCType
TraceGen::generate(J9TDFOptions *options, const char *currentTDFFile)
{
	RCType rc = RC_FAILED;
	unsigned int groupCount = 0;
	J9TDFGroup *groups = NULL;
	J9TDFFile *tdf = NULL;

	FileReader reader;
	TDFParser parser;

	Path *current = _visitedFile;
	char *realPath = NULL;

	/**
	 * User might specify multiple scan roots for example -root src,src/omr
	 * To avoid processing trace files multiple times keep the record of processed files.
	 * To handle relative paths omrfile_realpath is used to resolve canonicalized absolute pathname.
	 */
	if (NULL == (realPath = Port::omrfile_realpath(currentTDFFile))) {
		FileUtils::printError("Failed to resolve full path to file: %s\n", currentTDFFile);
		goto done;
	}
	while (NULL != current) {
		if (0 == strcmp(current->path, realPath)) {
			break;
		}
		current = current->next;
	}
	if (NULL == current) {
		Path *tmp = (Path *) Port::omrmem_calloc(1, sizeof(Path));
		tmp->path = realPath;
		tmp->next = _visitedFile;
		_visitedFile = tmp;
	} else if (options->debugOutput) {
		FileUtils::printError("File %s was already processed\n", realPath);
		goto done;
	}

	printf("Processing tdf file %s\n", currentTDFFile);

	rc = reader.init(currentTDFFile);
	if (RC_OK != rc) {
		FileUtils::printError("Failed to read from file: %s\n", currentTDFFile);
		goto done;
	}

	parser.init(&reader, options->treatWarningAsError);
	tdf = parser.parse();
	if (NULL == tdf) {
		rc = RC_FAILED;
		goto done;
	}

	tdf->fileName = strdup(currentTDFFile);
	if (NULL == tdf->fileName) {
		eprintf("Failed to allocate memory");
		rc = RC_FAILED;
		goto done;
	}

	groups = calculateGroups(tdf, &groupCount);
	if (NULL == groups) {
		FileUtils::printError("Failed to calculate tracepoint groups");
		rc = RC_FAILED;
		goto done;
	}

	TraceHeaderWriter hfw;
	DATFileWriter dfw;
	CFileWriter cfw;

	rc = hfw.writeOutputFiles(options, tdf);
	if (RC_OK != rc) {
		FileUtils::printError("Failed to generate header file for %s\n", currentTDFFile);
		goto done;
	}
	rc = dfw.writeOutputFiles(options, tdf);
	if (RC_OK != rc) {
		FileUtils::printError("Failed to generate DAT file for %s\n", currentTDFFile);
		goto done;
	}

	if (options->generateCFiles) {
		rc = cfw.writeOutputFiles(options, tdf, groups, groupCount);
		if (RC_OK != rc) {
			FileUtils::printError("Failed to generate C file for %s\n", currentTDFFile);
			goto done;
		}
	}

done:
	if (NULL != tdf) {
		Port::omrmem_free((void **)&tdf->fileName);
		Port::omrmem_free((void **)&tdf->header.datfilename);
		Port::omrmem_free((void **)&tdf->header.executable);
		Port::omrmem_free((void **)&tdf->header.submodules);

		J9TDFTracepoint *tp = tdf->tracepoints;
		while (NULL != tp) {
			J9TDFTracepoint *next = tp->nexttp;
			Port::omrmem_free((void **)&tp->name);
			if (NULL != tp->groups) {
				unsigned int groupIndex = 0;
				while (NULL != tp->groups[groupIndex]) {
					Port::omrmem_free((void **)&tp->groups[groupIndex]);
					groupIndex += 1;
				}
				tp->groups = NULL;
			}
			Port::omrmem_free((void **)&tp->format);
			Port::omrmem_free((void **)&tp->parameters);

			tp = next;
		}
	}

	if (NULL != groups) {
		freeGroups(groups);
		groups = NULL;
	}
	return rc;
}