Esempio n. 1
0
struct bt_value *bt_value_string_create_init(const char *val)
{
	struct bt_value_string *string_obj = NULL;

	if (!val) {
		BT_LOGW_STR("Invalid parameter: value is NULL.");
		goto end;
	}

	BT_LOGD("Creating string value object: val-len=%zu", strlen(val));
	string_obj = g_new0(struct bt_value_string, 1);
	if (!string_obj) {
		BT_LOGE_STR("Failed to allocate one string object.");
		goto end;
	}

	string_obj->base = bt_value_create_base(BT_VALUE_TYPE_STRING);
	string_obj->gstr = g_string_new(val);
	if (!string_obj->gstr) {
		BT_LOGE_STR("Failed to allocate a GString.");
		g_free(string_obj);
		string_obj = NULL;
		goto end;
	}

	BT_LOGD("Created string value object: addr=%p",
		string_obj);

end:
	return (void *) string_obj;
}
Esempio n. 2
0
static inline
struct bt_value *bt_value_integer_create_init(enum bt_value_type type,
		uint64_t uval)
{
	struct bt_value_integer *integer_obj;

	BT_ASSERT(type == BT_VALUE_TYPE_UNSIGNED_INTEGER ||
		type == BT_VALUE_TYPE_SIGNED_INTEGER);

	if (type == BT_VALUE_TYPE_UNSIGNED_INTEGER) {
		BT_LOGD("Creating unsigned integer value object: val=%" PRIu64,
			uval);
	} else {
		BT_LOGD("Creating signed integer value object: val=%" PRId64,
			(int64_t) uval);
	}

	integer_obj = g_new0(struct bt_value_integer, 1);
	if (!integer_obj) {
		BT_LOGE_STR("Failed to allocate one integer value object.");
		goto end;
	}

	integer_obj->base = bt_value_create_base(type);
	integer_obj->value.u = uval;
	BT_LOGD("Created %ssigned integer value object: addr=%p",
		type == BT_VALUE_TYPE_UNSIGNED_INTEGER ? "un" : "",
		integer_obj);

end:
	return (void *) integer_obj;
}
Esempio n. 3
0
enum bt_value_status bt_value_map_extend(
		const struct bt_value *base_map_obj,
		const struct bt_value *extension_obj,
		struct bt_value **extended_map_obj)
{
	struct extend_map_element_data extend_data = {
		.extended_obj = NULL,
		.status = BT_VALUE_STATUS_OK,
	};

	BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
	BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
	BT_ASSERT_PRE_NON_NULL(extended_map_obj,
		"Extended value object (output)");
	BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_VALUE_TYPE_MAP);
	BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_VALUE_TYPE_MAP);
	BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
		base_map_obj, extension_obj);
	*extended_map_obj = NULL;

	/* Create copy of base map object to start with */
	extend_data.status = bt_value_copy(base_map_obj, extended_map_obj);
	if (extend_data.status) {
		BT_LOGE("Cannot copy base value: base-value-addr=%p",
			base_map_obj);
		goto error;
	}

	BT_ASSERT(extended_map_obj);

	/*
	 * For each key in the extension map object, replace this key
	 * in the copied map object.
	 */
	extend_data.extended_obj = *extended_map_obj;

	if (bt_value_map_foreach_entry_const(extension_obj, extend_map_element,
			&extend_data)) {
		BT_LOGE("Cannot iterate on the extension object's elements: "
			"extension-value-addr=%p", extension_obj);
		goto error;
	}

	if (extend_data.status) {
		BT_LOGE("Failed to successfully iterate on the extension object's elements: "
			"extension-value-addr=%p", extension_obj);
		goto error;
	}

	BT_LOGD("Extended map value: extended-value-addr=%p",
		*extended_map_obj);
	goto end;

error:
	BT_OBJECT_PUT_REF_AND_RESET(*extended_map_obj);
	*extended_map_obj = NULL;

