Remove legacy printf_verbose()/printf_debug() and others
[babeltrace.git] / plugins / lttng-utils / plugin.c
index c6e75f59f122a929ac30965b19dc57afa3fe9d0a..1b63b8db585d3f6df9529401b6e6b15540d04f5a 100644 (file)
@@ -26,6 +26,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-UTILS-DEBUG-INFO-FLT"
+#include "logging.h"
+
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/graph/connection.h>
 #include "debug-info.h"
 #include "copy.h"
 
+static
+gboolean empty_trace_map(gpointer key, gpointer value, gpointer user_data)
+{
+       struct debug_info_trace *di_trace = value;
+
+       di_trace->trace_static = 1;
+       debug_info_close_trace(di_trace->debug_it, di_trace);
+
+       return TRUE;
+}
+
 static
 void destroy_debug_info_data(struct debug_info_component *debug_info)
 {
@@ -76,7 +90,8 @@ end:
 static
 void unref_trace(struct debug_info_trace *di_trace)
 {
-       bt_put(di_trace->trace);
+       bt_put(di_trace->writer_trace);
+       g_free(di_trace);
 }
 
 static
@@ -90,16 +105,14 @@ void debug_info_iterator_destroy(struct bt_private_notification_iterator *it)
        if (it_data->input_iterator_group) {
                g_ptr_array_free(it_data->input_iterator_group, TRUE);
        }
+
+       g_hash_table_foreach_remove(it_data->trace_map,
+                       empty_trace_map, it_data);
+       g_hash_table_destroy(it_data->trace_map);
+
        bt_put(it_data->current_notification);
        bt_put(it_data->input_iterator);
-       g_hash_table_destroy(it_data->trace_map);
-       /*
-        * TODO
-       g_hash_table_destroy(it_data->stream_map);
-       g_hash_table_destroy(it_data->stream_class_map);
-       g_hash_table_destroy(it_data->packet_map);
-       g_hash_table_destroy(it_data->trace_debug_map);
-       */
+
        g_free(it_data);
 }
 
@@ -127,6 +140,7 @@ struct bt_notification *handle_notification(FILE *err,
                                writer_packet);
                assert(new_notification);
                bt_put(packet);
+               bt_put(writer_packet);
                break;
        }
        case BT_NOTIFICATION_TYPE_PACKET_END:
@@ -145,6 +159,7 @@ struct bt_notification *handle_notification(FILE *err,
                                writer_packet);
                assert(new_notification);
                bt_put(packet);
+               bt_put(writer_packet);
                break;
        }
        case BT_NOTIFICATION_TYPE_EVENT:
@@ -350,7 +365,7 @@ enum bt_component_status init_from_params(
                value_ret = bt_value_string_get(value, &tmp);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve debug-info-field-name value. "
+                       BT_LOGE_STR("Failed to retrieve debug-info-field-name value. "
                                        "Expecting a string");
                }
                strcpy(debug_info_component->arg_debug_info_field_name, tmp);
@@ -360,7 +375,7 @@ enum bt_component_status init_from_params(
                        malloc(strlen("debug_info") + 1);
                if (!debug_info_component->arg_debug_info_field_name) {
                        ret = BT_COMPONENT_STATUS_NOMEM;
-                       printf_error();
+                       BT_LOGE_STR("Missing field name.");
                }
                sprintf(debug_info_component->arg_debug_info_field_name,
                                "debug_info");
@@ -377,7 +392,7 @@ enum bt_component_status init_from_params(
                                &debug_info_component->arg_debug_dir);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve debug-dir value. "
+                       BT_LOGE_STR("Failed to retrieve debug-dir value. "
                                        "Expecting a string");
                }
        }
@@ -394,7 +409,7 @@ enum bt_component_status init_from_params(
                                &debug_info_component->arg_target_prefix);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve target-prefix value. "
+                       BT_LOGE_STR("Failed to retrieve target-prefix value. "
                                        "Expecting a string");
                }
        }
@@ -412,7 +427,7 @@ enum bt_component_status init_from_params(
                                &bool_val);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
-                       printf_error("Failed to retrieve full-path value. "
+                       BT_LOGE_STR("Failed to retrieve full-path value. "
                                        "Expecting a boolean");
                }
 
This page took 0.033329 seconds and 4 git commands to generate.