From ab80adac56044ab951e76eb818c4ca1140d2a0a2 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Wed, 17 May 2017 16:58:55 -0400 Subject: [PATCH] copytrace: option to skip the copy of packet/content size 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/ctf/fs-sink/write.c | 2 +- plugins/libctfcopytrace/ctfcopytrace.c | 9 +++++---- plugins/libctfcopytrace/ctfcopytrace.h | 7 ++++--- plugins/lttng-utils/copy.c | 2 +- plugins/utils/trimmer/copy.c | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/ctf/fs-sink/write.c b/plugins/ctf/fs-sink/write.c index 91b92899..75360565 100644 --- a/plugins/ctf/fs-sink/write.c +++ b/plugins/ctf/fs-sink/write.c @@ -308,7 +308,7 @@ enum bt_component_status writer_new_packet( BT_PUT(stream); writer_packet_context = ctf_copy_packet_context(writer_component->err, - packet, writer_stream); + packet, writer_stream, 1); if (!writer_packet_context) { fprintf(writer_component->err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 4455dfb8..0689ee38 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -530,7 +530,8 @@ end: BT_HIDDEN struct bt_ctf_field *ctf_copy_packet_context(FILE *err, struct bt_ctf_packet *packet, - struct bt_ctf_stream *writer_stream) + struct bt_ctf_stream *writer_stream, + int skip_content_size) { enum bt_component_status ret; struct bt_ctf_field *packet_context = NULL, *writer_packet_context = NULL; @@ -592,9 +593,9 @@ struct bt_ctf_field *ctf_copy_packet_context(FILE *err, __FILE__, __LINE__); goto error; } - if (!strncmp(field_name, "content_size", strlen("content_size")) || - !strncmp(field_name, "packet_size", - strlen("packet_size"))) { + if (skip_content_size && + (!strncmp(field_name, "content_size", strlen("content_size")) || + !strncmp(field_name, "packet_size", strlen("packet_size")))) { BT_PUT(field_type); BT_PUT(field); continue; diff --git a/plugins/libctfcopytrace/ctfcopytrace.h b/plugins/libctfcopytrace/ctfcopytrace.h index 6820a8a2..417b2d5d 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.h +++ b/plugins/libctfcopytrace/ctfcopytrace.h @@ -105,8 +105,8 @@ enum bt_component_status ctf_copy_packet_context_field(FILE *err, /* * Copy all the field values of the packet context from the packet passed in * parameter and set it to the current packet in the writer stream. - * The content_size and packet_size fields are not copied since they are - * already handled by the ctf_writer library. + * The content_size and packet_size fields are not copied if skip_content_size + * is not 0. * * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on * error. @@ -114,7 +114,8 @@ enum bt_component_status ctf_copy_packet_context_field(FILE *err, BT_HIDDEN struct bt_ctf_field *ctf_copy_packet_context(FILE *err, struct bt_ctf_packet *packet, - struct bt_ctf_stream *writer_stream); + struct bt_ctf_stream *writer_stream, + int skip_content_size); /* * Create and return a copy of the event passed in parameter. The caller has to diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 14cc1274..c553d79b 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -1058,7 +1058,7 @@ struct bt_ctf_packet *debug_info_new_packet( bt_get(writer_packet); writer_packet_context = ctf_copy_packet_context(debug_it->err, packet, - writer_stream); + writer_stream, 0); if (!writer_packet_context) { fprintf(debug_it->err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); diff --git a/plugins/utils/trimmer/copy.c b/plugins/utils/trimmer/copy.c index 9d0d8141..a76f7c05 100644 --- a/plugins/utils/trimmer/copy.c +++ b/plugins/utils/trimmer/copy.c @@ -194,7 +194,7 @@ struct bt_ctf_packet *trimmer_new_packet( bt_get(writer_packet); writer_packet_context = ctf_copy_packet_context(trim_it->err, packet, - stream); + stream, 0); if (!writer_packet_context) { fprintf(trim_it->err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); -- 2.34.1