Exemplo n.º 1
0
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;
      }
}
Exemplo n.º 2
0
Arquivo: print.c Projeto: adannis/lttv
int getFields(struct bt_ctf_event *ctf_event, struct bt_definition const *fields, GString* fieldsStr)
{
	enum ctf_type_id fieldType = bt_ctf_field_type(bt_ctf_get_decl_from_def(fields));
	int ret = 0, isSigned = -1, len = 0, i = 0;
	const struct bt_definition *index_def; 
	switch (fieldType) {
	case CTF_TYPE_INTEGER:
		isSigned = bt_ctf_get_int_signedness(bt_ctf_get_decl_from_def(fields));
		if (isSigned == 1) {
			g_string_append_printf(fieldsStr, "%lu", bt_ctf_get_int64(fields));
		}
		else if (isSigned == 0) {
			g_string_append_printf(fieldsStr, "%" PRIu64 , bt_ctf_get_uint64(fields));
		}
		break;
	case CTF_TYPE_STRING:
		g_string_append_printf(fieldsStr, "%s", bt_ctf_get_string(fields));
		break;

	case CTF_TYPE_ARRAY:
		g_string_append_printf(fieldsStr, "[ ");
		len = bt_ctf_get_array_len(bt_ctf_get_decl_from_def(fields));
		if ((index_def = bt_ctf_get_index(ctf_event, fields, i))) {
			for (i = 0; i < len; i++) {
				if (i > 0) {
					g_string_append_printf(fieldsStr, ", ");
				}
				//bt_ctf_field_type( bt_ctf_get_index(ctf_event, fields, i));
				g_string_append_printf(fieldsStr, " ");
				g_string_append_printf(fieldsStr, "[%d] = ",i);
				getFields(ctf_event, bt_ctf_get_index(ctf_event, fields, i), fieldsStr);
			}
		}
		else {
			g_string_append_printf(fieldsStr, "%s", bt_ctf_get_char_array(fields));
		}
		g_string_append_printf(fieldsStr, " ]");

		break;
	case CTF_TYPE_UNKNOWN:
		g_string_append_printf(fieldsStr, "TYPE UNKNOWN");
	default:
		g_string_append_printf(fieldsStr, "TYPE UNIMP %i",fieldType );
		break;
	}
	return ret;
}