#include "trace-ir-mapping.h"
#include "trace-ir-metadata-copy.h"
#include "utils.h"
+#include "plugins/common/param-validation/param-validation.h"
#define DEFAULT_DEBUG_INFO_FIELD_NAME "debug_info"
#define LTTNG_UST_STATEDUMP_PREFIX "lttng_ust"
return out_message;
}
+struct bt_param_validation_map_value_entry_descr debug_info_params[] = {
+ { "debug-info-field-name", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } },
+ { "debug-info-dir", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } },
+ { "target-prefix", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_STRING } },
+ { "full-path", BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } },
+ BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END
+};
+
static
-int init_from_params(struct debug_info_component *debug_info_component,
+bt_component_class_initialize_method_status init_from_params(
+ struct debug_info_component *debug_info_component,
const bt_value *params)
{
- const bt_value *value = NULL;
- int ret = 0;
+ const bt_value *value;
+ bt_component_class_initialize_method_status status;
+ bt_logging_level log_level = debug_info_component->log_level;
+ enum bt_param_validation_status validation_status;
+ gchar *validate_error = NULL;
+
+ validation_status = bt_param_validation_validate(params,
+ debug_info_params, &validate_error);
+ if (validation_status == BT_PARAM_VALIDATION_STATUS_MEMORY_ERROR) {
+ status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ goto end;
+ } else if (validation_status == BT_PARAM_VALIDATION_STATUS_VALIDATION_ERROR) {
+ status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
+ BT_COMP_LOGE_APPEND_CAUSE(debug_info_component->self_comp,
+ "%s", validate_error);
+ goto end;
+ }
BT_ASSERT(params);
debug_info_component->arg_full_path = BT_FALSE;
}
- return ret;
+ status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
+
+end:
+ g_free(validate_error);
+
+ return status;
}
BT_HIDDEN
bt_self_component_filter_configuration *config,
const bt_value *params, __attribute__((unused)) void *init_method_data)
{
- int ret;
struct debug_info_component *debug_info_comp;
bt_component_class_initialize_method_status status =
BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
bt_logging_level log_level = bt_component_get_logging_level(
bt_self_component_as_component(self_comp));
-
BT_COMP_LOGI("Initializing debug_info component: "
"comp-addr=%p, params-addr=%p", self_comp, params);
add_port_status = bt_self_component_filter_add_input_port(
self_comp_flt, "in", NULL, NULL);
- switch (add_port_status) {
- case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
+ if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) {
+ status = (int) add_port_status;
goto error;
- case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- goto error;
- default:
- break;
}
add_port_status = bt_self_component_filter_add_output_port(
- self_comp_flt, "out", NULL, NULL);
- switch (add_port_status) {
- case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
- goto error;
- case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
+ self_comp_flt, "out", NULL, NULL);
+ if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) {
+ status = (int) add_port_status;
goto error;
- default:
- break;
}
- ret = init_from_params(debug_info_comp, params);
- if (ret) {
+ status = init_from_params(debug_info_comp, params);
+ if (status != BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
BT_COMP_LOGE("Cannot configure debug_info component: "
"debug_info-comp-addr=%p, params-addr=%p",
debug_info_comp, params);