end:
	return extend_data.status;
}
Esempio n. 4
0
static
struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
{
	int i;
	int ret;
	struct bt_value *copy_obj;
	struct bt_value_array *typed_array_obj;

	BT_LOGD("Copying array value: addr=%p", array_obj);
	typed_array_obj = BT_VALUE_TO_ARRAY(array_obj);
	copy_obj = bt_value_array_create();
	if (!copy_obj) {
		BT_LOGE_STR("Cannot create empty array value.");
		goto end;
	}

	for (i = 0; i < typed_array_obj->garray->len; ++i) {
		struct bt_value *element_obj_copy = NULL;
		const struct bt_value *element_obj =
			bt_value_array_borrow_element_by_index_const(
				array_obj, i);

		BT_ASSERT(element_obj);
		BT_LOGD("Copying array value's element: element-addr=%p, "
			"index=%d", element_obj, i);
		ret = bt_value_copy(element_obj, &element_obj_copy);
		if (ret) {
			BT_LOGE("Cannot copy array value's element: "
				"array-addr=%p, index=%d",
				array_obj, i);
			BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
			goto end;
		}

		BT_ASSERT(element_obj_copy);
		ret = bt_value_array_append_element(copy_obj,
			(void *) element_obj_copy);
		BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
		if (ret) {
			BT_LOGE("Cannot append to array value: addr=%p",
				array_obj);
			BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
			goto end;
		}
	}

	BT_LOGD("Copied array value: original-addr=%p, copy-addr=%p",
		array_obj, copy_obj);

end:
	return copy_obj;
}
Esempio n. 5
0
static
struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
{
	int ret;
	GHashTableIter iter;
	gpointer key, element_obj;
	struct bt_value *copy_obj;
	struct bt_value *element_obj_copy = NULL;
	struct bt_value_map *typed_map_obj;

	BT_LOGD("Copying map value: addr=%p", map_obj);
	typed_map_obj = BT_VALUE_TO_MAP(map_obj);
	copy_obj = bt_value_map_create();
	if (!copy_obj) {
		goto end;
	}

	g_hash_table_iter_init(&iter, typed_map_obj->ght);

	while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
		const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));

		BT_ASSERT(key_str);
		BT_LOGD("Copying map value's element: element-addr=%p, "
			"key=\"%s\"", element_obj, key_str);
		ret = bt_value_copy(element_obj, &element_obj_copy);
		if (ret) {
			BT_LOGE("Cannot copy map value's element: "
				"map-addr=%p, key=\"%s\"",
				map_obj, key_str);
			BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
			goto end;
		}

		BT_ASSERT(element_obj_copy);
		ret = bt_value_map_insert_entry(copy_obj, key_str,
			(void *) element_obj_copy);
		BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
		if (ret) {
			BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
				map_obj, key_str);
			BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
			goto end;
		}
	}

	BT_LOGD("Copied map value: addr=%p", map_obj);

end:
	return copy_obj;
}
Esempio n. 6
0
void bt_event_destroy(struct bt_object *obj)
{
	struct bt_event *event;

	event = container_of(obj, struct bt_event, base);
	BT_LOGD("Destroying event: addr=%p, "
		"event-class-name=\"%s\", event-class-id=%" PRId64,
		event, bt_event_class_get_name(event->event_class),
		bt_event_class_get_id(event->event_class));

	if (!event->base.parent) {
		/*
		 * Event was keeping a reference to its class since it shared no
		 * common ancestor with it to guarantee they would both have the
		 * same lifetime.
		 */
		bt_put(event->event_class);
	}
	g_hash_table_destroy(event->clock_values);
	BT_LOGD_STR("Putting event's header field.");
	bt_put(event->event_header);
	BT_LOGD_STR("Putting event's stream event context field.");
	bt_put(event->stream_event_context);
	BT_LOGD_STR("Putting event's context field.");
	bt_put(event->context_payload);
	BT_LOGD_STR("Putting event's payload field.");
	bt_put(event->fields_payload);
	BT_LOGD_STR("Putting event's packet.");
	bt_put(event->packet);
	g_free(event);
}
Esempio n. 7
0
static
struct stack *stack_new(void)
{
	struct stack *stack = NULL;

