예제 #1
0
/**
 * opd_open_files - open necessary files
 *
 * Open the device files and the log file,
 * and mmap() the hash map.
 */
static void opd_open_files(void)
{
	devfd = op_open_device("/dev/oprofile/buffer");
	if (devfd == -1) {
		if (errno == EINVAL)
			fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n"
				"parameters. Check /var/log/messages.");
		else
			perror("Failed to open profile device");
		exit(EXIT_FAILURE);
	}

	/* give output before re-opening stdout as the logfile */
	printf("Using log file %s\n", op_log_file);

	/* set up logfile */
	close(0);
	close(1);

	if (open("/dev/null", O_RDONLY) == -1) {
		perror("oprofiled: couldn't re-open stdin as /dev/null: ");
		exit(EXIT_FAILURE);
	}

	opd_open_logfile();
	opd_create_pipe();

	printf("oprofiled started %s", op_get_time());
	printf("kernel pointer size: %lu\n",
		(unsigned long)kernel_pointer_size);
	fflush(stdout);
}
예제 #2
0
static void opd_sigterm(void)
{
	opd_do_jitdumps();
	opd_print_stats();
	printf("oprofiled stopped %s", op_get_time());
	exit(EXIT_FAILURE);
}
예제 #3
0
static void opd_26_exit(void)
{
	opd_print_stats();
	printf("oprofiled stopped %s", op_get_time());

	free(sbuf);
	free(vmlinux);
	/* FIXME: free kernel images, sfiles etc. */
}
예제 #4
0
static void opd_24_exit(void)
{
	opd_print_24_stats();
	printf("oprofiled stopped %s", op_get_time());

	free(sbuf);
	free(nbuf);
	opd_clear_module_info();
	opd_proc_cleanup();
	
	opd_for_each_image(opd_delete_image);
}
예제 #5
0
void opd_print_stats(void)
{
	DIR * dir;
	struct dirent * dirent;

	printf("\n%s\n", op_get_time());
	printf("\n-- OProfile Statistics --\n");
	printf("Nr. sample dumps: %lu\n", opd_stats[OPD_DUMP_COUNT]);
	printf("Nr. non-backtrace samples: %lu\n", opd_stats[OPD_SAMPLES]);
	printf("Nr. kernel samples: %lu\n", opd_stats[OPD_KERNEL]);
	printf("Nr. lost samples (no kernel/user): %lu\n", opd_stats[OPD_NO_CTX]);
	printf("Nr. lost kernel samples: %lu\n", opd_stats[OPD_LOST_KERNEL]);
	printf("Nr. incomplete code structs: %lu\n", opd_stats[OPD_DANGLING_CODE]);
	printf("Nr. samples lost due to sample file open failure: %lu\n",
		opd_stats[OPD_LOST_SAMPLEFILE]);
	printf("Nr. samples lost due to no permanent mapping: %lu\n",
		opd_stats[OPD_LOST_NO_MAPPING]);
	print_if("Nr. event lost due to buffer overflow: %u\n",
	       "/dev/oprofile/stats", "event_lost_overflow", 1);
	print_if("Nr. samples lost due to no mapping: %u\n",
	       "/dev/oprofile/stats", "sample_lost_no_mapping", 1);
	print_if("Nr. backtraces skipped due to no file mapping: %u\n",
	       "/dev/oprofile/stats", "bt_lost_no_mapping", 0);
	print_if("Nr. samples lost due to no mm: %u\n",
	       "/dev/oprofile/stats", "sample_lost_no_mm", 1);

	opd_ext_print_stats();

	if (!(dir = opendir("/dev/oprofile/stats/")))
		goto out;
	while ((dirent = readdir(dir))) {
		int cpu_nr;
		char path[256];
		if (sscanf(dirent->d_name, "cpu%d", &cpu_nr) != 1)
			continue;
		snprintf(path, 256, "/dev/oprofile/stats/%s", dirent->d_name);

		printf("\n---- Statistics for cpu : %d\n", cpu_nr);
		print_if("Nr. samples lost cpu buffer overflow: %u\n",
		     path, "sample_lost_overflow", 1);
		print_if("Nr. samples lost task exit: %u\n",
		     path, "sample_lost_task_exit", 0);
		print_if("Nr. samples received: %u\n",
		     path, "sample_received", 1);
		print_if("Nr. backtrace aborted: %u\n", 
		     path, "backtrace_aborted", 0);
		print_if("Nr. samples lost invalid pc: %u\n", 
		     path, "sample_invalid_eip", 0);
	}
	closedir(dir);
out:
	fflush(stdout);
}
예제 #6
0
static void op_open_files(void)
{
	hashmapdevfd = op_open_device(op_hash_device);
	if (hashmapdevfd == -1) {
		perror("Failed to open hash map device");
		exit(EXIT_FAILURE);
	}

	notedevfd = op_open_device(op_note_device);
	if (notedevfd == -1) {
		if (errno == EINVAL)
			fprintf(stderr, "Failed to open note device. Possibly you have passed incorrect\n"
				"parameters. Check /var/log/messages.");
		else
			perror("Failed to open note device");
		exit(EXIT_FAILURE);
	}

	devfd = op_open_device(op_device);
	if (devfd == -1) {
		if (errno == EINVAL)
			fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n"
				"parameters. Check /var/log/messages.");
		else
			perror("Failed to open profile device");
		exit(EXIT_FAILURE);
	}

	opd_init_hash_map();

	
	printf("Using log file %s\n", op_log_file);

	
	close(0);
	close(1);

	if (open("/dev/null", O_RDONLY) == -1) {
		perror("oprofiled: couldn't re-open stdin as /dev/null: ");
		exit(EXIT_FAILURE);
	}

	opd_open_logfile();

	printf("oprofiled started %s", op_get_time());
	fflush(stdout);
}