コード例 #1
0
ファイル: misc_wrapper.c プロジェクト: gllort/extrae
void Extrae_memusage_Wrapper (void)
{
#if defined(HAVE_MALLINFO)
        static int mallinfo_running = FALSE;

        if (TRACING_MEMUSAGE)
        {
                if (mallinfo_running)
                        return;

                mallinfo_running = TRUE;

                struct mallinfo current_mi = mallinfo();
                int inuse = current_mi.arena + current_mi.hblkhd - current_mi.fordblks;

                TRACE_MISCEVENT(LAST_READ_TIME, MEMUSAGE_EV, MEMUSAGE_ARENA_EV,    current_mi.arena);
                TRACE_MISCEVENT(LAST_READ_TIME, MEMUSAGE_EV, MEMUSAGE_HBLKHD_EV,   current_mi.hblkhd);
                TRACE_MISCEVENT(LAST_READ_TIME, MEMUSAGE_EV, MEMUSAGE_UORDBLKS_EV, current_mi.uordblks);
                TRACE_MISCEVENT(LAST_READ_TIME, MEMUSAGE_EV, MEMUSAGE_FORDBLKS_EV, current_mi.fordblks);
                TRACE_MISCEVENT(LAST_READ_TIME, MEMUSAGE_EV, MEMUSAGE_INUSE_EV,    inuse);
                if (inuse < 0)
                {
                        fprintf(stderr, "WARNING: Negative value for MEMUSAGE_INUSE_EV detected (inuse=%d+%d-%d=%d). Please submit a bug report.\n",
                                current_mi.arena,
                                current_mi.hblkhd,
                                current_mi.fordblks,
                                inuse);
                }
                mallinfo_running = FALSE;
        }
#endif
}
コード例 #2
0
ファイル: malloc_probe.c プロジェクト: gllort/extrae
void Probe_Realloc_Entry (void *p, size_t s)
{
	if (mpitrace_on && trace_malloc)
	{
		/* Split p & s in two events. There's no need to read counters for the
		   second event */
		TRACE_MISCEVENTANDCOUNTERS(LAST_READ_TIME, REALLOC_EV, EVT_BEGIN, (UINT64) p);
		TRACE_MISCEVENT(LAST_READ_TIME, REALLOC_EV, EVT_BEGIN+1, s);
	}
}
コード例 #3
0
void Extrae_Probe_system_Entry (char *newbinary)
{
	Backend_Enter_Instrumentation (2);
	Probe_system_Entry();

	/* Dude!, grab the binary we're about to execute and post it into the .sym file */
	Extrae_define_event_type_Wrapper (SYSTEM_BIN_EV, "system() binary name", 1,
		&last_system_id, &newbinary);
	TRACE_MISCEVENT(LAST_READ_TIME, USER_EV, SYSTEM_BIN_EV, last_system_id);

	last_system_id++;
}
コード例 #4
0
ファイル: misc_wrapper.c プロジェクト: gllort/extrae
void Extrae_register_codelocation_type_Wrapper (extrae_type_t type_function,
	extrae_type_t type_file_line, const char *description_function,
	const char *description_file_line)
{
	TRACE_MISCEVENT(LAST_READ_TIME,REGISTER_CODELOCATION_TYPE_EV, type_function,
		type_file_line);

	Extrae_AddTypeValuesEntryToLocalSYM ('C', type_function, (char*)description_function,
		(char)0,  0, NULL, NULL);
	Extrae_AddTypeValuesEntryToLocalSYM ('c', type_file_line, (char*)description_file_line,
		(char)0, 0, NULL, NULL);
}
コード例 #5
0
void Extrae_Probe_exec_v_Entry (char *newbinary, char *const argv[])
{
	#define BUFFER_SIZE 1024
	char buffer[BUFFER_SIZE];
	char *pbuffer[1] = { buffer };
	int i = 0;
	int remaining = BUFFER_SIZE -1;
	int position = 0;

	UNREFERENCED_PARAMETER(newbinary);

	Backend_Enter_Instrumentation (2);
	Probe_exec_Entry();

	for (i = 0; i < BUFFER_SIZE; i++)
		buffer[i] = 0;

	i = 0;
	while (argv[i] != NULL && remaining > 0)
	{
		int length = strlen (argv[i]);

		if (length < remaining)
		{
			strncpy (&buffer[position], argv[i], length);
			buffer[position+length] = ' ';
			position += length + 1;
			remaining -= length + 1;
		}
		else
		{
			strncpy (&buffer[position], argv[i], remaining);
			remaining = 0;
		}
		i++;
	}

	extrae_value_t v = getpid();

	/* Dude!, we are changing the process image! Dump all the information
	   generated into the tracefile */
	pbuffer[0] = buffer;
	Extrae_define_event_type_Wrapper (EXEC_BIN_EV, "exec() binary name", 1, &v, pbuffer);
	TRACE_MISCEVENT(LAST_READ_TIME, USER_EV, EXEC_BIN_EV, getpid());

	Extrae_fini_Wrapper();

	#undef BUFFER_SIZE
}
コード例 #6
0
void Extrae_Probe_exec_l_Entry (char *newbinary)
{
	printf ("Extrae_Probe_exec_l_Entry, Extrae_Probe_exec_l_Entry, Extrae_Probe_exec_l_Entry\n");

	Backend_Enter_Instrumentation (2);
	Probe_exec_Entry();

	extrae_value_t v = getpid();

	/* Dude!, we are changing the process image! Dump all the information
	   generated into the tracefile */
	Extrae_define_event_type_Wrapper (EXEC_BIN_EV, "exec() binary name", 1, &v, &newbinary);
	TRACE_MISCEVENT(LAST_READ_TIME, USER_EV, EXEC_BIN_EV, getpid());

	Extrae_fini_Wrapper();
}
コード例 #7
0
ファイル: misc_wrapper.c プロジェクト: gllort/extrae
void Extrae_getrusage_set_to_0_Wrapper (UINT64 time)
{
	if (TRACING_RUSAGE)
	{
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_UTIME_EV,  0);
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_STIME_EV,  0);
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_MINFLT_EV, 0);
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_MAJFLT_EV, 0);
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_NVCSW_EV,  0);
		TRACE_MISCEVENT(time, RUSAGE_EV, RUSAGE_NIVCSW_EV, 0);
	}
}
コード例 #8
0
ファイル: misc_wrapper.c プロジェクト: gllort/extrae
void Extrae_getrusage_Wrapper (void)
{
	int err;
	static int init_pending = TRUE;
	static int getrusage_running = FALSE;
	static struct rusage last_usage;

	if (TRACING_RUSAGE)
	{
		struct rusage current_usage;
		struct rusage delta_usage;
	
		if (getrusage_running)
			return;

		getrusage_running = TRUE;

		err = getrusage(RUSAGE_SELF, &current_usage);

		if (!init_pending) 
		{
			delta_usage.ru_utime.tv_sec = current_usage.ru_utime.tv_sec - last_usage.ru_utime.tv_sec;
			delta_usage.ru_utime.tv_usec = current_usage.ru_utime.tv_usec - last_usage.ru_utime.tv_usec;
			delta_usage.ru_stime.tv_sec = current_usage.ru_stime.tv_sec - last_usage.ru_stime.tv_sec;
			delta_usage.ru_stime.tv_usec = current_usage.ru_stime.tv_usec - last_usage.ru_stime.tv_usec;
			delta_usage.ru_minflt = current_usage.ru_minflt - last_usage.ru_minflt;
			delta_usage.ru_majflt = current_usage.ru_majflt - last_usage.ru_majflt;
			delta_usage.ru_nvcsw = current_usage.ru_nvcsw - last_usage.ru_nvcsw;
			delta_usage.ru_nivcsw = current_usage.ru_nivcsw - last_usage.ru_nivcsw;
		}
		else
			delta_usage = current_usage;

		if (!err) 
		{
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_UTIME_EV,  delta_usage.ru_utime.tv_sec * 1000000 + delta_usage.ru_utime.tv_usec);
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_STIME_EV,  delta_usage.ru_stime.tv_sec * 1000000 + delta_usage.ru_stime.tv_usec);
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_MINFLT_EV, delta_usage.ru_minflt);
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_MAJFLT_EV, delta_usage.ru_majflt);
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_NVCSW_EV,  delta_usage.ru_nvcsw);
			TRACE_MISCEVENT(LAST_READ_TIME, RUSAGE_EV, RUSAGE_NIVCSW_EV, delta_usage.ru_nivcsw);
		}

		last_usage = current_usage;
		init_pending = FALSE;
		getrusage_running = FALSE;
	}
}