	stack = g_new0(struct stack, 1);
	if (!stack) {
		BT_LOGE_STR("Failed to allocate one stack.");
		goto error;
	}

	stack->entries = g_ptr_array_new_with_free_func(stack_entry_free_func);
	if (!stack->entries) {
		BT_LOGE_STR("Failed to allocate a GPtrArray.");
		goto error;
	}

	BT_LOGD("Created stack: addr=%p", stack);
	return stack;

error:
	g_free(stack);

	return NULL;
}
Esempio n. 8
0
struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name)
{
	struct bt_ctf_event_class *ctf_event_class = NULL;
	int ret;

	if (!name) {
		BT_LOGW_STR("Invalid parameter: name is NULL.");
		goto error;
	}

	BT_LOGD("Creating event class object: name=\"%s\"",
		name);
	ctf_event_class = g_new0(struct bt_ctf_event_class, 1);
	if (!ctf_event_class) {
		BT_LOGE_STR("Failed to allocate one event class.");
		goto error;
	}

	ret = bt_ctf_event_class_common_initialize(BT_CTF_TO_COMMON(ctf_event_class),
		name, bt_ctf_event_class_destroy,
		(bt_ctf_field_type_structure_create_func)
			bt_ctf_field_type_structure_create);
	if (ret) {
		goto error;
	}

	goto end;

error:
	bt_ctf_object_put_ref(ctf_event_class);

end:
	return ctf_event_class;
}
Esempio n. 9
0
BT_HIDDEN
struct bt_value *bt_attributes_create(void)
{
	struct bt_value *attr_obj;

	/*
	 * Attributes: array value object of array value objects, each one
	 * containing two entries: a string value object (attributes
	 * field name), and a value object (attributes field value).
	 *
	 * Example (JSON representation):
	 *
	 *     [
	 *         ["hostname", "eeppdesk"],
	 *         ["sysname", "Linux"],
	 *         ["tracer_major", 2],
	 *         ["tracer_minor", 5]
	 *     ]
	 */
	BT_LOGD_STR("Creating attributes object.");
	attr_obj = bt_value_array_create();
	if (!attr_obj) {
		BT_LOGE_STR("Failed to create array value.");
	} else {
		BT_LOGD("Created attributes object: addr=%p",
			attr_obj);
	}

	return attr_obj;
}
Esempio n. 10
0
struct bt_btr *bt_btr_create(struct bt_btr_cbs cbs, void *data)
{
	struct bt_btr *btr;

	BT_LOGD_STR("Creating binary type reader (BTR).");
	btr = g_new0(struct bt_btr, 1);
	if (!btr) {
		BT_LOGE_STR("Failed to allocate one binary type reader.");
		goto end;
	}

	btr->stack = stack_new();
	if (!btr->stack) {
		BT_LOGE_STR("Cannot create BTR's stack.");
		bt_btr_destroy(btr);
		btr = NULL;
		goto end;
	}

	btr->state = BTR_STATE_NEXT_FIELD;
	btr->user.cbs = cbs;
	btr->user.data = data;
	BT_LOGD("Created BTR: addr=%p", btr);

end:
	return btr;
}
Esempio n. 11
0
BT_HIDDEN
struct bt_value *bt_attributes_get_field_value_by_name(
		struct bt_value *attr_obj, const char *name)
{
	struct bt_value *value_obj = NULL;
	struct bt_value *attr_field_obj = NULL;

	if (!attr_obj || !name) {
		BT_LOGW("Invalid parameter: attributes object or name is NULL: "
			"value-addr=%p, name-addr=%p", attr_obj, name);
		goto end;
	}

	attr_field_obj = bt_attributes_get_field_by_name(attr_obj, name);
	if (!attr_field_obj) {
		BT_LOGD("Cannot find attributes object's field by name: "
			"value-addr=%p, name=\"%s\"", attr_obj, name);
		goto end;
	}

