From 2d64a1eb85d4ddd21e34235ab735ae6afd0903de Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 12 Jun 2017 15:06:27 -0400 Subject: [PATCH] debug-info fix: packet_context is optional MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- plugins/lttng-utils/copy.c | 42 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 668bd032..2d48ac61 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -1036,7 +1036,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 +1044,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) { @@ -1370,6 +1366,7 @@ struct bt_ctf_packet *debug_info_new_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,12 +1409,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; + packet_context = bt_ctf_packet_get_context(packet); + if (packet_context) { + 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; + } + BT_PUT(packet_context); } int_ret = bt_ctf_packet_set_context(writer_packet, writer_packet_context); @@ -1433,6 +1434,7 @@ struct bt_ctf_packet *debug_info_new_packet( error: end: + bt_put(packet_context); bt_put(writer_packet_context); bt_put(writer_stream); bt_put(stream); -- 2.34.1