コード例 #1
0
ファイル: traceset.c プロジェクト: adannis/lttv
LttvTraceset *lttv_traceset_new(void)
{
	LttvTraceset *ts;
	struct bt_iter_pos begin_pos;

	ts = g_new(LttvTraceset, 1);
	ts->filename = NULL;
	ts->common_path = NULL;
	ts->traces = g_ptr_array_new();
	ts->context = bt_context_create();
	ts->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);

	/*Initialize iterator to the beginning of the traces*/        
	begin_pos.type = BT_SEEK_BEGIN;
	ts->iter = bt_ctf_iter_create(ts->context, &begin_pos, NULL);

	ts->event_hooks = lttv_hooks_new();

	ts->state_trace_handle_index = g_ptr_array_new();
	ts->has_precomputed_states = FALSE;

	ts->time_span.start_time = ltt_time_zero;
        ts->time_span.end_time = ltt_time_zero;
	lttv_traceset_get_time_span_real(ts);
	return ts;
}
コード例 #2
0
ファイル: ctf.c プロジェクト: phausler/binutils
static void
ctf_open_dir (const char *dirname)
{
  struct bt_iter_pos begin_pos;
  struct bt_iter_pos *pos;
  unsigned int count, i;
  struct bt_ctf_event_decl * const *list;

  ctx = bt_context_create ();
  if (ctx == NULL)
    error (_("Unable to create bt_context"));
  handle_id = bt_context_add_trace (ctx, dirname, "ctf", NULL, NULL, NULL);
  if (handle_id < 0)
    {
      ctf_destroy ();
      error (_("Unable to use libbabeltrace on directory \"%s\""),
	     dirname);
    }

  begin_pos.type = BT_SEEK_BEGIN;
  ctf_iter = bt_ctf_iter_create (ctx, &begin_pos, NULL);
  if (ctf_iter == NULL)
    {
      ctf_destroy ();
      error (_("Unable to create bt_iterator"));
    }

  /* Look for the declaration of register block.  Get the length of
     array "contents" to set trace_regblock_size.  */

  bt_ctf_get_event_decl_list (handle_id, ctx, &list, &count);
  for (i = 0; i < count; i++)
    if (strcmp ("register", bt_ctf_get_decl_event_name (list[i])) == 0)
      {
	unsigned int j;
	const struct bt_ctf_field_decl * const *field_list;
	const struct bt_declaration *decl;

	bt_ctf_get_decl_fields (list[i], BT_EVENT_FIELDS, &field_list,
				&count);

	gdb_assert (count == 1);
	gdb_assert (0 == strcmp ("contents",
				 bt_ctf_get_decl_field_name (field_list[0])));
	decl = bt_ctf_get_decl_from_field_decl (field_list[0]);
	trace_regblock_size = bt_ctf_get_array_len (decl);

	break;
      }
}
コード例 #3
0
ファイル: common.c プロジェクト: cooljeanius/babeltrace
struct bt_context *create_context_with_path(const char *path)
{
	struct bt_context *ctx;
	int ret;

	ctx = bt_context_create();
	if (!ctx) {
		return NULL;
	}

	ret = bt_context_add_trace(ctx, path, "ctf", NULL, NULL, NULL);
	if (ret < 0) {
		bt_context_put(ctx);
		return NULL;
	}
	return ctx;
}
コード例 #4
0
int main(int argc, char **argv)
{
	int ret, partial_error = 0, open_success = 0;
	struct bt_format *fmt_write;
	struct bt_trace_descriptor *td_write;
	struct bt_context *ctx;
	int i;

	opt_input_paths = g_ptr_array_new();

	ret = parse_options(argc, argv);
	if (ret < 0) {
		fprintf(stderr, "Error parsing options.\n\n");
		usage(stderr);
		g_ptr_array_free(opt_input_paths, TRUE);
		exit(EXIT_FAILURE);
	} else if (ret > 0) {
		g_ptr_array_free(opt_input_paths, TRUE);
		exit(EXIT_SUCCESS);
	}
	printf_verbose("Verbose mode active.\n");
	printf_debug("Debug mode active.\n");

	if (opt_input_format)
		strlower(opt_input_format);
	if (opt_output_format)
		strlower(opt_output_format);

	printf_verbose("Converting from directory(ies):\n");
	for (i = 0; i < opt_input_paths->len; i++) {
		const char *ipath = g_ptr_array_index(opt_input_paths, i);
		printf_verbose("    %s\n", ipath);
	}
	printf_verbose("Converting from format: %s\n",
		opt_input_format ? : "ctf <default>");
	printf_verbose("Converting to target: %s\n",
		opt_output_path ? : "<stdout>");
	printf_verbose("Converting to format: %s\n",
		opt_output_format ? : "text <default>");

	if (!opt_input_format) {
		opt_input_format = strdup("ctf");
		if (!opt_input_format) {
			partial_error = 1;
			goto end;
		}
	}
	if (!opt_output_format) {
		opt_output_format = strdup("text");
		if (!opt_output_format) {
			partial_error = 1;
			goto end;
		}
	}
	fmt_read = bt_lookup_format(g_quark_from_static_string(opt_input_format));
	if (!fmt_read) {
		fprintf(stderr, "[error] Format \"%s\" is not supported.\n\n",
			opt_input_format);
		partial_error = 1;
		goto end;
	}
	fmt_write = bt_lookup_format(g_quark_from_static_string(opt_output_format));
	if (!fmt_write) {
		fprintf(stderr, "[error] format \"%s\" is not supported.\n\n",
			opt_output_format);
		partial_error = 1;
		goto end;
	}

	ctx = bt_context_create();
	if (!ctx) {
		goto error_td_read;
	}

	for (i = 0; i < opt_input_paths->len; i++) {
		const char *ipath = g_ptr_array_index(opt_input_paths, i);
		ret = bt_context_add_traces_recursive(ctx, ipath,
				opt_input_format, NULL);
		if (ret < 0) {
			fprintf(stderr, "[error] opening trace \"%s\" for reading.\n\n",
				ipath);
		} else if (ret > 0) {
			fprintf(stderr, "[warning] errors occurred when opening trace \"%s\" for reading, continuing anyway.\n\n",
				ipath);
			open_success = 1;	/* some traces were OK */
			partial_error = 1;
		} else {
			open_success = 1;	/* all traces were OK */
		}
	}
	if (!open_success) {
		fprintf(stderr, "[error] none of the specified trace paths could be opened.\n\n");
		goto error_td_read;
	}

	td_write = fmt_write->open_trace(opt_output_path, O_RDWR, NULL, NULL);
	if (!td_write) {
		fprintf(stderr, "Error opening trace \"%s\" for writing.\n\n",
			opt_output_path ? : "<none>");
		goto error_td_write;
	}