	value_obj = bt_value_array_get(attr_field_obj,
		BT_ATTR_VALUE_INDEX);
	if (!value_obj) {
		BT_LOGE("Cannot get attribute array value's element by index: "
			"value-addr=%p, index=%" PRIu64, attr_field_obj,
			(uint64_t) BT_ATTR_VALUE_INDEX);
	}

end:
	BT_PUT(attr_field_obj);

	return value_obj;
}
Esempio n. 12
0
struct bt_value *bt_value_map_create(void)
{
	struct bt_value_map *map_obj;

	BT_LOGD_STR("Creating empty map value object.");
	map_obj = g_new0(struct bt_value_map, 1);
	if (!map_obj) {
		BT_LOGE_STR("Failed to allocate one map object.");
		goto end;
	}

	map_obj->base = bt_value_create_base(BT_VALUE_TYPE_MAP);
	map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal,
		NULL, (GDestroyNotify) bt_object_put_ref);
	if (!map_obj->ght) {
		BT_LOGE_STR("Failed to allocate a GHashTable.");
		g_free(map_obj);
		map_obj = NULL;
		goto end;
	}

	BT_LOGD("Created map value object: addr=%p",
		map_obj);

end:
	return (void *) map_obj;
}
Esempio n. 13
0
struct bt_value *bt_value_array_create(void)
{
	struct bt_value_array *array_obj;

	BT_LOGD_STR("Creating empty array value object.");
	array_obj = g_new0(struct bt_value_array, 1);
	if (!array_obj) {
		BT_LOGE_STR("Failed to allocate one array object.");
		goto end;
	}

	array_obj->base = bt_value_create_base(BT_VALUE_TYPE_ARRAY);
	array_obj->garray = bt_g_ptr_array_new_full(0,
		(GDestroyNotify) bt_object_put_ref);
	if (!array_obj->garray) {
		BT_LOGE_STR("Failed to allocate a GPtrArray.");
		g_free(array_obj);
		array_obj = NULL;
		goto end;
	}

	BT_LOGD("Created array value object: addr=%p",
		array_obj);

end:
	return (void *) array_obj;
}
Esempio n. 14
0
void
BluetoothRilListener::ServiceChanged(uint32_t aClientId, bool aRegistered)
{
  // Stop listening
  ListenMobileConnAndIccInfo(false);

  /**
   * aRegistered:
   * - TRUE:  service becomes registered. We were listening to all clients
   *          and one of them becomes available. Select it to listen.
   * - FALSE: service becomes un-registered. The client we were listening
   *          becomes unavailable. Select another registered one to listen.
   */
  if (aRegistered) {
    mClientId = aClientId;
  } else {
    SelectClient();
  }

  // Restart listening
  ListenMobileConnAndIccInfo(true);

  BT_LOGD("%d client %d. new mClientId %d", aRegistered, aClientId,
          (mClientId < mMobileConnListeners.Length()) ? mClientId : -1);
}
Esempio n. 15
0
BT_HIDDEN
int bin_info_lookup_function_name(struct bin_info *bin,
		uint64_t addr, char **func_name)
{
	int ret = 0;
	char *_func_name = NULL;

	if (!bin || !func_name) {
		goto error;
	}

	/* Set DWARF info if it hasn't been accessed yet. */
	if (!bin->dwarf_info && !bin->is_elf_only) {
		ret = bin_info_set_dwarf_info(bin);
		if (ret) {
			BT_LOGD_STR("Failed to set bin dwarf info, falling back to ELF lookup.");
			/* Failed to set DWARF info, fallback to ELF. */
			bin->is_elf_only = true;
		}
	}

	if (!bin_info_has_address(bin, addr)) {
		goto error;
	}

	/*
	 * Addresses in ELF and DWARF are relative to base address for
	 * PIC, so make the address argument relative too if needed.
	 */
	if (bin->is_pic) {
		addr -= bin->low_addr;
	}

	if (bin->is_elf_only) {
		ret = bin_info_lookup_elf_function_name(bin, addr, &_func_name);
		BT_LOGD("Failed to lookup function name (ELF): ret=%d", ret);
	} else {
		ret = bin_info_lookup_dwarf_function_name(bin, addr, &_func_name);
		BT_LOGD("Failed to lookup function name (DWARF): ret=%d", ret);
	}

	*func_name = _func_name;
	return 0;

error:
	return -1;
}
Esempio n. 16
0
BT_HIDDEN
struct bt_port *bt_port_create(struct bt_component *parent_component,
		enum bt_port_type type, const char *name, void *user_data)
{
	struct bt_port *port = NULL;

