#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"
debug_info_src->line_no =
g_strdup_printf("%"PRId64, src_loc->line_no);
if (!debug_info_src->line_no) {
- BT_COMP_LOGE("Error occured when setting line_no field.");
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error occured when setting `line_no` field.");
goto error;
}
const bt_field *event_payload, *field;
event_payload = bt_event_borrow_payload_field_const(event);
- BT_ASSERT(event_payload);
+ BT_ASSERT_DBG(event_payload);
field = bt_field_structure_borrow_member_field_by_name_const(
event_payload, field_name);
}
static inline
-int event_get_payload_build_id_length(const bt_event *event,
+void event_get_payload_build_id_length(const bt_event *event,
const char *field_name, uint64_t *build_id_len)
{
const bt_field *build_id_field;
build_id_field_class = bt_field_borrow_class_const(build_id_field);
BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ bt_field_class_get_type(build_id_field_class) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
BT_ASSERT(bt_field_class_get_type(
bt_field_class_array_borrow_element_field_class_const(
build_id_field_class)) ==
BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER);
*build_id_len = bt_field_array_get_length(build_id_field);
-
- return 0;
}
static inline
-int event_get_payload_build_id_value(const bt_event *event,
+void event_get_payload_build_id_value(const bt_event *event,
const char *field_name, uint8_t *build_id)
{
const bt_field *curr_field, *build_id_field;
const bt_field_class *build_id_field_class;
uint64_t i, build_id_len;
- int ret;
-
- ret = 0;
build_id_field = event_borrow_payload_field(event, field_name);
build_id_field_class = bt_field_borrow_class_const(build_id_field);
BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ bt_field_class_get_type(build_id_field_class) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
BT_ASSERT(bt_field_class_get_type(
bt_field_class_array_borrow_element_field_class_const(
build_id_field_class)) ==
for (i = 0; i < build_id_len; i++) {
curr_field = bt_field_array_borrow_element_field_by_index_const(
- build_id_field, i);
+ build_id_field, i);
build_id[i] = bt_field_integer_unsigned_get_value(curr_field);
}
-
- return ret;
}
static
*/
goto end;
}
- ret = event_get_payload_build_id_length(event, BUILD_ID_FIELD_NAME,
+
+ event_get_payload_build_id_length(event, BUILD_ID_FIELD_NAME,
&build_id_len);
build_id = g_new0(uint8_t, build_id_len);
goto end;
}
- ret = event_get_payload_build_id_value(event, BUILD_ID_FIELD_NAME,
- build_id);
- if (ret) {
- goto end;
- }
+ event_get_payload_build_id_value(event, BUILD_ID_FIELD_NAME, build_id);
ret = bin_info_set_build_id(bin, build_id, build_id_len);
if (ret) {
bt_field_string_set_value_status set_status;
bt_field_string_append_status append_status;
- BT_ASSERT(bt_field_get_class_type(curr_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
BT_FIELD_CLASS_TYPE_STRING);
if (dbg_info_src) {
dbg_info_src->short_bin_path);
}
if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set path component of \"bin\" "
+ BT_COMP_LOGE("Cannot set path component of `bin` "
"curr_field field's value: str-fc-addr=%p",
curr_field);
bt_current_thread_clear_error();
append_status = bt_field_string_append(curr_field,
dbg_info_src->bin_loc);
if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
- BT_COMP_LOGE("Cannot set bin location component of \"bin\" "
+ BT_COMP_LOGE("Cannot set bin location component of `bin` "
"curr_field field's value: str-fc-addr=%p",
curr_field);
bt_current_thread_clear_error();
} else {
set_status = bt_field_string_set_value(curr_field, "");
if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"bin\" curr_field field's value: "
+ BT_COMP_LOGE("Cannot set `bin` curr_field field's value: "
"str-fc-addr=%p", curr_field);
bt_current_thread_clear_error();
}
{
bt_field_string_set_value_status status;
- BT_ASSERT(bt_field_get_class_type(curr_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
BT_FIELD_CLASS_TYPE_STRING);
if (dbg_info_src && dbg_info_src->func) {
status = bt_field_string_set_value(curr_field,
status = bt_field_string_set_value(curr_field, "");
}
if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"func\" curr_field field's value: "
+ BT_COMP_LOGE("Cannot set `func` curr_field field's value: "
"str-fc-addr=%p", curr_field);
bt_current_thread_clear_error();
}
bt_field_string_set_value_status set_status;
bt_field_string_append_status append_status;
- BT_ASSERT(bt_field_get_class_type(curr_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(curr_field) ==
BT_FIELD_CLASS_TYPE_STRING);
if (dbg_info_src && dbg_info_src->src_path) {
dbg_info_src->short_src_path);
}
if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set path component of \"src\" "
+ BT_COMP_LOGE("Cannot set path component of `src` "
"curr_field field's value: str-fc-addr=%p",
curr_field);
bt_current_thread_clear_error();
append_status = bt_field_string_append(curr_field, ":");
if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
- BT_COMP_LOGE("Cannot set colon component of \"src\" "
+ BT_COMP_LOGE("Cannot set colon component of `src` "
"curr_field field's value: str-fc-addr=%p",
curr_field);
bt_current_thread_clear_error();
append_status = bt_field_string_append(curr_field,
dbg_info_src->line_no);
if (append_status != BT_FIELD_STRING_APPEND_STATUS_OK) {
- BT_COMP_LOGE("Cannot set line number component of \"src\" "
+ BT_COMP_LOGE("Cannot set line number component of `src` "
"curr_field field's value: str-fc-addr=%p",
curr_field);
bt_current_thread_clear_error();
} else {
set_status = bt_field_string_set_value(curr_field, "");
if (set_status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"src\" curr_field field's value: "
+ BT_COMP_LOGE("Cannot set `src` curr_field field's value: "
"str-fc-addr=%p", curr_field);
bt_current_thread_clear_error();
}
bt_field_string_set_value_status status;
bt_field *bin_field, *func_field, *src_field;
- BT_ASSERT(bt_field_get_class_type(debug_info_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(debug_info_field) ==
BT_FIELD_CLASS_TYPE_STRUCTURE);
bin_field = bt_field_structure_borrow_member_field_by_name(
src_field = bt_field_structure_borrow_member_field_by_name(
debug_info_field, "src");
- BT_ASSERT(bt_field_get_class_type(bin_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(bin_field) ==
BT_FIELD_CLASS_TYPE_STRING);
- BT_ASSERT(bt_field_get_class_type(func_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(func_field) ==
BT_FIELD_CLASS_TYPE_STRING);
- BT_ASSERT(bt_field_get_class_type(src_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(src_field) ==
BT_FIELD_CLASS_TYPE_STRING);
status = bt_field_string_set_value(bin_field, "");
if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"bin\" bin_field field's value: "
+ BT_COMP_LOGE("Cannot set `bin` field's value: "
"str-fc-addr=%p", bin_field);
bt_current_thread_clear_error();
}
status = bt_field_string_set_value(func_field, "");
if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"func\" func_field field's value: "
+ BT_COMP_LOGE("Cannot set `func` field's value: "
"str-fc-addr=%p", func_field);
bt_current_thread_clear_error();
}
status = bt_field_string_set_value(src_field, "");
if (status != BT_FIELD_STRING_SET_VALUE_STATUS_OK) {
- BT_COMP_LOGE("Cannot set \"src\" src_field field's value: "
+ BT_COMP_LOGE("Cannot set `src` field's value: "
"str-fc-addr=%p", src_field);
bt_current_thread_clear_error();
}
struct debug_info_source *dbg_info_src;
const bt_field_class *debug_info_fc;
- BT_ASSERT(bt_field_get_class_type(debug_info_field) ==
+ BT_ASSERT_DBG(bt_field_get_class_type(debug_info_field) ==
BT_FIELD_CLASS_TYPE_STRUCTURE);
debug_info_fc = bt_field_borrow_class_const(debug_info_field);
- BT_ASSERT(bt_field_class_structure_get_member_count(debug_info_fc) == 3);
+ BT_ASSERT_DBG(bt_field_class_structure_get_member_count(
+ debug_info_fc) == 3);
dbg_info_src = debug_info_query(debug_info, vpid, ip);
out_event_class = trace_ir_mapping_create_new_mapped_event_class(
debug_it->ir_maps, in_event_class);
}
- BT_ASSERT(out_event_class);
+ BT_ASSERT_DBG(out_event_class);
/* Borrow the input stream. */
in_stream = bt_event_borrow_stream_const(in_event);
- BT_ASSERT(in_stream);
+ BT_ASSERT_DBG(in_stream);
out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
in_stream);
- BT_ASSERT(in_stream);
+ BT_ASSERT_DBG(in_stream);
/* Borrow the input and output packets. */
in_packet = bt_event_borrow_packet_const(in_event);
}
if (!out_message) {
- BT_COMP_LOGE("Error creating output event message.");
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output event message.");
goto error;
}
out_event = bt_message_event_borrow_event(out_message);
/* Copy the original fields to the output event. */
- copy_event_content(in_event, out_event, log_level, self_comp);
+ if (copy_event_content(in_event, out_event, log_level, self_comp) !=
+ DEBUG_INFO_TRACE_IR_MAPPING_STATUS_OK) {
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error copying event message content output event message: "
+ "in-ev-addr=%p, out-ev-addr=%p", in_event, out_event);
+ goto error;
+ }
/*
* Try to set the debug-info fields based on debug information that is
*/
fill_debug_info_event_if_needed(debug_it, in_event, out_event);
+ goto end;
+
error:
+ BT_MESSAGE_PUT_REF_AND_RESET(out_message);
+end:
return out_message;
}
out_message = bt_message_stream_beginning_create(
debug_it->input_iterator, out_stream);
if (!out_message) {
- BT_COMP_LOGE("Error creating output stream beginning message: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output stream beginning message: "
"out-s-addr=%p", out_stream);
}
error:
out_message = bt_message_stream_end_create(debug_it->input_iterator,
out_stream);
if (!out_message) {
- BT_COMP_LOGE("Error creating output stream end message: out-s-addr=%p",
- out_stream);
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output stream end message: "
+ "out-s-addr=%p", out_stream);
goto end;
}
debug_it->input_iterator, out_packet);
}
if (!out_message) {
- BT_COMP_LOGE("Error creating output packet beginning message: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output packet beginning message: "
"out-p-addr=%p", out_packet);
}
}
if (!out_message) {
- BT_COMP_LOGE("Error creating output packet end message: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output packet end message: "
"out-p-addr=%p", out_packet);
goto end;
}
debug_it->input_iterator, out_stream);
}
if (!out_message) {
- BT_COMP_LOGE("Error creating output discarded events message: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output discarded events message: "
"out-s-addr=%p", out_stream);
goto error;
}
debug_it->input_iterator, out_stream);
}
if (!out_message) {
- BT_COMP_LOGE("Error creating output discarded packet message: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Error creating output discarded packet message: "
"out-s-addr=%p", out_stream);
goto error;
}
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
bt_component_class_initialize_method_status init_from_params(
struct debug_info_component *debug_info_component,
{
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);
status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
+end:
+ g_free(validate_error);
+
return status;
}
debug_info_comp = g_new0(struct debug_info_component, 1);
if (!debug_info_comp) {
- BT_COMP_LOGE_STR("Failed to allocate one debug_info component.");
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Failed to allocate one debug_info component.");
goto error;
}
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: "
+ BT_COMP_LOGE_APPEND_CAUSE(self_comp,
+ "Cannot configure debug_info component: "
"debug_info-comp-addr=%p, params-addr=%p",
debug_info_comp, params);
goto error;
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
self_comp = bt_self_message_iterator_borrow_component(self_msg_iter);
- BT_ASSERT(self_comp);
+ BT_ASSERT_DBG(self_comp);
debug_info = bt_self_component_get_data(self_comp);
- BT_ASSERT(debug_info);
+ BT_ASSERT_DBG(debug_info);
debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter);
- BT_ASSERT(debug_info_msg_iter);
+ BT_ASSERT_DBG(debug_info_msg_iter);
upstream_iterator = debug_info_msg_iter->msg_iter;
- BT_ASSERT(upstream_iterator);
+ BT_ASSERT_DBG(upstream_iterator);
upstream_iterator_ret_status =
bt_self_component_port_input_message_iterator_next(
* There should never be more received messages than the capacity we
* provided.
*/
- BT_ASSERT(*count <= capacity);
+ BT_ASSERT_DBG(*count <= capacity);
for (curr_msg_idx = 0; curr_msg_idx < *count; curr_msg_idx++) {
out_message = handle_message(debug_info_msg_iter,