+ int_ret = 0;
+ goto end;
+
+error:
+ int_ret = -1;
+end:
+ bt_put(stream_class);
+ bt_put(writer_stream_class);
+ return int_ret;
+}
+
+static
+void trace_is_static_listener(struct bt_trace *trace, void *data)
+{
+ struct debug_info_trace *di_trace = data;
+ int trace_completed = 1, ret, nr_stream, i;
+ struct bt_stream *stream = NULL, *writer_stream = NULL;
+ struct bt_trace *writer_trace = di_trace->writer_trace;
+
+ /*
+ * When the trace becomes static, make sure that we have all
+ * the event classes in our stream_class copies before setting it
+ * static as well.
+ */
+ nr_stream = bt_trace_get_stream_count(trace);
+ for (i = 0; i < nr_stream; i++) {
+ stream = bt_trace_get_stream_by_index(trace, i);
+ BT_ASSERT(stream);
+
+ writer_stream = bt_trace_get_stream_by_index(writer_trace, i);
+ BT_ASSERT(writer_stream);
+
+ ret = sync_event_classes(di_trace->debug_it, stream, writer_stream);
+ if (ret) {
+ BT_LOGE_STR("Failed to synchronize the event classes.");
+ goto error;
+ }
+ BT_PUT(stream);
+ BT_PUT(writer_stream);
+ }
+
+ bt_trace_set_is_static(di_trace->writer_trace);
+ di_trace->trace_static = 1;
+
+ g_hash_table_foreach(di_trace->stream_states,
+ check_completed_trace, &trace_completed);
+ if (trace_completed) {
+ debug_info_close_trace(di_trace->debug_it, di_trace);
+ g_hash_table_remove(di_trace->debug_it->trace_map,
+ di_trace->trace);
+ }
+
+error:
+ bt_put(writer_stream);
+ bt_put(stream);
+}
+
+static
+struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it,
+ struct bt_stream *stream) {
+ struct bt_trace *writer_trace = NULL;
+ struct debug_info_trace *di_trace = NULL;
+ struct bt_trace *trace = NULL;
+ struct bt_stream_class *stream_class = NULL;
+ struct bt_stream *writer_stream = NULL;
+ int ret, nr_stream, i;
+
+ writer_trace = bt_trace_create();
+ if (!writer_trace) {
+ BT_LOGE_STR("Failed to create a new trace.");