	assert(name);
	assert(parent_component);
	assert(type == BT_PORT_TYPE_INPUT || type == BT_PORT_TYPE_OUTPUT);

	if (strlen(name) == 0) {
		BT_LOGW_STR("Invalid parameter: name is an empty string.");
		goto end;
	}

	port = g_new0(struct bt_port, 1);
	if (!port) {
		BT_LOGE_STR("Failed to allocate one port.");
		goto end;
	}

	BT_LOGD("Creating port for component: "
		"comp-addr=%p, comp-name=\"%s\", port-type=%s, "
		"port-name=\"%s\"",
		parent_component, bt_component_get_name(parent_component),
		bt_port_type_string(type), name);

	bt_object_init(port, bt_port_destroy);
	port->name = g_string_new(name);
	if (!port->name) {
		BT_LOGE_STR("Failed to allocate one GString.");
		BT_PUT(port);
		goto end;
	}

	port->type = type;
	port->user_data = user_data;
	bt_object_set_parent(port, &parent_component->base);
	BT_LOGD("Created port for component: "
		"comp-addr=%p, comp-name=\"%s\", port-type=%s, "
		"port-name=\"%s\", port-addr=%p",
		parent_component, bt_component_get_name(parent_component),
		bt_port_type_string(type), name, port);

end:
	return port;
}
Esempio n. 17
0
struct bt_value *bt_value_bool_create_init(bt_bool val)
{
	struct bt_value_bool *bool_obj;

	BT_LOGD("Creating boolean value object: val=%d", val);
	bool_obj = g_new0(struct bt_value_bool, 1);
	if (!bool_obj) {
		BT_LOGE_STR("Failed to allocate one boolean value object.");
		goto end;
	}

	bool_obj->base = bt_value_create_base(BT_VALUE_TYPE_BOOL);
	bool_obj->value = val;
	BT_LOGD("Created boolean value object: addr=%p", bool_obj);

end:
	return (void *) bool_obj;
}
Esempio n. 18
0
static
void reset(struct bt_btr *btr)
{
	BT_LOGD("Resetting BTR: addr=%p", btr);
	stack_clear(btr->stack);
	BT_PUT(btr->cur_basic_field_type);
	stitch_reset(btr);
	btr->buf.addr = NULL;
	btr->last_bo = BT_BYTE_ORDER_UNKNOWN;
}
Esempio n. 19
0
void bt_btr_destroy(struct bt_btr *btr)
{
	if (btr->stack) {
		stack_destroy(btr->stack);
	}

	BT_LOGD("Destroying BTR: addr=%p", btr);
	BT_PUT(btr->cur_basic_field_type);
	g_free(btr);
}
Esempio n. 20
0
struct bt_value *bt_value_real_create_init(double val)
{
	struct bt_value_real *real_obj;

	BT_LOGD("Creating real number value object: val=%f", val);
	real_obj = g_new0(struct bt_value_real, 1);
	if (!real_obj) {
		BT_LOGE_STR("Failed to allocate one real number value object.");
		goto end;
	}

	real_obj->base = bt_value_create_base(BT_VALUE_TYPE_REAL);
	real_obj->value = val;
	BT_LOGD("Created real number value object: addr=%p",
		real_obj);

end:
	return (void *) real_obj;
}
Esempio n. 21
0
static
void stack_destroy(struct stack *stack)
{
	if (!stack) {
		return;
	}

	BT_LOGD("Destroying stack: addr=%p", stack);
	g_ptr_array_free(stack->entries, TRUE);
	g_free(stack);
}
Esempio n. 22
0
enum bt_value_status bt_value_copy(const struct bt_value *object,
		struct bt_value **copy_obj)
{
	enum bt_value_status status = BT_VALUE_STATUS_OK;

