X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Flttng-utils%2Fcopy.c;h=07590c7b330127eae12a67318beb2f6f92b9fb8a;hb=387483fca23fe90a5d2470581192049ef74ec3ec;hp=668bd0321396e61722ebe481be7d250da8d9ee03;hpb=1081db08e46cc432026fdf104fa7c130f8a1c72e;p=babeltrace.git diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 668bd032..07590c7b 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -867,15 +867,28 @@ struct bt_ctf_packet *insert_new_packet(struct debug_info_iterator *debug_it, struct debug_info_trace *di_trace) { struct bt_ctf_packet *writer_packet; + int ret; writer_packet = bt_ctf_packet_create(writer_stream); if (!writer_packet) { fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); - goto end; + goto error; } - g_hash_table_insert(di_trace->packet_map, (gpointer) packet, writer_packet); + ret = ctf_packet_copy_header(debug_it->err, packet, writer_packet); + if (ret) { + fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__, + __FILE__, __LINE__); + goto error; + } + + g_hash_table_insert(di_trace->packet_map, (gpointer) packet, + writer_packet); + goto end; + +error: + BT_PUT(writer_packet); end: return writer_packet; } @@ -1036,7 +1049,7 @@ struct bt_ctf_stream_class *copy_stream_class_debug_info(FILE *err, name = NULL; } - writer_stream_class = bt_ctf_stream_class_create(name); + writer_stream_class = bt_ctf_stream_class_create_empty(name); if (!writer_stream_class) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); @@ -1044,20 +1057,16 @@ struct bt_ctf_stream_class *copy_stream_class_debug_info(FILE *err, } type = bt_ctf_stream_class_get_packet_context_type(stream_class); - if (!type) { - fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, - __LINE__); - goto error; - } - - ret_int = bt_ctf_stream_class_set_packet_context_type( - writer_stream_class, type); - if (ret_int < 0) { - fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, - __LINE__); - goto error; + if (type) { + ret_int = bt_ctf_stream_class_set_packet_context_type( + writer_stream_class, type); + if (ret_int < 0) { + fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, + __LINE__); + goto error; + } + BT_PUT(type); } - BT_PUT(type); type = bt_ctf_stream_class_get_event_header_type(stream_class); if (type) { @@ -1368,8 +1377,8 @@ struct bt_ctf_packet *debug_info_new_packet( struct bt_ctf_packet *packet) { struct bt_ctf_stream *stream = NULL, *writer_stream = NULL; - struct bt_ctf_field *writer_packet_context = NULL; struct bt_ctf_packet *writer_packet = NULL; + struct bt_ctf_field *packet_context = NULL; struct debug_info_trace *di_trace; int int_ret; @@ -1412,19 +1421,16 @@ struct bt_ctf_packet *debug_info_new_packet( goto error; } - writer_packet_context = ctf_copy_packet_context(debug_it->err, packet, - writer_stream); - if (!writer_packet_context) { - fprintf(debug_it->err, "[error] %s in %s:%d\n", - __func__, __FILE__, __LINE__); - goto error; - } - - int_ret = bt_ctf_packet_set_context(writer_packet, writer_packet_context); - if (int_ret) { - fprintf(debug_it->err, "[error] %s in %s:%d\n", - __func__, __FILE__, __LINE__); - goto error; + packet_context = bt_ctf_packet_get_context(packet); + if (packet_context) { + int_ret = ctf_packet_copy_context(debug_it->err, + packet, writer_stream, writer_packet); + if (int_ret < 0) { + fprintf(debug_it->err, "[error] %s in %s:%d\n", + __func__, __FILE__, __LINE__); + goto error; + } + BT_PUT(packet_context); } bt_get(writer_packet); @@ -1433,7 +1439,7 @@ struct bt_ctf_packet *debug_info_new_packet( error: end: - bt_put(writer_packet_context); + bt_put(packet_context); bt_put(writer_stream); bt_put(stream); return writer_packet;