Dry-run mode can be used when component classes need to decode CTF
packets but do not want the `bt_msg_iter` to create and use the
Babeltrace library objects (bt_field, bt_message_*, etc.).
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I336ec4c893835e7b1d6f32262841793f7543aa06
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1417
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
/* True to emit a stream end message. */
bool emit_stream_end_msg;
/* True to emit a stream end message. */
bool emit_stream_end_msg;
+ /*
+ * True if library objects are unavailable during the decoding and
+ * should not be created/used.
+ */
+ bool dry_run;
+
/* True to set the stream */
bool set_stream;
/* True to set the stream */
bool set_stream;
BT_ASSERT(!notit->packet_context_field);
BT_ASSERT(!notit->packet_context_field);
- if (packet_context_fc->in_ir) {
+ if (packet_context_fc->in_ir && !notit->dry_run) {
/*
* Create free packet context field from stream class.
* This field is going to be moved to the packet once we
/*
* Create free packet context field from stream class.
* This field is going to be moved to the packet once we
+ if (G_UNLIKELY(notit->dry_run)) {
+ goto next_state;
+ }
+
status = set_current_event_message(notit);
if (status != BT_MSG_ITER_STATUS_OK) {
goto end;
status = set_current_event_message(notit);
if (status != BT_MSG_ITER_STATUS_OK) {
goto end;
notit->event = bt_message_event_borrow_event(
notit->event_msg);
BT_ASSERT(notit->event);
notit->event = bt_message_event_borrow_event(
notit->event_msg);
BT_ASSERT(notit->event);
notit->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
end:
notit->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
end:
- if (event_common_context_fc->in_ir) {
+ if (event_common_context_fc->in_ir && !notit->dry_run) {
BT_ASSERT(!notit->dscopes.event_common_context);
notit->dscopes.event_common_context =
bt_event_borrow_common_context_field(
BT_ASSERT(!notit->dscopes.event_common_context);
notit->dscopes.event_common_context =
bt_event_borrow_common_context_field(
- if (event_spec_context_fc->in_ir) {
+ if (event_spec_context_fc->in_ir && !notit->dry_run) {
BT_ASSERT(!notit->dscopes.event_spec_context);
notit->dscopes.event_spec_context =
bt_event_borrow_specific_context_field(
BT_ASSERT(!notit->dscopes.event_spec_context);
notit->dscopes.event_spec_context =
bt_event_borrow_specific_context_field(
- if (event_payload_fc->in_ir) {
+ if (event_payload_fc->in_ir && !notit->dry_run) {
BT_ASSERT(!notit->dscopes.event_payload);
notit->dscopes.event_payload =
bt_event_borrow_payload_field(
BT_ASSERT(!notit->dscopes.event_payload);
notit->dscopes.event_payload =
bt_event_borrow_payload_field(
(uint64_t) int_fc->storing_index) = value;
}
(uint64_t) int_fc->storing_index) = value;
}
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
BT_ASSERT(!int_fc->mapped_clock_class);
BT_ASSERT(int_fc->storing_index < 0);
BT_ASSERT(!int_fc->mapped_clock_class);
BT_ASSERT(int_fc->storing_index < 0);
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
(uint64_t) int_fc->storing_index) = (uint64_t) value;
}
(uint64_t) int_fc->storing_index) = (uint64_t) value;
}
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
"fc-type=%d, fc-in-ir=%d, value=%f",
notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
"fc-type=%d, fc-in-ir=%d, value=%f",
notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
notit, notit->bfcr, fc, fc->type, fc->in_ir,
len);
notit, notit->bfcr, fc, fc->type, fc->in_ir,
len);
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
- if (G_UNLIKELY(!fc->in_ir)) {
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
+ if (G_UNLIKELY(!fc->in_ir || notit->dry_run)) {
length = (uint64_t) g_array_index(notit->stored_values, uint64_t,
seq_fc->stored_length_index);
length = (uint64_t) g_array_index(notit->stored_values, uint64_t,
seq_fc->stored_length_index);
+
+ if (G_UNLIKELY(notit->dry_run)){
+ goto end;
+ }
+
seq_field = stack_top(notit->stack)->base;
BT_ASSERT(seq_field);
seq_field = stack_top(notit->stack)->base;
BT_ASSERT(seq_field);
selected_option = ctf_field_class_variant_borrow_option_by_index(
var_fc, (uint64_t) option_index);
selected_option = ctf_field_class_variant_borrow_option_by_index(
var_fc, (uint64_t) option_index);
- if (selected_option->fc->in_ir) {
+ if (selected_option->fc->in_ir && !notit->dry_run) {
bt_field *var_field = stack_top(notit->stack)->base;
ret = bt_field_variant_select_option_field_by_index(
bt_field *var_field = stack_top(notit->stack)->base;
ret = bt_field_variant_select_option_field_by_index(
{
notit->emit_stream_end_msg = val;
}
{
notit->emit_stream_end_msg = val;
}
+
+BT_HIDDEN
+void bt_msg_iter_set_dry_run(struct bt_msg_iter *notit,
+ bool val)
+{
+ notit->dry_run = val;
+}
void bt_msg_iter_set_emit_stream_end_message(struct bt_msg_iter *notit,
bool val);
void bt_msg_iter_set_emit_stream_end_message(struct bt_msg_iter *notit,
bool val);
+BT_HIDDEN
+void bt_msg_iter_set_dry_run(struct bt_msg_iter *notit,
+ bool val);
+
static inline
const char *bt_msg_iter_medium_status_string(
enum bt_msg_iter_medium_status status)
static inline
const char *bt_msg_iter_medium_status_string(
enum bt_msg_iter_medium_status status)