	BT_ASSERT_PRE_NON_NULL(object, "Value object");
	BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)");
	BT_LOGD("Copying value object: addr=%p", object);
	*copy_obj = copy_funcs[object->type](object);
	if (*copy_obj) {
		BT_LOGD("Copied value object: copy-value-addr=%p",
			copy_obj);
	} else {
		status = BT_VALUE_STATUS_NOMEM;
		*copy_obj = NULL;
		BT_LOGE_STR("Failed to copy value object.");
	}

	return status;
}
Esempio n. 23
0
/**
 * Initialize the ELF file for a given executable.
 *
 * @param bin	bin_info instance
 * @returns	0 on success, negative value on error.
 */
static
int bin_info_set_elf_file(struct bin_info *bin)
{
	int elf_fd = -1;
	Elf *elf_file = NULL;

	if (!bin) {
		goto error;
	}

	elf_fd = open(bin->elf_path, O_RDONLY);
	if (elf_fd < 0) {
		elf_fd = -errno;
		BT_LOGD("Failed to open ELF file: path=\"%s\"", bin->elf_path);
		goto error;
	}

	elf_file = elf_begin(elf_fd, ELF_C_READ, NULL);
	if (!elf_file) {
		BT_LOGD("elf_begin() failed: %s.", elf_errmsg(-1));
		goto error;
	}

	if (elf_kind(elf_file) != ELF_K_ELF) {
		BT_LOGD("ELF file is not an ELF object: path=\"%s\"",
			bin->elf_path);
		goto error;
	}

	bin->elf_fd = elf_fd;
	bin->elf_file = elf_file;
	return 0;

error:
	if (elf_fd >= 0) {
		close(elf_fd);
		elf_fd = -1;
	}
	elf_end(elf_file);
	return elf_fd;
}
void
BluetoothDiscoveryHandle::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[DH] %s", NS_ConvertUTF16toUTF8(aData.name()).get());

  if (aData.name().EqualsLiteral("DeviceFound")) {
    DispatchDeviceEvent(aData.value());
  } else {
    BT_WARNING("Not handling discovery handle signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
Esempio n. 25
0
BT_HIDDEN
int bin_info_init(void)
{
	int ret = 0;

	if (elf_version(EV_CURRENT) == EV_NONE) {
		BT_LOGD("ELF library initialization failed: %s.",
			elf_errmsg(-1));
		ret = -1;
	}

	return ret;
}
Esempio n. 26
0
BT_HIDDEN
void bt_ctf_clock_class_serialize(struct bt_ctf_clock_class *clock_class,
		struct metadata_context *context)
{
	unsigned char *uuid;

	BT_LOGD("Serializing clock class's metadata: clock-class-addr=%p, "
		"name=\"%s\", metadata-context-addr=%p", clock_class,
		bt_ctf_clock_class_get_name(clock_class),
		context);

	if (!clock_class || !context) {
		BT_LOGW("Invalid parameter: clock class or metadata context is NULL: "
			"clock-class-addr=%p, name=\"%s\", metadata-context-addr=%p",
			clock_class,
			bt_ctf_clock_class_get_name(clock_class),
			context);
		return;
	}

	uuid = clock_class->uuid;
	g_string_append(context->string, "clock {\n");
	g_string_append_printf(context->string, "\tname = %s;\n",
		clock_class->name->str);

	if (clock_class->uuid_set) {
		g_string_append_printf(context->string,
			"\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n",
			uuid[0], uuid[1], uuid[2], uuid[3],
			uuid[4], uuid[5], uuid[6], uuid[7],
			uuid[8], uuid[9], uuid[10], uuid[11],
			uuid[12], uuid[13], uuid[14], uuid[15]);
	}

	if (clock_class->description) {
		g_string_append_printf(context->string, "\tdescription = \"%s\";\n",
			clock_class->description->str);
	}

	g_string_append_printf(context->string, "\tfreq = %" PRIu64 ";\n",
		clock_class->frequency);
	g_string_append_printf(context->string, "\tprecision = %" PRIu64 ";\n",
		clock_class->precision);
	g_string_append_printf(context->string, "\toffset_s = %" PRIu64 ";\n",
		clock_class->offset_s);
	g_string_append_printf(context->string, "\toffset = %" PRIu64 ";\n",
		clock_class->offset);
	g_string_append_printf(context->string, "\tabsolute = %s;\n",
		clock_class->absolute ? "true" : "false");
	g_string_append(context->string, "};\n\n");
}
Esempio n. 27
0
BT_HIDDEN
int bt_ctf_event_class_common_initialize(struct bt_ctf_event_class_common *event_class,
		const char *name, bt_ctf_object_release_func release_func,
		bt_ctf_field_type_structure_create_func ft_struct_create_func)
{
	int ret = 0;

	BT_LOGD("Initializing common event class object: name=\"%s\"",
		name);
	bt_ctf_object_init_shared_with_parent(&event_class->base, release_func);
	event_class->payload_field_type = ft_struct_create_func();
	if (!event_class->payload_field_type) {
		BT_LOGE_STR("Cannot create event class's initial payload field type object.");
		goto error;
	}

	event_class->id = -1;
	event_class->name = g_string_new(name);
	if (!event_class->name) {
		BT_LOGE_STR("Failed to allocate a GString.");
		goto error;
	}

	event_class->emf_uri = g_string_new(NULL);
	if (!event_class->emf_uri) {
		BT_LOGE_STR("Failed to allocate a GString.");
		goto error;
	}

	event_class->log_level = BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED;
	BT_LOGD("Initialized common event class object: addr=%p, name=\"%s\"",
		event_class, bt_ctf_event_class_common_get_name(event_class));
	return ret;

error:
	ret = -1;
	return ret;
}
Esempio n. 28
0
static
void bt_port_destroy(struct bt_object *obj)
{
	struct bt_port *port = container_of(obj, struct bt_port, base);

	BT_LOGD("Destroying port: addr=%p, name=\"%s\", comp-addr=%p",
		port, bt_port_get_name(port), obj->parent);

	if (port->name) {
		g_string_free(port->name, TRUE);
	}

	g_free(port);
}
Esempio n. 29
0
static
int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
		struct ctf_fs_trace *ctf_fs_trace,
		struct ctf_fs_ds_file_group *ds_file_group)
{
	int ret = 0;
	struct ctf_fs_port_data *port_data = NULL;
	GString *port_name = NULL;

	port_name = get_stream_instance_unique_name(ds_file_group);
	if (!port_name) {
		goto error;
	}

	BT_LOGD("Creating one port named `%s`", port_name->str);

	/* Create output port for this file */
	port_data = g_new0(struct ctf_fs_port_data, 1);
	if (!port_data) {
		goto error;
	}

	port_data->ctf_fs = ctf_fs;
	port_data->ds_file_group = ds_file_group;
	ret = bt_self_component_source_add_output_port(
		ctf_fs->self_comp, port_name->str, port_data, NULL);
	if (ret) {
		goto error;
	}

	g_ptr_array_add(ctf_fs->port_data, port_data);
	port_data = NULL;
	goto end;

error:
	ret = -1;

end:
	if (port_name) {
		g_string_free(port_name, TRUE);
	}

	port_data_destroy(port_data);
	return ret;
}
Esempio n. 30
0
BT_HIDDEN
void bt_ctf_event_class_common_freeze(struct bt_ctf_event_class_common *event_class)
{
	BT_ASSERT(event_class);

	if (event_class->frozen) {
		return;
	}

	BT_LOGD("Freezing event class: addr=%p, name=\"%s\", id=%" PRId64,
		event_class, bt_ctf_event_class_common_get_name(event_class),
		bt_ctf_event_class_common_get_id(event_class));
	event_class->frozen = 1;
	BT_LOGD_STR("Freezing event class's context field type.");
	bt_ctf_field_type_common_freeze(event_class->context_field_type);
	BT_LOGD_STR("Freezing event class's payload field type.");
	bt_ctf_field_type_common_freeze(event_class->payload_field_type);
}