Beispiel #1
0
struct processtop* add_proc(struct lttngtop *ctx, int tid, char *comm,
		unsigned long timestamp)
{
	struct processtop *newproc;

	/* if the PID already exists, we just rename the process */
	/* FIXME : need to integrate with clone/fork/exit to be accurate */
	newproc = find_process_tid(ctx, tid, comm);
	if (!newproc) {
		newproc = g_new0(struct processtop, 1);
		newproc->tid = tid;
		newproc->birth = timestamp;
		newproc->process_files_table = g_ptr_array_new();
		newproc->files_history = NULL;
		newproc->totalfileread = 0;
		newproc->totalfilewrite = 0;
		newproc->fileread = 0;
		newproc->filewrite = 0;
		newproc->syscall_info = NULL;
		newproc->threadparent = NULL;
		newproc->threads = g_ptr_array_new();
		newproc->perf = g_hash_table_new(g_str_hash, g_str_equal);
		g_ptr_array_add(ctx->process_table, newproc);

		ctx->nbnewthreads++;
		ctx->nbthreads++;
	}
Beispiel #2
0
void print_fields(struct bt_ctf_event *event, const char *procname,
		int pid)
{
	unsigned int cnt, i;
	const struct bt_definition *const * list;
	const struct bt_declaration *l;
	const struct bt_definition *scope;
	enum ctf_type_id type;
	const char *str;
	struct processtop *current_proc;
	struct files *current_file;
	int fd, fd_value = -1;

	scope = bt_ctf_get_top_level_scope(event, BT_EVENT_FIELDS);

	bt_ctf_get_field_list(event, scope, &list, &cnt);
	for (i = 0; i < cnt; i++) {
		if (i != 0)
			fprintf(output, ", ");
		fprintf(output, "%s = ", bt_ctf_field_name(list[i]));
		l = bt_ctf_get_decl_from_def(list[i]);
		if (strncmp(bt_ctf_field_name(list[i]), "fd", 2) == 0)
			fd = 1;
		else
			fd = 0;
		type = bt_ctf_field_type(l);
		if (type == CTF_TYPE_INTEGER) {
			if (bt_ctf_get_int_signedness(l) == 0) {
				fd_value = bt_ctf_get_uint64(list[i]);
				fprintf(output, "%" PRIu64, bt_ctf_get_uint64(list[i]));
			} else {
				fd_value = bt_ctf_get_int64(list[i]);
				fprintf(output, "%" PRId64, bt_ctf_get_int64(list[i]));
			}
		} else if (type == CTF_TYPE_STRING) {
			fprintf(output, "%s", bt_ctf_get_string(list[i]));
		} else if (type == CTF_TYPE_ARRAY) {
			str = bt_ctf_get_char_array(list[i]);
			if (!bt_ctf_field_get_error() && str)
				fprintf(output, "%s", str);
		}
		if (fd) {
			current_proc = find_process_tid(&lttngtop, pid, procname);
			if (!current_proc)
				continue;
			current_file = get_file(current_proc, fd_value);
			if (!current_file || !current_file->name)
				continue;
			fprintf(output, "<%s>", current_file->name);
		}
	}
}