Always evaluate BT_ASSERT(); add BT_ASSERT_DBG() for debug mode only
[babeltrace.git] / src / plugins / lttng-utils / debug-info / debug-info.c
index 9f1be4bf35ae5645d133c68f0d4e809f787d07d6..71bb4c1a1158da434b95d96fbf6cb9ea47a2e755 100644 (file)
@@ -335,7 +335,7 @@ const bt_field *event_borrow_payload_field(const bt_event *event,
        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);
@@ -369,7 +369,7 @@ void event_get_common_context_signed_integer_field_value(
 }
 
 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;
@@ -388,20 +388,15 @@ int event_get_payload_build_id_length(const bt_event *event,
                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);
@@ -419,12 +414,10 @@ int event_get_payload_build_id_value(const bt_event *event,
 
        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
@@ -630,7 +623,8 @@ void handle_event_statedump_build_id(struct debug_info *debug_info,
                 */
                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);
@@ -638,11 +632,7 @@ void handle_event_statedump_build_id(struct debug_info *debug_info,
                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) {
@@ -960,7 +950,7 @@ void fill_debug_info_bin_field(struct debug_info_source *dbg_info_src,
        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) {
@@ -1003,7 +993,7 @@ void fill_debug_info_func_field(struct debug_info_source *dbg_info_src,
 {
        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,
@@ -1027,7 +1017,7 @@ void fill_debug_info_src_field(struct debug_info_source *dbg_info_src,
        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) {
@@ -1078,7 +1068,7 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
        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(
@@ -1088,11 +1078,11 @@ void fill_debug_info_field_empty(bt_field *debug_info_field,
        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, "");
@@ -1123,12 +1113,13 @@ void fill_debug_info_field(struct debug_info *debug_info, int64_t vpid,
        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);
 
@@ -1287,14 +1278,14 @@ bt_message *handle_event_message(struct debug_info_msg_iter *debug_it,
                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);
@@ -1861,16 +1852,16 @@ bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next(
        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(
@@ -1890,7 +1881,7 @@ bt_component_class_message_iterator_next_method_status debug_info_msg_iter_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,
This page took 0.026226 seconds and 4 git commands to generate.