From 605e1019783967f33d86967e7c98dd52cbd69a4c Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 8 Dec 2018 13:46:17 -0500 Subject: [PATCH] lib: rename "clock value" -> "clock snapshot" This is more consistent with the current counter snapshots in the packet API. Signed-off-by: Philippe Proulx --- include/Makefile.am | 6 +- include/babeltrace/babeltrace.h | 2 +- .../graph/message-inactivity-const.h | 6 +- .../graph/message-inactivity-internal.h | 4 +- include/babeltrace/graph/message-inactivity.h | 2 +- .../babeltrace/graph/message-stream-const.h | 10 +- .../graph/message-stream-internal.h | 6 +- include/babeltrace/graph/message-stream.h | 4 +- include/babeltrace/lib-logging-internal.h | 2 +- .../trace-ir/clock-class-internal.h | 6 +- ...k-value-const.h => clock-snapshot-const.h} | 26 +-- ...e-internal.h => clock-snapshot-internal.h} | 52 +++--- .../trace-ir/clock-snapshot-set-internal.h | 159 ++++++++++++++++ .../trace-ir/clock-value-set-internal.h | 159 ---------------- include/babeltrace/trace-ir/event-const.h | 10 +- include/babeltrace/trace-ir/event-internal.h | 8 +- include/babeltrace/trace-ir/event.h | 2 +- include/babeltrace/trace-ir/packet-const.h | 14 +- include/babeltrace/trace-ir/packet-internal.h | 6 +- include/babeltrace/trace-ir/packet.h | 4 +- .../babeltrace/trace-ir/stream-class-const.h | 4 +- .../trace-ir/stream-class-internal.h | 4 +- include/babeltrace/trace-ir/stream-class.h | 4 +- include/babeltrace/types.h | 2 +- lib/graph/message/discarded-events.c | 12 +- lib/graph/message/discarded-packets.c | 12 +- lib/graph/message/inactivity.c | 22 +-- lib/graph/message/stream.c | 40 ++-- lib/lib-logging.c | 60 +++--- lib/trace-ir/Makefile.am | 2 +- lib/trace-ir/clock-class.c | 16 +- lib/trace-ir/clock-snapshot.c | 173 ++++++++++++++++++ lib/trace-ir/clock-value.c | 172 ----------------- lib/trace-ir/event-class.c | 2 +- lib/trace-ir/event.c | 34 ++-- lib/trace-ir/packet.c | 86 ++++----- lib/trace-ir/stream-class.c | 22 +-- .../ctf/common/metadata/ctf-meta-translate.c | 4 +- plugins/ctf/common/msg-iter/msg-iter.c | 32 ++-- plugins/ctf/lttng-live/lttng-live.c | 14 +- plugins/libctfcopytrace/clock-fields.c | 18 +- plugins/libctfcopytrace/ctfcopytrace.c | 18 +- plugins/lttng-utils/copy.c | 14 +- plugins/text/dmesg/dmesg.c | 2 +- plugins/text/pretty/print.c | 54 +++--- plugins/utils/muxer/muxer.c | 30 +-- plugins/utils/trimmer/iterator.c | 26 +-- 47 files changed, 684 insertions(+), 683 deletions(-) rename include/babeltrace/trace-ir/{clock-value-const.h => clock-snapshot-const.h} (71%) rename include/babeltrace/trace-ir/{clock-value-internal.h => clock-snapshot-internal.h} (55%) create mode 100644 include/babeltrace/trace-ir/clock-snapshot-set-internal.h delete mode 100644 include/babeltrace/trace-ir/clock-value-set-internal.h create mode 100644 lib/trace-ir/clock-snapshot.c delete mode 100644 lib/trace-ir/clock-value.c diff --git a/include/Makefile.am b/include/Makefile.am index 0edf60da..96d41927 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -119,7 +119,7 @@ babeltracetraceirincludedir = "$(includedir)/babeltrace/trace-ir" babeltracetraceirinclude_HEADERS = \ babeltrace/trace-ir/clock-class-const.h \ babeltrace/trace-ir/clock-class.h \ - babeltrace/trace-ir/clock-value-const.h \ + babeltrace/trace-ir/clock-snapshot-const.h \ babeltrace/trace-ir/event-class-const.h \ babeltrace/trace-ir/event-class.h \ babeltrace/trace-ir/event-const.h \ @@ -244,8 +244,8 @@ noinst_HEADERS = \ babeltrace/endian-internal.h \ babeltrace/trace-ir/attributes-internal.h \ babeltrace/trace-ir/clock-class-internal.h \ - babeltrace/trace-ir/clock-value-internal.h \ - babeltrace/trace-ir/clock-value-set-internal.h \ + babeltrace/trace-ir/clock-snapshot-internal.h \ + babeltrace/trace-ir/clock-snapshot-set-internal.h \ babeltrace/trace-ir/event-class-internal.h \ babeltrace/trace-ir/event-internal.h \ babeltrace/trace-ir/field-class-internal.h \ diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index 01b220d1..10595c29 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -65,7 +65,7 @@ /* Trace IR API */ #include #include -#include +#include #include #include #include diff --git a/include/babeltrace/graph/message-inactivity-const.h b/include/babeltrace/graph/message-inactivity-const.h index 7aab72ba..9c1a825b 100644 --- a/include/babeltrace/graph/message-inactivity-const.h +++ b/include/babeltrace/graph/message-inactivity-const.h @@ -23,15 +23,15 @@ * SOFTWARE. */ -/* For bt_message, bt_clock_value */ +/* For bt_message, bt_clock_snapshot */ #include #ifdef __cplusplus extern "C" { #endif -extern const bt_clock_value * -bt_message_inactivity_borrow_default_clock_value_const( +extern const bt_clock_snapshot * +bt_message_inactivity_borrow_default_clock_snapshot_const( const bt_message *msg); #ifdef __cplusplus diff --git a/include/babeltrace/graph/message-inactivity-internal.h b/include/babeltrace/graph/message-inactivity-internal.h index b0523cad..5ac0f55e 100644 --- a/include/babeltrace/graph/message-inactivity-internal.h +++ b/include/babeltrace/graph/message-inactivity-internal.h @@ -24,12 +24,12 @@ */ #include -#include +#include #include struct bt_message_inactivity { struct bt_message parent; - struct bt_clock_value *default_cv; + struct bt_clock_snapshot *default_cs; }; #endif /* BABELTRACE_GRAPH_MESSAGE_INACTIVITY_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-inactivity.h b/include/babeltrace/graph/message-inactivity.h index 8425d57b..f958eb66 100644 --- a/include/babeltrace/graph/message-inactivity.h +++ b/include/babeltrace/graph/message-inactivity.h @@ -37,7 +37,7 @@ bt_message *bt_message_inactivity_create( bt_self_message_iterator *message_iterator, bt_clock_class *default_clock_class); -extern void bt_message_inactivity_set_default_clock_value( +extern void bt_message_inactivity_set_default_clock_snapshot( bt_message *msg, uint64_t raw_value); #ifdef __cplusplus diff --git a/include/babeltrace/graph/message-stream-const.h b/include/babeltrace/graph/message-stream-const.h index 9c050e91..f1c2c2ec 100644 --- a/include/babeltrace/graph/message-stream-const.h +++ b/include/babeltrace/graph/message-stream-const.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -/* For bt_message, bt_clock_value, bt_stream */ +/* For bt_message, bt_clock_snapshot, bt_stream */ #include #ifdef __cplusplus @@ -34,15 +34,15 @@ extern "C" { extern const bt_stream *bt_message_stream_beginning_borrow_stream_const( const bt_message *message); -extern const bt_clock_value * -bt_message_stream_beginning_borrow_default_clock_value_const( +extern const bt_clock_snapshot * +bt_message_stream_beginning_borrow_default_clock_snapshot_const( const bt_message *msg); extern const bt_stream *bt_message_stream_end_borrow_stream_const( const bt_message *message); -extern const bt_clock_value * -bt_message_stream_end_borrow_default_clock_value_const( +extern const bt_clock_snapshot * +bt_message_stream_end_borrow_default_clock_snapshot_const( const bt_message *msg); #ifdef __cplusplus diff --git a/include/babeltrace/graph/message-stream-internal.h b/include/babeltrace/graph/message-stream-internal.h index b9601b4f..3752c109 100644 --- a/include/babeltrace/graph/message-stream-internal.h +++ b/include/babeltrace/graph/message-stream-internal.h @@ -27,19 +27,19 @@ #include #include #include -#include +#include #include struct bt_message_stream_beginning { struct bt_message parent; struct bt_stream *stream; - struct bt_clock_value *default_cv; + struct bt_clock_snapshot *default_cs; }; struct bt_message_stream_end { struct bt_message parent; struct bt_stream *stream; - struct bt_clock_value *default_cv; + struct bt_clock_snapshot *default_cs; }; #endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-stream.h b/include/babeltrace/graph/message-stream.h index f025396e..e810a661 100644 --- a/include/babeltrace/graph/message-stream.h +++ b/include/babeltrace/graph/message-stream.h @@ -44,13 +44,13 @@ bt_message *bt_message_stream_end_create( extern bt_stream *bt_message_stream_beginning_borrow_stream( bt_message *message); -extern void bt_message_stream_beginning_set_default_clock_value( +extern void bt_message_stream_beginning_set_default_clock_snapshot( bt_message *msg, uint64_t value_cycles); extern bt_stream *bt_message_stream_end_borrow_stream( bt_message *message); -extern void bt_message_stream_end_set_default_clock_value( +extern void bt_message_stream_end_set_default_clock_snapshot( bt_message *msg, uint64_t value_cycles); #ifdef __cplusplus diff --git a/include/babeltrace/lib-logging-internal.h b/include/babeltrace/lib-logging-internal.h index 5c3fad42..74d1cc09 100644 --- a/include/babeltrace/lib-logging-internal.h +++ b/include/babeltrace/lib-logging-internal.h @@ -115,7 +115,7 @@ int bt_lib_log_level; * Clock class. The parameter type is `struct bt_clock_class *`. * * `k`: - * Clock value. The parameter type is `struct bt_clock_value *`. + * Clock snapshot. The parameter type is `struct bt_clock_snapshot *`. * * `v`: * Value. The parameter type is `struct bt_value *`. diff --git a/include/babeltrace/trace-ir/clock-class-internal.h b/include/babeltrace/trace-ir/clock-class-internal.h index a2fcc303..236d70b4 100644 --- a/include/babeltrace/trace-ir/clock-class-internal.h +++ b/include/babeltrace/trace-ir/clock-class-internal.h @@ -73,7 +73,7 @@ struct bt_clock_class { * base offset in nanoseconds including both `offset_seconds` * and `offset_cycles` above in the result. It is used to * accelerate future calls to - * bt_clock_value_get_ns_from_origin() and + * bt_clock_snapshot_get_ns_from_origin() and * bt_clock_class_cycles_to_ns_from_origin(). * * `overflows` is true if the base offset cannot be computed @@ -84,8 +84,8 @@ struct bt_clock_class { bool overflows; } base_offset; - /* Pool of `struct bt_clock_value *` */ - struct bt_object_pool cv_pool; + /* Pool of `struct bt_clock_snapshot *` */ + struct bt_object_pool cs_pool; bool frozen; }; diff --git a/include/babeltrace/trace-ir/clock-value-const.h b/include/babeltrace/trace-ir/clock-snapshot-const.h similarity index 71% rename from include/babeltrace/trace-ir/clock-value-const.h rename to include/babeltrace/trace-ir/clock-snapshot-const.h index 53ed627b..e0b0e392 100644 --- a/include/babeltrace/trace-ir/clock-value-const.h +++ b/include/babeltrace/trace-ir/clock-snapshot-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_TRACE_IR_CLOCK_VALUE_CONST_H -#define BABELTRACE_TRACE_IR_CLOCK_VALUE_CONST_H +#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H +#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -29,30 +29,30 @@ #include -/* For bt_clock_class, bt_clock_value */ +/* For bt_clock_class, bt_clock_snapshot */ #include #ifdef __cplusplus extern "C" { #endif -enum bt_clock_value_status { - BT_CLOCK_VALUE_STATUS_KNOWN, - BT_CLOCK_VALUE_STATUS_UNKNOWN, +enum bt_clock_snapshot_status { + BT_CLOCK_SNAPSHOT_STATUS_KNOWN, + BT_CLOCK_SNAPSHOT_STATUS_UNKNOWN, }; -extern const bt_clock_class *bt_clock_value_borrow_clock_class_const( - const bt_clock_value *clock_value); +extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( + const bt_clock_snapshot *clock_snapshot); -extern uint64_t bt_clock_value_get_value( - const bt_clock_value *clock_value); +extern uint64_t bt_clock_snapshot_get_value( + const bt_clock_snapshot *clock_snapshot); -extern int bt_clock_value_get_ns_from_origin( - const bt_clock_value *clock_value, +extern int bt_clock_snapshot_get_ns_from_origin( + const bt_clock_snapshot *clock_snapshot, int64_t *ns_from_origin); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_TRACE_IR_CLOCK_VALUE_CONST_H */ +#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H */ diff --git a/include/babeltrace/trace-ir/clock-value-internal.h b/include/babeltrace/trace-ir/clock-snapshot-internal.h similarity index 55% rename from include/babeltrace/trace-ir/clock-value-internal.h rename to include/babeltrace/trace-ir/clock-snapshot-internal.h index b3979048..3ba604ee 100644 --- a/include/babeltrace/trace-ir/clock-value-internal.h +++ b/include/babeltrace/trace-ir/clock-snapshot-internal.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_TRACE_IR_CLOCK_VALUE_INTERNAL_H -#define BABELTRACE_TRACE_IR_CLOCK_VALUE_INTERNAL_H +#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H +#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H /* * Copyright 2017-2018 Philippe Proulx @@ -32,7 +32,7 @@ struct bt_clock_class; -struct bt_clock_value { +struct bt_clock_snapshot { struct bt_object base; struct bt_clock_class *clock_class; uint64_t value_cycles; @@ -42,61 +42,61 @@ struct bt_clock_value { }; static inline -void bt_clock_value_set(struct bt_clock_value *clock_value) +void bt_clock_snapshot_set(struct bt_clock_snapshot *clock_snapshot) { - BT_ASSERT(clock_value); - clock_value->is_set = true; + BT_ASSERT(clock_snapshot); + clock_snapshot->is_set = true; } static inline -void bt_clock_value_reset(struct bt_clock_value *clock_value) +void bt_clock_snapshot_reset(struct bt_clock_snapshot *clock_snapshot) { - BT_ASSERT(clock_value); - clock_value->is_set = false; + BT_ASSERT(clock_snapshot); + clock_snapshot->is_set = false; } static inline -void set_ns_from_origin(struct bt_clock_value *clock_value) +void set_ns_from_origin(struct bt_clock_snapshot *clock_snapshot) { - if (bt_util_ns_from_origin(clock_value->clock_class, clock_value->value_cycles, - &clock_value->ns_from_origin)) { - clock_value->ns_from_origin_overflows = true; + if (bt_util_ns_from_origin(clock_snapshot->clock_class, clock_snapshot->value_cycles, + &clock_snapshot->ns_from_origin)) { + clock_snapshot->ns_from_origin_overflows = true; } } static inline -void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value, +void bt_clock_snapshot_set_raw_value(struct bt_clock_snapshot *clock_snapshot, uint64_t cycles) { - BT_ASSERT(clock_value); - clock_value->value_cycles = cycles; - set_ns_from_origin(clock_value); - bt_clock_value_set(clock_value); + BT_ASSERT(clock_snapshot); + clock_snapshot->value_cycles = cycles; + set_ns_from_origin(clock_snapshot); + bt_clock_snapshot_set(clock_snapshot); } static inline -void bt_clock_value_set_value_inline(struct bt_clock_value *clock_value, +void bt_clock_snapshot_set_value_inline(struct bt_clock_snapshot *clock_snapshot, uint64_t raw_value) { - bt_clock_value_set_raw_value(clock_value, raw_value); + bt_clock_snapshot_set_raw_value(clock_snapshot, raw_value); } BT_HIDDEN -void bt_clock_value_destroy(struct bt_clock_value *clock_value); +void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot); BT_HIDDEN -struct bt_clock_value *bt_clock_value_new(struct bt_clock_class *clock_class); +struct bt_clock_snapshot *bt_clock_snapshot_new(struct bt_clock_class *clock_class); BT_HIDDEN -struct bt_clock_value *bt_clock_value_create( +struct bt_clock_snapshot *bt_clock_snapshot_create( struct bt_clock_class *clock_class); BT_HIDDEN -void bt_clock_value_recycle(struct bt_clock_value *clock_value); +void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot); BT_HIDDEN -void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value, +void bt_clock_snapshot_set_raw_value(struct bt_clock_snapshot *clock_snapshot, uint64_t cycles); -#endif /* BABELTRACE_TRACE_IR_CLOCK_VALUE_INTERNAL_H */ +#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H */ diff --git a/include/babeltrace/trace-ir/clock-snapshot-set-internal.h b/include/babeltrace/trace-ir/clock-snapshot-set-internal.h new file mode 100644 index 00000000..69412ca0 --- /dev/null +++ b/include/babeltrace/trace-ir/clock-snapshot-set-internal.h @@ -0,0 +1,159 @@ +#ifndef BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H +#define BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H + +/* + * Copyright 2018 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include + +struct bt_clock_snapshot_set { + /* Unique objects owned by this */ + GPtrArray *clock_snapshots; + + /* Weak; points to one of the clock snapshots above */ + struct bt_clock_snapshot *default_cs; +}; + +static inline +int bt_clock_snapshot_set_initialize(struct bt_clock_snapshot_set *cs_set) +{ + int ret = 0; + + cs_set->clock_snapshots = g_ptr_array_sized_new(1); + if (!cs_set->clock_snapshots) { +#ifdef BT_LOGE_STR + BT_LOGE_STR("Failed to allocate one GPtrArray."); +#endif + + ret = -1; + goto end; + } + + cs_set->default_cs = NULL; + +end: + return ret; +} + +static inline +void bt_clock_snapshot_set_reset(struct bt_clock_snapshot_set *cs_set) +{ + uint64_t i; + + BT_ASSERT(cs_set); + BT_ASSERT(cs_set->clock_snapshots); + + for (i = 0; i < cs_set->clock_snapshots->len; i++) { + struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i]; + + BT_ASSERT(cs); + bt_clock_snapshot_reset(cs); + } + + cs_set->default_cs = NULL; +} + +static inline +void bt_clock_snapshot_set_finalize(struct bt_clock_snapshot_set *cs_set) +{ + uint64_t i; + + BT_ASSERT(cs_set); + + if (cs_set->clock_snapshots) { + for (i = 0; i < cs_set->clock_snapshots->len; i++) { + struct bt_clock_snapshot *cs = + cs_set->clock_snapshots->pdata[i]; + + BT_ASSERT(cs); + bt_clock_snapshot_recycle(cs); + } + + g_ptr_array_free(cs_set->clock_snapshots, TRUE); + } + + cs_set->default_cs = NULL; +} + +static inline +int bt_clock_snapshot_set_set_clock_snapshot(struct bt_clock_snapshot_set *cs_set, + struct bt_clock_class *cc, uint64_t raw_value) +{ + int ret = 0; + struct bt_clock_snapshot *clock_snapshot = NULL; + uint64_t i; + + BT_ASSERT(cs_set); + BT_ASSERT(cc); + + /* + * Check if we already have a value for this clock class. + * + * TODO: When we have many clock classes, make this more + * efficient. + */ + for (i = 0; i < cs_set->clock_snapshots->len; i++) { + struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i]; + + BT_ASSERT(cs); + + if (cs->clock_class == cc) { + clock_snapshot = cs; + break; + } + } + + if (!clock_snapshot) { + clock_snapshot = bt_clock_snapshot_create(cc); + if (!clock_snapshot) { +#ifdef BT_LIB_LOGE + BT_LIB_LOGE("Cannot create a clock snapshot from a clock class: " + "%![cc-]+K", cc); +#endif + + ret = -1; + goto end; + } + + g_ptr_array_add(cs_set->clock_snapshots, clock_snapshot); + } + + bt_clock_snapshot_set_value_inline(clock_snapshot, raw_value); + +end: + return ret; +} + +static inline +void bt_clock_snapshot_set_set_default_clock_snapshot( + struct bt_clock_snapshot_set *cs_set, uint64_t raw_value) +{ + BT_ASSERT(cs_set); + BT_ASSERT(cs_set->default_cs); + bt_clock_snapshot_set_value_inline(cs_set->default_cs, raw_value); +} + +#endif /* BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H */ diff --git a/include/babeltrace/trace-ir/clock-value-set-internal.h b/include/babeltrace/trace-ir/clock-value-set-internal.h deleted file mode 100644 index 5c7e7bd3..00000000 --- a/include/babeltrace/trace-ir/clock-value-set-internal.h +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef BABELTRACE_GRAPH_CLOCK_VALUE_SET_H -#define BABELTRACE_GRAPH_CLOCK_VALUE_SET_H - -/* - * Copyright 2018 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include - -struct bt_clock_value_set { - /* Unique objects owned by this */ - GPtrArray *clock_values; - - /* Weak; points to one of the clock values above */ - struct bt_clock_value *default_cv; -}; - -static inline -int bt_clock_value_set_initialize(struct bt_clock_value_set *cv_set) -{ - int ret = 0; - - cv_set->clock_values = g_ptr_array_sized_new(1); - if (!cv_set->clock_values) { -#ifdef BT_LOGE_STR - BT_LOGE_STR("Failed to allocate one GPtrArray."); -#endif - - ret = -1; - goto end; - } - - cv_set->default_cv = NULL; - -end: - return ret; -} - -static inline -void bt_clock_value_set_reset(struct bt_clock_value_set *cv_set) -{ - uint64_t i; - - BT_ASSERT(cv_set); - BT_ASSERT(cv_set->clock_values); - - for (i = 0; i < cv_set->clock_values->len; i++) { - struct bt_clock_value *cv = cv_set->clock_values->pdata[i]; - - BT_ASSERT(cv); - bt_clock_value_reset(cv); - } - - cv_set->default_cv = NULL; -} - -static inline -void bt_clock_value_set_finalize(struct bt_clock_value_set *cv_set) -{ - uint64_t i; - - BT_ASSERT(cv_set); - - if (cv_set->clock_values) { - for (i = 0; i < cv_set->clock_values->len; i++) { - struct bt_clock_value *cv = - cv_set->clock_values->pdata[i]; - - BT_ASSERT(cv); - bt_clock_value_recycle(cv); - } - - g_ptr_array_free(cv_set->clock_values, TRUE); - } - - cv_set->default_cv = NULL; -} - -static inline -int bt_clock_value_set_set_clock_value(struct bt_clock_value_set *cv_set, - struct bt_clock_class *cc, uint64_t raw_value) -{ - int ret = 0; - struct bt_clock_value *clock_value = NULL; - uint64_t i; - - BT_ASSERT(cv_set); - BT_ASSERT(cc); - - /* - * Check if we already have a value for this clock class. - * - * TODO: When we have many clock classes, make this more - * efficient. - */ - for (i = 0; i < cv_set->clock_values->len; i++) { - struct bt_clock_value *cv = cv_set->clock_values->pdata[i]; - - BT_ASSERT(cv); - - if (cv->clock_class == cc) { - clock_value = cv; - break; - } - } - - if (!clock_value) { - clock_value = bt_clock_value_create(cc); - if (!clock_value) { -#ifdef BT_LIB_LOGE - BT_LIB_LOGE("Cannot create a clock value from a clock class: " - "%![cc-]+K", cc); -#endif - - ret = -1; - goto end; - } - - g_ptr_array_add(cv_set->clock_values, clock_value); - } - - bt_clock_value_set_value_inline(clock_value, raw_value); - -end: - return ret; -} - -static inline -void bt_clock_value_set_set_default_clock_value( - struct bt_clock_value_set *cv_set, uint64_t raw_value) -{ - BT_ASSERT(cv_set); - BT_ASSERT(cv_set->default_cv); - bt_clock_value_set_value_inline(cv_set->default_cv, raw_value); -} - -#endif /* BABELTRACE_GRAPH_CLOCK_VALUE_SET_H */ diff --git a/include/babeltrace/trace-ir/event-const.h b/include/babeltrace/trace-ir/event-const.h index 87877e78..9aa4e692 100644 --- a/include/babeltrace/trace-ir/event-const.h +++ b/include/babeltrace/trace-ir/event-const.h @@ -27,10 +27,10 @@ * http://www.efficios.com/ctf */ -/* For enum bt_clock_value_status */ -#include +/* For enum bt_clock_snapshot_status */ +#include -/* For bt_event, bt_clock_value, bt_event_class, bt_field, bt_packet */ +/* For bt_event, bt_clock_snapshot, bt_event_class, bt_field, bt_packet */ #include #ifdef __cplusplus @@ -58,9 +58,9 @@ extern const bt_field *bt_event_borrow_specific_context_field_const( extern const bt_field *bt_event_borrow_payload_field_const( const bt_event *event); -extern enum bt_clock_value_status bt_event_borrow_default_clock_value_const( +extern enum bt_clock_snapshot_status bt_event_borrow_default_clock_snapshot_const( const bt_event *event, - const bt_clock_value **clock_value); + const bt_clock_snapshot **clock_snapshot); #ifdef __cplusplus } diff --git a/include/babeltrace/trace-ir/event-internal.h b/include/babeltrace/trace-ir/event-internal.h index 1753f964..8e84596a 100644 --- a/include/babeltrace/trace-ir/event-internal.h +++ b/include/babeltrace/trace-ir/event-internal.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ struct bt_event { struct bt_field *common_context_field; struct bt_field *specific_context_field; struct bt_field *payload_field; - struct bt_clock_value *default_cv; + struct bt_clock_snapshot *default_cs; bool frozen; }; @@ -128,8 +128,8 @@ void bt_event_reset(struct bt_event *event) BT_LIB_LOGD("Resetting event: %!+e", event); bt_event_set_is_frozen(event, false); - if (event->default_cv) { - bt_clock_value_reset(event->default_cv); + if (event->default_cs) { + bt_clock_snapshot_reset(event->default_cs); } bt_object_put_no_null_check(&event->packet->base); diff --git a/include/babeltrace/trace-ir/event.h b/include/babeltrace/trace-ir/event.h index 4440b145..2f432e71 100644 --- a/include/babeltrace/trace-ir/event.h +++ b/include/babeltrace/trace-ir/event.h @@ -53,7 +53,7 @@ bt_event_borrow_specific_context_field(bt_event *event); extern bt_field *bt_event_borrow_payload_field(bt_event *event); -extern void bt_event_set_default_clock_value(bt_event *event, +extern void bt_event_set_default_clock_snapshot(bt_event *event, uint64_t value_cycles); #ifdef __cplusplus diff --git a/include/babeltrace/trace-ir/packet-const.h b/include/babeltrace/trace-ir/packet-const.h index 62ee8d1e..877def81 100644 --- a/include/babeltrace/trace-ir/packet-const.h +++ b/include/babeltrace/trace-ir/packet-const.h @@ -31,12 +31,12 @@ /* For enum bt_property_availability */ #include -/* For enum bt_clock_value_status */ -#include +/* For enum bt_clock_snapshot_status */ +#include /* * For bt_packet, bt_packet_header_field, bt_packet_context_field, - * bt_stream, bt_clock_value + * bt_stream, bt_clock_snapshot */ #include @@ -56,14 +56,14 @@ const bt_field *bt_packet_borrow_context_field_const( const bt_packet *packet); extern -enum bt_clock_value_status bt_packet_borrow_default_beginning_clock_value_const( +enum bt_clock_snapshot_status bt_packet_borrow_default_beginning_clock_snapshot_const( const bt_packet *packet, - const bt_clock_value **clock_value); + const bt_clock_snapshot **clock_snapshot); extern -enum bt_clock_value_status bt_packet_borrow_default_end_clock_valeu_const( +enum bt_clock_snapshot_status bt_packet_borrow_default_end_clock_valeu_const( const bt_packet *packet, - const bt_clock_value **clock_value); + const bt_clock_snapshot **clock_snapshot); extern enum bt_property_availability bt_packet_get_discarded_event_counter_snapshot( diff --git a/include/babeltrace/trace-ir/packet-internal.h b/include/babeltrace/trace-ir/packet-internal.h index 2414a6af..c9431816 100644 --- a/include/babeltrace/trace-ir/packet-internal.h +++ b/include/babeltrace/trace-ir/packet-internal.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -39,8 +39,8 @@ struct bt_packet { struct bt_field_wrapper *header_field; struct bt_field_wrapper *context_field; struct bt_stream *stream; - struct bt_clock_value *default_beginning_cv; - struct bt_clock_value *default_end_cv; + struct bt_clock_snapshot *default_beginning_cs; + struct bt_clock_snapshot *default_end_cs; struct bt_property_uint discarded_event_counter_snapshot; struct bt_property_uint packet_counter_snapshot; bool frozen; diff --git a/include/babeltrace/trace-ir/packet.h b/include/babeltrace/trace-ir/packet.h index b485e9bc..2b1d9b06 100644 --- a/include/babeltrace/trace-ir/packet.h +++ b/include/babeltrace/trace-ir/packet.h @@ -54,11 +54,11 @@ int bt_packet_move_context_field(bt_packet *packet, bt_packet_context_field *context); extern -void bt_packet_set_default_beginning_clock_value(bt_packet *packet, +void bt_packet_set_default_beginning_clock_snapshot(bt_packet *packet, uint64_t value_cycles); extern -void bt_packet_set_default_end_clock_value(bt_packet *packet, +void bt_packet_set_default_end_clock_snapshot(bt_packet *packet, uint64_t value_cycles); extern diff --git a/include/babeltrace/trace-ir/stream-class-const.h b/include/babeltrace/trace-ir/stream-class-const.h index d954c057..476a40eb 100644 --- a/include/babeltrace/trace-ir/stream-class-const.h +++ b/include/babeltrace/trace-ir/stream-class-const.h @@ -90,10 +90,10 @@ extern bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot( extern bt_bool bt_stream_class_packets_have_packet_counter_snapshot( const bt_stream_class *stream_class); -extern bt_bool bt_stream_class_packets_have_default_beginning_clock_value( +extern bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot( const bt_stream_class *stream_class); -extern bt_bool bt_stream_class_packets_have_default_end_clock_value( +extern bt_bool bt_stream_class_packets_have_default_end_clock_snapshot( const bt_stream_class *stream_class); extern void bt_stream_class_get_ref(const bt_stream_class *stream_class); diff --git a/include/babeltrace/trace-ir/stream-class-internal.h b/include/babeltrace/trace-ir/stream-class-internal.h index 4d45e8e4..dcb50b62 100644 --- a/include/babeltrace/trace-ir/stream-class-internal.h +++ b/include/babeltrace/trace-ir/stream-class-internal.h @@ -50,8 +50,8 @@ struct bt_stream_class { bool assigns_automatic_stream_id; bool packets_have_discarded_event_counter_snapshot; bool packets_have_packet_counter_snapshot; - bool packets_have_default_beginning_cv; - bool packets_have_default_end_cv; + bool packets_have_default_beginning_cs; + bool packets_have_default_end_cs; struct bt_field_class *packet_context_fc; struct bt_field_class *event_header_fc; struct bt_field_class *event_common_context_fc; diff --git a/include/babeltrace/trace-ir/stream-class.h b/include/babeltrace/trace-ir/stream-class.h index aec3be34..074d4584 100644 --- a/include/babeltrace/trace-ir/stream-class.h +++ b/include/babeltrace/trace-ir/stream-class.h @@ -94,11 +94,11 @@ bt_stream_class_set_packets_have_packet_counter_snapshot( bt_stream_class *stream_class, bt_bool value); extern void -bt_stream_class_set_packets_have_default_beginning_clock_value( +bt_stream_class_set_packets_have_default_beginning_clock_snapshot( bt_stream_class *stream_class, bt_bool value); extern void -bt_stream_class_set_packets_have_default_end_clock_value( +bt_stream_class_set_packets_have_default_end_clock_snapshot( bt_stream_class *stream_class, bt_bool value); #ifdef __cplusplus diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index bf4c72d9..39f3f423 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -77,7 +77,7 @@ typedef int bt_bool; typedef const uint8_t *bt_uuid; typedef struct bt_clock_class bt_clock_class; -typedef struct bt_clock_value bt_clock_value; +typedef struct bt_clock_snapshot bt_clock_snapshot; typedef struct bt_component bt_component; typedef struct bt_component_class bt_component_class; typedef struct bt_component_class_filter bt_component_class_filter; diff --git a/lib/graph/message/discarded-events.c b/lib/graph/message/discarded-events.c index e594fe1d..cb5d1a68 100644 --- a/lib/graph/message/discarded-events.c +++ b/lib/graph/message/discarded-events.c @@ -25,19 +25,19 @@ #include #include -struct bt_clock_value * -bt_message_discarded_events_borrow_begin_clock_value( +struct bt_clock_snapshot * +bt_message_discarded_events_borrow_begin_clock_snapshot( struct bt_message *message) { - return bt_message_discarded_elements_borrow_begin_clock_value( + return bt_message_discarded_elements_borrow_begin_clock_snapshot( BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } -struct bt_clock_value * -bt_message_discarded_events_borrow_end_clock_value( +struct bt_clock_snapshot * +bt_message_discarded_events_borrow_end_clock_snapshot( struct bt_message *message) { - return bt_message_discarded_elements_borrow_end_clock_value( + return bt_message_discarded_elements_borrow_end_clock_snapshot( BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } diff --git a/lib/graph/message/discarded-packets.c b/lib/graph/message/discarded-packets.c index 953ba04c..73ae909a 100644 --- a/lib/graph/message/discarded-packets.c +++ b/lib/graph/message/discarded-packets.c @@ -25,19 +25,19 @@ #include #include -struct bt_clock_value * -bt_message_discarded_packets_borrow_begin_clock_value( +struct bt_clock_snapshot * +bt_message_discarded_packets_borrow_begin_clock_snapshot( struct bt_message *message) { - return bt_message_discarded_elements_borrow_begin_clock_value( + return bt_message_discarded_elements_borrow_begin_clock_snapshot( BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } -struct bt_clock_value * -bt_message_discarded_packets_borrow_end_clock_value( +struct bt_clock_snapshot * +bt_message_discarded_packets_borrow_end_clock_snapshot( struct bt_message *message) { - return bt_message_discarded_elements_borrow_end_clock_value( + return bt_message_discarded_elements_borrow_end_clock_snapshot( BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } diff --git a/lib/graph/message/inactivity.c b/lib/graph/message/inactivity.c index 0b7dff90..f61f1fdc 100644 --- a/lib/graph/message/inactivity.c +++ b/lib/graph/message/inactivity.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,8 +41,8 @@ void bt_message_inactivity_destroy(struct bt_object *obj) BT_LIB_LOGD("Destroying inactivity message: %!+n", message); - if (message->default_cv) { - bt_clock_value_recycle(message->default_cv); + if (message->default_cs) { + bt_clock_snapshot_recycle(message->default_cs); } g_free(message); @@ -71,8 +71,8 @@ struct bt_message *bt_message_inactivity_create( BT_MESSAGE_TYPE_INACTIVITY, bt_message_inactivity_destroy, NULL); ret_msg = &message->parent; - message->default_cv = bt_clock_value_create(default_clock_class); - if (!message->default_cv) { + message->default_cs = bt_clock_snapshot_create(default_clock_class); + if (!message->default_cs) { goto error; } @@ -86,7 +86,7 @@ end: return (void *) ret_msg; } -void bt_message_inactivity_set_default_clock_value( +void bt_message_inactivity_set_default_clock_snapshot( struct bt_message *msg, uint64_t value_cycles) { struct bt_message_inactivity *inactivity = (void *) msg; @@ -94,18 +94,18 @@ void bt_message_inactivity_set_default_clock_value( BT_ASSERT_PRE_NON_NULL(msg, "Message"); BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY); BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); - bt_clock_value_set_value_inline(inactivity->default_cv, value_cycles); - BT_LIB_LOGV("Set inactivity message's default clock value: " + bt_clock_snapshot_set_value_inline(inactivity->default_cs, value_cycles); + BT_LIB_LOGV("Set inactivity message's default clock snapshot: " "%![msg-]+n, value=%" PRIu64, msg, value_cycles); } -const struct bt_clock_value * -bt_message_inactivity_borrow_default_clock_value_const( +const struct bt_clock_snapshot * +bt_message_inactivity_borrow_default_clock_snapshot_const( const struct bt_message *msg) { struct bt_message_inactivity *inactivity = (void *) msg; BT_ASSERT_PRE_NON_NULL(msg, "Message"); BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY); - return inactivity->default_cv; + return inactivity->default_cs; } diff --git a/lib/graph/message/stream.c b/lib/graph/message/stream.c index 46039696..d2483b4b 100644 --- a/lib/graph/message/stream.c +++ b/lib/graph/message/stream.c @@ -46,9 +46,9 @@ void bt_message_stream_end_destroy(struct bt_object *obj) BT_LIB_LOGD("Putting stream: %!+s", message->stream); BT_OBJECT_PUT_REF_AND_RESET(message->stream); - if (message->default_cv) { - bt_clock_value_recycle(message->default_cv); - message->default_cv = NULL; + if (message->default_cs) { + bt_clock_snapshot_recycle(message->default_cs); + message->default_cs = NULL; } g_free(message); @@ -106,7 +106,7 @@ const struct bt_stream *bt_message_stream_end_borrow_stream_const( (void *) message); } -void bt_message_stream_end_set_default_clock_value( +void bt_message_stream_end_set_default_clock_snapshot( struct bt_message *msg, uint64_t value_cycles) { struct bt_message_stream_end *se_msg = (void *) msg; @@ -119,22 +119,22 @@ void bt_message_stream_end_set_default_clock_value( "%![msg-]+n, %![sc-]+S", msg, se_msg->stream->class); /* TODO: have the object already created */ - se_msg->default_cv = bt_clock_value_create( + se_msg->default_cs = bt_clock_snapshot_create( se_msg->stream->class->default_clock_class); - BT_ASSERT(se_msg->default_cv); - bt_clock_value_set_value_inline(se_msg->default_cv, value_cycles); - BT_LIB_LOGV("Set message's default clock value: %![msg-]+n, " + BT_ASSERT(se_msg->default_cs); + bt_clock_snapshot_set_value_inline(se_msg->default_cs, value_cycles); + BT_LIB_LOGV("Set message's default clock snapshot: %![msg-]+n, " "value=%" PRIu64, value_cycles); } -struct bt_clock_value *bt_message_stream_end_borrow_default_clock_value( +struct bt_clock_snapshot *bt_message_stream_end_borrow_default_clock_snapshot( struct bt_message *msg) { struct bt_message_stream_end *stream_end = (void *) msg; BT_ASSERT_PRE_NON_NULL(msg, "Message"); BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END); - return stream_end->default_cv; + return stream_end->default_cs; } static @@ -148,9 +148,9 @@ void bt_message_stream_beginning_destroy(struct bt_object *obj) BT_LIB_LOGD("Putting stream: %!+s", message->stream); BT_OBJECT_PUT_REF_AND_RESET(message->stream); - if (message->default_cv) { - bt_clock_value_recycle(message->default_cv); - message->default_cv = NULL; + if (message->default_cs) { + bt_clock_snapshot_recycle(message->default_cs); + message->default_cs = NULL; } g_free(message); @@ -207,7 +207,7 @@ const struct bt_stream *bt_message_stream_beginning_borrow_stream_const( (void *) message); } -void bt_message_stream_beginning_set_default_clock_value( +void bt_message_stream_beginning_set_default_clock_snapshot( struct bt_message *msg, uint64_t value_cycles) { @@ -221,20 +221,20 @@ void bt_message_stream_beginning_set_default_clock_value( "%![msg-]+n, %![sc-]+S", msg, sb_msg->stream->class); /* TODO: have the object already created */ - sb_msg->default_cv = bt_clock_value_create( + sb_msg->default_cs = bt_clock_snapshot_create( sb_msg->stream->class->default_clock_class); - BT_ASSERT(sb_msg->default_cv); - bt_clock_value_set_value_inline(sb_msg->default_cv, value_cycles); - BT_LIB_LOGV("Set message's default clock value: %![msg-]+n, " + BT_ASSERT(sb_msg->default_cs); + bt_clock_snapshot_set_value_inline(sb_msg->default_cs, value_cycles); + BT_LIB_LOGV("Set message's default clock snapshot: %![msg-]+n, " "value=%" PRIu64, value_cycles); } -struct bt_clock_value *bt_message_stream_beginning_borrow_default_clock_value( +struct bt_clock_snapshot *bt_message_stream_beginning_borrow_default_clock_snapshot( struct bt_message *msg) { struct bt_message_stream_beginning *stream_begin = (void *) msg; BT_ASSERT_PRE_NON_NULL(msg, "Message"); BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_BEGINNING); - return stream_begin->default_cv; + return stream_begin->default_cs; } diff --git a/lib/lib-logging.c b/lib/lib-logging.c index d418310f..403c2a17 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include #include @@ -113,8 +113,8 @@ static inline void format_port(char **buf_ch, bool extended, static inline void format_connection(char **buf_ch, bool extended, const char *prefix, const struct bt_connection *connection); -static inline void format_clock_value(char **buf_ch, bool extended, - const char *prefix, const struct bt_clock_value *clock_value); +static inline void format_clock_snapshot(char **buf_ch, bool extended, + const char *prefix, const struct bt_clock_snapshot *clock_snapshot); static inline void format_field_path(char **buf_ch, bool extended, const char *prefix, const struct bt_field_path *field_path); @@ -533,14 +533,14 @@ static inline void format_stream_class(char **buf_ch, bool extended, BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, " "%spackets-have-discarded-ev-counter-snapshot=%d, " "%spackets-have-packet-counter-snapshot=%d, " - "%spackets-have-default-begin-cv=%d, " - "%spackets-have-default-end-cv=%d", + "%spackets-have-default-begin-cs=%d, " + "%spackets-have-default-end-cs=%d", PRFIELD(stream_class->assigns_automatic_event_class_id), PRFIELD(stream_class->assigns_automatic_stream_id), PRFIELD(stream_class->packets_have_discarded_event_counter_snapshot), PRFIELD(stream_class->packets_have_packet_counter_snapshot), - PRFIELD(stream_class->packets_have_default_beginning_cv), - PRFIELD(stream_class->packets_have_default_end_cv)); + PRFIELD(stream_class->packets_have_default_beginning_cs), + PRFIELD(stream_class->packets_have_default_end_cs)); BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); SET_TMP_PREFIX("trace-class-"); format_trace_class(buf_ch, false, tmp_prefix, trace_class); @@ -671,16 +671,16 @@ static inline void format_packet(char **buf_ch, bool extended, return; } - if (packet->default_beginning_cv) { - SET_TMP_PREFIX("default-begin-cv-"); - format_clock_value(buf_ch, true, tmp_prefix, - packet->default_beginning_cv); + if (packet->default_beginning_cs) { + SET_TMP_PREFIX("default-begin-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + packet->default_beginning_cs); } - if (packet->default_end_cv) { - SET_TMP_PREFIX("default-end-cv-"); - format_clock_value(buf_ch, true, tmp_prefix, - packet->default_end_cv); + if (packet->default_end_cs) { + SET_TMP_PREFIX("default-end-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + packet->default_end_cs); } if (packet->discarded_event_counter_snapshot.base.avail) { @@ -755,10 +755,10 @@ static inline void format_event(char **buf_ch, bool extended, } } - if (event->default_cv) { - SET_TMP_PREFIX("default-cv-"); - format_clock_value(buf_ch, true, tmp_prefix, - event->default_cv); + if (event->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + event->default_cs); } packet = bt_event_borrow_packet_const(event); @@ -813,30 +813,30 @@ static inline void format_clock_class(char **buf_ch, bool extended, PRFIELD(clock_class->is_absolute), PRFIELD(clock_class->base_offset.value_ns)); - SET_TMP_PREFIX("cv-pool-"); - format_object_pool(buf_ch, extended, prefix, &clock_class->cv_pool); + SET_TMP_PREFIX("cs-pool-"); + format_object_pool(buf_ch, extended, prefix, &clock_class->cs_pool); } -static inline void format_clock_value(char **buf_ch, bool extended, - const char *prefix, const struct bt_clock_value *clock_value) +static inline void format_clock_snapshot(char **buf_ch, bool extended, + const char *prefix, const struct bt_clock_snapshot *clock_snapshot) { char tmp_prefix[64]; BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, - PRFIELD(clock_value->value_cycles), - PRFIELD(clock_value->ns_from_origin)); + PRFIELD(clock_snapshot->value_cycles), + PRFIELD(clock_snapshot->ns_from_origin)); if (!extended) { return; } - BUF_APPEND(", %sis-set=%d", PRFIELD(clock_value->is_set)); + BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot->is_set)); - if (clock_value->clock_class) { + if (clock_snapshot->clock_class) { BUF_APPEND(", %sclock-class-addr=%p", - PRFIELD(clock_value->clock_class)); + PRFIELD(clock_snapshot->clock_class)); SET_TMP_PREFIX("clock-class-"); format_clock_class(buf_ch, false, tmp_prefix, - clock_value->clock_class); + clock_snapshot->clock_class); } } @@ -1332,7 +1332,7 @@ static inline void handle_conversion_specifier_bt(void *priv_data, format_clock_class(buf_ch, extended, prefix, obj); break; case 'k': - format_clock_value(buf_ch, extended, prefix, obj); + format_clock_snapshot(buf_ch, extended, prefix, obj); break; case 'v': format_value(buf_ch, extended, prefix, obj); diff --git a/lib/trace-ir/Makefile.am b/lib/trace-ir/Makefile.am index f51103b1..5c35796e 100644 --- a/lib/trace-ir/Makefile.am +++ b/lib/trace-ir/Makefile.am @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libtrace-ir.la libtrace_ir_la_SOURCES = \ attributes.c \ clock-class.c \ - clock-value.c \ + clock-snapshot.c \ event.c \ event-class.c \ event-header-field.c \ diff --git a/lib/trace-ir/clock-class.c b/lib/trace-ir/clock-class.c index 45b47c1e..a2465b41 100644 --- a/lib/trace-ir/clock-class.c +++ b/lib/trace-ir/clock-class.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,15 +58,15 @@ void destroy_clock_class(struct bt_object *obj) clock_class->description.value = NULL; } - bt_object_pool_finalize(&clock_class->cv_pool); + bt_object_pool_finalize(&clock_class->cs_pool); g_free(clock_class); } static -void free_clock_value(struct bt_clock_value *clock_value, +void free_clock_snapshot(struct bt_clock_snapshot *clock_snapshot, struct bt_clock_class *clock_class) { - bt_clock_value_destroy(clock_value); + bt_clock_snapshot_destroy(clock_snapshot); } static inline @@ -133,13 +133,13 @@ struct bt_clock_class *bt_clock_class_create(void) clock_class->frequency = UINT64_C(1000000000); clock_class->is_absolute = BT_TRUE; set_base_offset(clock_class); - ret = bt_object_pool_initialize(&clock_class->cv_pool, - (bt_object_pool_new_object_func) bt_clock_value_new, + ret = bt_object_pool_initialize(&clock_class->cs_pool, + (bt_object_pool_new_object_func) bt_clock_snapshot_new, (bt_object_pool_destroy_object_func) - free_clock_value, + free_clock_snapshot, clock_class); if (ret) { - BT_LOGE("Failed to initialize clock value pool: ret=%d", + BT_LOGE("Failed to initialize clock snapshot pool: ret=%d", ret); goto error; } diff --git a/lib/trace-ir/clock-snapshot.c b/lib/trace-ir/clock-snapshot.c new file mode 100644 index 00000000..7dcf2893 --- /dev/null +++ b/lib/trace-ir/clock-snapshot.c @@ -0,0 +1,173 @@ +/* + * Copyright 2017-2018 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "CLOCK-SNAPSHOT" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BT_HIDDEN +void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot) +{ + BT_LIB_LOGD("Destroying clock snapshot: %!+k", clock_snapshot); + BT_OBJECT_PUT_REF_AND_RESET(clock_snapshot->clock_class); + g_free(clock_snapshot); +} + +BT_HIDDEN +struct bt_clock_snapshot *bt_clock_snapshot_new(struct bt_clock_class *clock_class) +{ + struct bt_clock_snapshot *ret = NULL; + + BT_ASSERT(clock_class); + BT_LIB_LOGD("Creating clock snapshot object: %![cc-]+K=", + clock_class); + ret = g_new0(struct bt_clock_snapshot, 1); + if (!ret) { + BT_LOGE_STR("Failed to allocate one clock snapshot."); + goto end; + } + + bt_object_init_unique(&ret->base); + ret->clock_class = clock_class; + bt_object_get_no_null_check(clock_class); + bt_clock_class_freeze(clock_class); + BT_LIB_LOGD("Created clock snapshot object: %!+k", ret); + +end: + return ret; +} + +BT_HIDDEN +struct bt_clock_snapshot *bt_clock_snapshot_create(struct bt_clock_class *clock_class) +{ + struct bt_clock_snapshot *clock_snapshot = NULL; + + BT_ASSERT(clock_class); + clock_snapshot = bt_object_pool_create_object(&clock_class->cs_pool); + if (!clock_snapshot) { + BT_LIB_LOGE("Cannot allocate one clock snapshot from clock class's clock snapshot pool: " + "%![cc-]+K", clock_class); + goto error; + } + + if (likely(!clock_snapshot->clock_class)) { + clock_snapshot->clock_class = clock_class; + bt_object_get_no_null_check(clock_class); + } + + goto end; + +error: + if (clock_snapshot) { + bt_clock_snapshot_recycle(clock_snapshot); + clock_snapshot = NULL; + } + +end: + return clock_snapshot; +} + +BT_HIDDEN +void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot) +{ + struct bt_clock_class *clock_class; + + BT_ASSERT(clock_snapshot); + BT_LIB_LOGD("Recycling clock snapshot: %!+k", clock_snapshot); + + /* + * Those are the important ordered steps: + * + * 1. Reset the clock snapshot object, but do NOT put its clock + * class's reference. This clock class contains the pool to + * which we're about to recycle this clock snapshot object, + * so we must guarantee its existence thanks to this existing + * reference. + * + * 2. Move the clock class reference to our `clock_class` + * variable so that we can set the clock snapshot's clock + * class member to NULL before recycling it. We CANNOT do + * this after we put the clock class reference because this + * bt_object_put_ref() could destroy the clock class, also + * destroying its clock snapshot pool, thus also destroying + * our clock snapshot object (this would result in an invalid + * write access). + * + * 3. Recycle the clock snapshot object. + * + * 4. Put our clock class reference. + */ + bt_clock_snapshot_reset(clock_snapshot); + clock_class = clock_snapshot->clock_class; + BT_ASSERT(clock_class); + clock_snapshot->clock_class = NULL; + bt_object_pool_recycle_object(&clock_class->cs_pool, clock_snapshot); + bt_object_put_ref(clock_class); +} + +uint64_t bt_clock_snapshot_get_value(const struct bt_clock_snapshot *clock_snapshot) +{ + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); + BT_ASSERT_PRE(clock_snapshot->is_set, + "Clock snapshot is not set: %!+k", clock_snapshot); + return clock_snapshot->value_cycles; +} + +int bt_clock_snapshot_get_ns_from_origin(const struct bt_clock_snapshot *clock_snapshot, + int64_t *ret_value_ns) +{ + int ret = 0; + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); + BT_ASSERT_PRE_NON_NULL(ret_value_ns, "Value (ns) (output)"); + BT_ASSERT_PRE(clock_snapshot->is_set, + "Clock snapshot is not set: %!+k", clock_snapshot); + + if (clock_snapshot->ns_from_origin_overflows) { + BT_LIB_LOGD("Clock snapshot, once converted to nanoseconds from origin, " + "overflows the signed 64-bit integer range: " + "%![cs-]+k", clock_snapshot); + ret = -1; + goto end; + } + + *ret_value_ns = clock_snapshot->ns_from_origin; + +end: + return ret; +} + +const struct bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( + const struct bt_clock_snapshot *clock_snapshot) +{ + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); + return clock_snapshot->clock_class; +} diff --git a/lib/trace-ir/clock-value.c b/lib/trace-ir/clock-value.c deleted file mode 100644 index 8bd2b1cb..00000000 --- a/lib/trace-ir/clock-value.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "CLOCK-VALUE" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BT_HIDDEN -void bt_clock_value_destroy(struct bt_clock_value *clock_value) -{ - BT_LIB_LOGD("Destroying clock value: %!+k", clock_value); - BT_OBJECT_PUT_REF_AND_RESET(clock_value->clock_class); - g_free(clock_value); -} - -BT_HIDDEN -struct bt_clock_value *bt_clock_value_new(struct bt_clock_class *clock_class) -{ - struct bt_clock_value *ret = NULL; - - BT_ASSERT(clock_class); - BT_LIB_LOGD("Creating clock value object: %![cc-]+K=", - clock_class); - ret = g_new0(struct bt_clock_value, 1); - if (!ret) { - BT_LOGE_STR("Failed to allocate one clock value."); - goto end; - } - - bt_object_init_unique(&ret->base); - ret->clock_class = clock_class; - bt_object_get_no_null_check(clock_class); - bt_clock_class_freeze(clock_class); - BT_LIB_LOGD("Created clock value object: %!+k", ret); - -end: - return ret; -} - -BT_HIDDEN -struct bt_clock_value *bt_clock_value_create(struct bt_clock_class *clock_class) -{ - struct bt_clock_value *clock_value = NULL; - - BT_ASSERT(clock_class); - clock_value = bt_object_pool_create_object(&clock_class->cv_pool); - if (!clock_value) { - BT_LIB_LOGE("Cannot allocate one clock value from clock class's clock value pool: " - "%![cc-]+K", clock_class); - goto error; - } - - if (likely(!clock_value->clock_class)) { - clock_value->clock_class = clock_class; - bt_object_get_no_null_check(clock_class); - } - - goto end; - -error: - if (clock_value) { - bt_clock_value_recycle(clock_value); - clock_value = NULL; - } - -end: - return clock_value; -} - -BT_HIDDEN -void bt_clock_value_recycle(struct bt_clock_value *clock_value) -{ - struct bt_clock_class *clock_class; - - BT_ASSERT(clock_value); - BT_LIB_LOGD("Recycling clock value: %!+k", clock_value); - - /* - * Those are the important ordered steps: - * - * 1. Reset the clock value object, but do NOT put its clock - * class's reference. This clock class contains the pool to - * which we're about to recycle this clock value object, so - * we must guarantee its existence thanks to this existing - * reference. - * - * 2. Move the clock class reference to our `clock_class` - * variable so that we can set the clock value's clock class - * member to NULL before recycling it. We CANNOT do this - * after we put the clock class reference because this - * bt_object_put_ref() could destroy the clock class, also destroying - * its clock value pool, thus also destroying our clock value - * object (this would result in an invalid write access). - * - * 3. Recycle the clock value object. - * - * 4. Put our clock class reference. - */ - bt_clock_value_reset(clock_value); - clock_class = clock_value->clock_class; - BT_ASSERT(clock_class); - clock_value->clock_class = NULL; - bt_object_pool_recycle_object(&clock_class->cv_pool, clock_value); - bt_object_put_ref(clock_class); -} - -uint64_t bt_clock_value_get_value(const struct bt_clock_value *clock_value) -{ - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value"); - BT_ASSERT_PRE(clock_value->is_set, - "Clock value is not set: %!+k", clock_value); - return clock_value->value_cycles; -} - -int bt_clock_value_get_ns_from_origin(const struct bt_clock_value *clock_value, - int64_t *ret_value_ns) -{ - int ret = 0; - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value"); - BT_ASSERT_PRE_NON_NULL(ret_value_ns, "Value (ns) (output)"); - BT_ASSERT_PRE(clock_value->is_set, - "Clock value is not set: %!+k", clock_value); - - if (clock_value->ns_from_origin_overflows) { - BT_LIB_LOGD("Clock value, once converted to nanoseconds from origin, " - "overflows the signed 64-bit integer range: " - "%![cv-]+k", clock_value); - ret = -1; - goto end; - } - - *ret_value_ns = clock_value->ns_from_origin; - -end: - return ret; -} - -const struct bt_clock_class *bt_clock_value_borrow_clock_class_const( - const struct bt_clock_value *clock_value) -{ - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value"); - return clock_value->clock_class; -} diff --git a/lib/trace-ir/event-class.c b/lib/trace-ir/event-class.c index 0c8b9f6c..7c09f78b 100644 --- a/lib/trace-ir/event-class.c +++ b/lib/trace-ir/event-class.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/trace-ir/event.c b/lib/trace-ir/event.c index d65d7637..1b3a085f 100644 --- a/lib/trace-ir/event.c +++ b/lib/trace-ir/event.c @@ -28,8 +28,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -177,10 +177,10 @@ struct bt_event *bt_event_new(struct bt_event_class *event_class) } if (stream_class->default_clock_class) { - event->default_cv = bt_clock_value_create( + event->default_cs = bt_clock_snapshot_create( stream_class->default_clock_class); - if (!event->default_cv) { - /* bt_clock_value_create() logs errors */ + if (!event->default_cs) { + /* bt_clock_snapshot_create() logs errors */ goto error; } } @@ -321,9 +321,9 @@ void bt_event_destroy(struct bt_event *event) BT_LOGD_STR("Putting event's class."); bt_object_put_ref(event->class); - if (event->default_cv) { - bt_clock_value_recycle(event->default_cv); - event->default_cv = NULL; + if (event->default_cs) { + bt_clock_snapshot_recycle(event->default_cs); + event->default_cs = NULL; } BT_LOGD_STR("Putting event's packet."); @@ -331,7 +331,7 @@ void bt_event_destroy(struct bt_event *event) g_free(event); } -void bt_event_set_default_clock_value(struct bt_event *event, +void bt_event_set_default_clock_snapshot(struct bt_event *event, uint64_t value_cycles) { struct bt_stream_class *sc; @@ -343,20 +343,20 @@ void bt_event_set_default_clock_value(struct bt_event *event, BT_ASSERT_PRE(sc->default_clock_class, "Event's stream class has no default clock class: " "%![ev-]+e, %![sc-]+S", event, sc); - BT_ASSERT(event->default_cv); - bt_clock_value_set_value_inline(event->default_cv, value_cycles); - BT_LIB_LOGV("Set event's default clock value: %![event-]+e, " + BT_ASSERT(event->default_cs); + bt_clock_snapshot_set_value_inline(event->default_cs, value_cycles); + BT_LIB_LOGV("Set event's default clock snapshot: %![event-]+e, " "value=%" PRIu64, event, value_cycles); } -enum bt_clock_value_status bt_event_borrow_default_clock_value_const( +enum bt_clock_snapshot_status bt_event_borrow_default_clock_snapshot_const( const struct bt_event *event, - const struct bt_clock_value **clock_value) + const struct bt_clock_snapshot **clock_snapshot) { BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value (output)"); - *clock_value = event->default_cv; - return BT_CLOCK_VALUE_STATUS_KNOWN; + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)"); + *clock_snapshot = event->default_cs; + return BT_CLOCK_SNAPSHOT_STATUS_KNOWN; } struct bt_packet *bt_event_borrow_packet(struct bt_event *event) diff --git a/lib/trace-ir/packet.c b/lib/trace-ir/packet.c index cf320389..41bd4119 100644 --- a/lib/trace-ir/packet.c +++ b/lib/trace-ir/packet.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -130,12 +130,12 @@ void reset_packet(struct bt_packet *packet) bt_field_reset(packet->context_field->field); } - if (packet->default_beginning_cv) { - bt_clock_value_reset(packet->default_beginning_cv); + if (packet->default_beginning_cs) { + bt_clock_snapshot_reset(packet->default_beginning_cs); } - if (packet->default_end_cv) { - bt_clock_value_reset(packet->default_end_cv); + if (packet->default_end_cs) { + bt_clock_snapshot_reset(packet->default_end_cs); } reset_counter_snapshots(packet); @@ -233,16 +233,16 @@ void bt_packet_destroy(struct bt_packet *packet) packet->context_field = NULL; } - if (packet->default_beginning_cv) { - BT_LOGD_STR("Recycling beginning clock value."); - bt_clock_value_recycle(packet->default_beginning_cv); - packet->default_beginning_cv = NULL; + if (packet->default_beginning_cs) { + BT_LOGD_STR("Recycling beginning clock snapshot."); + bt_clock_snapshot_recycle(packet->default_beginning_cs); + packet->default_beginning_cs = NULL; } - if (packet->default_end_cv) { - BT_LOGD_STR("Recycling end clock value."); - bt_clock_value_recycle(packet->default_end_cv); - packet->default_end_cv = NULL; + if (packet->default_end_cs) { + BT_LOGD_STR("Recycling end clock snapshot."); + bt_clock_snapshot_recycle(packet->default_end_cs); + packet->default_end_cs = NULL; } BT_LOGD_STR("Putting packet's stream."); @@ -294,20 +294,20 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream) } if (stream->class->default_clock_class) { - if (stream->class->packets_have_default_beginning_cv) { - packet->default_beginning_cv = bt_clock_value_create( + if (stream->class->packets_have_default_beginning_cs) { + packet->default_beginning_cs = bt_clock_snapshot_create( stream->class->default_clock_class); - if (!packet->default_beginning_cv) { - /* bt_clock_value_create() logs errors */ + if (!packet->default_beginning_cs) { + /* bt_clock_snapshot_create() logs errors */ goto error; } } - if (stream->class->packets_have_default_end_cv) { - packet->default_end_cv = bt_clock_value_create( + if (stream->class->packets_have_default_end_cs) { + packet->default_end_cs = bt_clock_snapshot_create( stream->class->default_clock_class); - if (!packet->default_end_cv) { - /* bt_clock_value_create() logs errors */ + if (!packet->default_end_cs) { + /* bt_clock_snapshot_create() logs errors */ goto error; } } @@ -401,7 +401,7 @@ int bt_packet_move_context_field(struct bt_packet *packet, return 0; } -void bt_packet_set_default_beginning_clock_value(struct bt_packet *packet, +void bt_packet_set_default_beginning_clock_snapshot(struct bt_packet *packet, uint64_t value_cycles) { struct bt_stream_class *sc; @@ -413,28 +413,28 @@ void bt_packet_set_default_beginning_clock_value(struct bt_packet *packet, BT_ASSERT_PRE(sc->default_clock_class, "Packet's stream class has no default clock class: " "%![packet-]+a, %![sc-]+S", packet, sc); - BT_ASSERT_PRE(sc->packets_have_default_beginning_cv, + BT_ASSERT_PRE(sc->packets_have_default_beginning_cs, "Packet's stream class indicates that its packets have " - "no default beginning clock value: %![packet-]+a, %![sc-]+S", + "no default beginning clock snapshot: %![packet-]+a, %![sc-]+S", packet, sc); - BT_ASSERT(packet->default_beginning_cv); - bt_clock_value_set_value_inline(packet->default_beginning_cv, + BT_ASSERT(packet->default_beginning_cs); + bt_clock_snapshot_set_value_inline(packet->default_beginning_cs, value_cycles); - BT_LIB_LOGV("Set packet's default beginning clock value: " + BT_LIB_LOGV("Set packet's default beginning clock snapshot: " "%![packet-]+a, value=%" PRIu64, packet, value_cycles); } -enum bt_clock_value_status bt_packet_borrow_default_beginning_clock_value( +enum bt_clock_snapshot_status bt_packet_borrow_default_beginning_clock_snapshot( const struct bt_packet *packet, - const struct bt_clock_value **clock_value) + const struct bt_clock_snapshot **clock_snapshot) { BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value (output)"); - *clock_value = packet->default_beginning_cv; - return BT_CLOCK_VALUE_STATUS_KNOWN; + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)"); + *clock_snapshot = packet->default_beginning_cs; + return BT_CLOCK_SNAPSHOT_STATUS_KNOWN; } -void bt_packet_set_default_end_clock_value(struct bt_packet *packet, +void bt_packet_set_default_end_clock_snapshot(struct bt_packet *packet, uint64_t value_cycles) { struct bt_stream_class *sc; @@ -446,24 +446,24 @@ void bt_packet_set_default_end_clock_value(struct bt_packet *packet, BT_ASSERT_PRE(sc->default_clock_class, "Packet's stream class has no default clock class: " "%![packet-]+a, %![sc-]+S", packet, sc); - BT_ASSERT_PRE(sc->packets_have_default_end_cv, + BT_ASSERT_PRE(sc->packets_have_default_end_cs, "Packet's stream class indicates that its packets have " - "no default end clock value: %![packet-]+a, %![sc-]+S", + "no default end clock snapshot: %![packet-]+a, %![sc-]+S", packet, sc); - BT_ASSERT(packet->default_end_cv); - bt_clock_value_set_value_inline(packet->default_end_cv, value_cycles); - BT_LIB_LOGV("Set packet's default end clock value: " + BT_ASSERT(packet->default_end_cs); + bt_clock_snapshot_set_value_inline(packet->default_end_cs, value_cycles); + BT_LIB_LOGV("Set packet's default end clock snapshot: " "%![packet-]+a, value=%" PRIu64, packet, value_cycles); } -enum bt_clock_value_status bt_packet_borrow_default_end_clock_value( +enum bt_clock_snapshot_status bt_packet_borrow_default_end_clock_snapshot( const struct bt_packet *packet, - const struct bt_clock_value **clock_value) + const struct bt_clock_snapshot **clock_snapshot) { BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value (output)"); - *clock_value = packet->default_end_cv; - return BT_CLOCK_VALUE_STATUS_KNOWN; + BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)"); + *clock_snapshot = packet->default_end_cs; + return BT_CLOCK_SNAPSHOT_STATUS_KNOWN; } enum bt_property_availability bt_packet_get_discarded_event_counter_snapshot( diff --git a/lib/trace-ir/stream-class.c b/lib/trace-ir/stream-class.c index b032b8ee..9b3dd621 100644 --- a/lib/trace-ir/stream-class.c +++ b/lib/trace-ir/stream-class.c @@ -550,14 +550,14 @@ void bt_stream_class_set_packets_have_packet_counter_snapshot( "%!+S", stream_class); } -bt_bool bt_stream_class_packets_have_default_beginning_clock_value( +bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot( const struct bt_stream_class *stream_class) { BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - return (bt_bool) stream_class->packets_have_default_beginning_cv; + return (bt_bool) stream_class->packets_have_default_beginning_cs; } -void bt_stream_class_set_packets_have_default_beginning_clock_value( +void bt_stream_class_set_packets_have_default_beginning_clock_snapshot( struct bt_stream_class *stream_class, bt_bool value) { @@ -566,20 +566,20 @@ void bt_stream_class_set_packets_have_default_beginning_clock_value( BT_ASSERT_PRE(!value || stream_class->default_clock_class, "Stream class does not have a default clock class: %!+S", stream_class); - stream_class->packets_have_default_beginning_cv = (bool) value; + stream_class->packets_have_default_beginning_cs = (bool) value; BT_LIB_LOGV("Set stream class's " - "\"packets have default beginning clock value\" property: " + "\"packets have default beginning clock snapshot\" property: " "%!+S", stream_class); } -bt_bool bt_stream_class_packets_have_default_end_clock_value( +bt_bool bt_stream_class_packets_have_default_end_clock_snapshot( const struct bt_stream_class *stream_class) { BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - return (bt_bool) stream_class->packets_have_default_end_cv; + return (bt_bool) stream_class->packets_have_default_end_cs; } -void bt_stream_class_set_packets_have_default_end_clock_value( +void bt_stream_class_set_packets_have_default_end_clock_snapshot( struct bt_stream_class *stream_class, bt_bool value) { @@ -588,16 +588,16 @@ void bt_stream_class_set_packets_have_default_end_clock_value( BT_ASSERT_PRE(!value || stream_class->default_clock_class, "Stream class does not have a default clock class: %!+S", stream_class); - stream_class->packets_have_default_end_cv = (bool) value; + stream_class->packets_have_default_end_cs = (bool) value; BT_LIB_LOGV("Set stream class's " - "\"packets have default end clock value\" property: " + "\"packets have default end clock snapshot\" property: " "%!+S", stream_class); } bt_bool bt_stream_class_default_clock_is_always_known( const struct bt_stream_class *stream_class) { - /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */ + /* BT_CLOCK_SNAPSHOT_STATUS_UNKNOWN is not supported as of 2.0 */ return BT_TRUE; } diff --git a/plugins/ctf/common/metadata/ctf-meta-translate.c b/plugins/ctf/common/metadata/ctf-meta-translate.c index 54b7d971..516b499f 100644 --- a/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -541,7 +541,7 @@ bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, "timestamp_begin"); if (int_fc) { if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) { - bt_stream_class_set_packets_have_default_beginning_clock_value( + bt_stream_class_set_packets_have_default_beginning_clock_snapshot( ir_sc, BT_TRUE); } } @@ -550,7 +550,7 @@ bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, "timestamp_end"); if (int_fc) { if (int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) { - bt_stream_class_set_packets_have_default_end_clock_value( + bt_stream_class_set_packets_have_default_end_clock_snapshot( ir_sc, BT_TRUE); } } diff --git a/plugins/ctf/common/msg-iter/msg-iter.c b/plugins/ctf/common/msg-iter/msg-iter.c index 4843f275..8bed0378 100644 --- a/plugins/ctf/common/msg-iter/msg-iter.c +++ b/plugins/ctf/common/msg-iter/msg-iter.c @@ -213,7 +213,7 @@ struct bt_msg_iter { off_t cur_packet_offset; /* Default clock's current value */ - uint64_t default_clock_val; + uint64_t default_clock_snapshot; /* End of packet snapshots */ struct { @@ -1731,12 +1731,12 @@ void update_default_clock(struct bt_msg_iter *notit, uint64_t new_val, * current value directly. */ if (new_val_size == 64) { - notit->default_clock_val = new_val; + notit->default_clock_snapshot = new_val; goto end; } new_val_mask = (1ULL << new_val_size) - 1; - cur_value_masked = notit->default_clock_val & new_val_mask; + cur_value_masked = notit->default_clock_snapshot & new_val_mask; if (new_val < cur_value_masked) { /* @@ -1744,18 +1744,18 @@ void update_default_clock(struct bt_msg_iter *notit, uint64_t new_val, * of the requested new value. Assume that the clock * value wrapped only one time. */ - notit->default_clock_val += new_val_mask + 1; + notit->default_clock_snapshot += new_val_mask + 1; } /* Clear the low bits of the current clock value. */ - notit->default_clock_val &= ~new_val_mask; + notit->default_clock_snapshot &= ~new_val_mask; /* Set the low bits of the current clock value. */ - notit->default_clock_val |= new_val; + notit->default_clock_snapshot |= new_val; end: BT_LOGV("Updated default clock's value from integer field's value: " - "value=%" PRIu64, notit->default_clock_val); + "value=%" PRIu64, notit->default_clock_snapshot); } static @@ -2244,7 +2244,7 @@ end: } static -void set_event_default_clock_value(struct bt_msg_iter *notit) +void set_event_default_clock_snapshot(struct bt_msg_iter *notit) { bt_event *event = bt_message_event_borrow_event( @@ -2254,8 +2254,8 @@ void set_event_default_clock_value(struct bt_msg_iter *notit) BT_ASSERT(event); if (bt_stream_class_borrow_default_clock_class(sc)) { - bt_event_set_default_clock_value(event, - notit->default_clock_val); + bt_event_set_default_clock_snapshot(event, + notit->default_clock_snapshot); } } @@ -2341,15 +2341,15 @@ void notify_new_packet(struct bt_msg_iter *notit, notit->packet, notit->snapshots.packets); } - if (bt_stream_class_packets_have_default_beginning_clock_value(sc)) { + if (bt_stream_class_packets_have_default_beginning_clock_snapshot(sc)) { BT_ASSERT(notit->snapshots.beginning_clock != UINT64_C(-1)); - bt_packet_set_default_beginning_clock_value( + bt_packet_set_default_beginning_clock_snapshot( notit->packet, notit->snapshots.beginning_clock); } - if (bt_stream_class_packets_have_default_end_clock_value(sc)) { + if (bt_stream_class_packets_have_default_end_clock_snapshot(sc)) { BT_ASSERT(notit->snapshots.end_clock != UINT64_C(-1)); - bt_packet_set_default_end_clock_value( + bt_packet_set_default_end_clock_snapshot( notit->packet, notit->snapshots.end_clock); } @@ -2419,7 +2419,7 @@ void notify_end_of_packet(struct bt_msg_iter *notit, /* Update default clock from packet's end time */ if (notit->snapshots.end_clock != UINT64_C(-1)) { - notit->default_clock_val = notit->snapshots.end_clock; + notit->default_clock_snapshot = notit->snapshots.end_clock; } BT_ASSERT(notit->msg_iter); @@ -2610,7 +2610,7 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message( goto end; case STATE_EMIT_MSG_EVENT: BT_ASSERT(notit->event_msg); - set_event_default_clock_value(notit); + set_event_default_clock_snapshot(notit); *message = notit->event_msg; notit->event_msg = NULL; goto end; diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index 1bc5dc60..f7036304 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -563,7 +563,7 @@ enum bt_lttng_live_iterator_status emit_inactivity_message( BT_LTTNG_LIVE_ITERATOR_STATUS_OK; struct lttng_live_trace *trace; const bt_clock_class *clock_class = NULL; - bt_clock_value *clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL; const bt_message *msg = NULL; int retval; @@ -575,21 +575,21 @@ enum bt_lttng_live_iterator_status emit_inactivity_message( if (!clock_class) { goto error; } - clock_value = bt_clock_value_create(clock_class, timestamp); - if (!clock_value) { + clock_snapshot = bt_clock_snapshot_create(clock_class, timestamp); + if (!clock_snapshot) { goto error; } msg = bt_message_inactivity_create(trace->cc_prio_map); if (!msg) { goto error; } - retval = bt_message_inactivity_set_clock_value(msg, clock_value); + retval = bt_message_inactivity_set_clock_snapshot(msg, clock_snapshot); if (retval) { goto error; } *message = msg; end: - bt_object_put_ref(clock_value); + bt_object_put_ref(clock_snapshot); bt_clock_class_put_ref(clock_class); return ret; @@ -608,7 +608,7 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent enum bt_lttng_live_iterator_status ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; const bt_clock_class *clock_class = NULL; - bt_clock_value *clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL; if (lttng_live_stream->state != LTTNG_LIVE_STREAM_QUIESCENT) { return BT_LTTNG_LIVE_ITERATOR_STATUS_OK; @@ -627,7 +627,7 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent lttng_live_stream->last_returned_inactivity_timestamp = lttng_live_stream->current_inactivity_timestamp; end: - bt_object_put_ref(clock_value); + bt_object_put_ref(clock_snapshot); bt_clock_class_put_ref(clock_class); return ret; } diff --git a/plugins/libctfcopytrace/clock-fields.c b/plugins/libctfcopytrace/clock-fields.c index ef5368c0..07d129d2 100644 --- a/plugins/libctfcopytrace/clock-fields.c +++ b/plugins/libctfcopytrace/clock-fields.c @@ -763,7 +763,7 @@ int copy_find_clock_int_field(FILE *err, const bt_field *copy_field) { const bt_clock_class *clock_class = NULL, *writer_clock_class = NULL; - bt_clock_value *clock_value = NULL, *writer_clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL, *writer_clock_snapshot = NULL; uint64_t value; int ret; @@ -772,12 +772,12 @@ int copy_find_clock_int_field(FILE *err, return set_int_value(err, field, copy_field, type); } - clock_value = bt_event_get_clock_value(event, clock_class); + clock_snapshot = bt_event_get_clock_snapshot(event, clock_class); BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); - BT_ASSERT(clock_value); + BT_ASSERT(clock_snapshot); - ret = bt_clock_value_get_value(clock_value, &value); - BT_OBJECT_PUT_REF_AND_RESET(clock_value); + ret = bt_clock_snapshot_get_value(clock_snapshot, &value); + BT_OBJECT_PUT_REF_AND_RESET(clock_snapshot); if (ret) { BT_LOGE("Failed to get clock value."); goto error; @@ -792,15 +792,15 @@ int copy_find_clock_int_field(FILE *err, writer_clock_class = event_get_clock_class(err, writer_event); BT_ASSERT(writer_clock_class); - writer_clock_value = bt_clock_value_create(writer_clock_class, value); + writer_clock_snapshot = bt_clock_snapshot_create(writer_clock_class, value); BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class); - if (!writer_clock_value) { + if (!writer_clock_snapshot) { BT_LOGE_STR("Failed to create clock value."); goto error; } - ret = bt_event_set_clock_value(writer_event, writer_clock_value); - BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value); + ret = bt_event_set_clock_snapshot(writer_event, writer_clock_snapshot); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_snapshot); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 140a7ad8..cb1f7aa7 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -655,7 +655,7 @@ int ctf_copy_event_header(FILE *err, const bt_event *event, const bt_field *event_header) { const bt_clock_class *clock_class = NULL, *writer_clock_class = NULL; - bt_clock_value *clock_value = NULL, *writer_clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL, *writer_clock_snapshot = NULL; int ret; const bt_field *writer_event_header = NULL; @@ -667,12 +667,12 @@ int ctf_copy_event_header(FILE *err, const bt_event *event, goto error; } - clock_value = bt_event_get_clock_value(event, clock_class); + clock_snapshot = bt_event_get_clock_snapshot(event, clock_class); BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); - BT_ASSERT(clock_value); + BT_ASSERT(clock_snapshot); - ret = bt_clock_value_get_value(clock_value, &value); - BT_OBJECT_PUT_REF_AND_RESET(clock_value); + ret = bt_clock_snapshot_get_value(clock_snapshot, &value); + BT_OBJECT_PUT_REF_AND_RESET(clock_snapshot); if (ret) { BT_LOGE_STR("Failed to get clock value."); goto error; @@ -684,15 +684,15 @@ int ctf_copy_event_header(FILE *err, const bt_event *event, goto error; } - writer_clock_value = bt_clock_value_create(writer_clock_class, value); + writer_clock_snapshot = bt_clock_snapshot_create(writer_clock_class, value); BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class); - if (!writer_clock_value) { + if (!writer_clock_snapshot) { BT_LOGE_STR("Failed to create clock value."); goto error; } - ret = bt_event_set_clock_value(writer_event, writer_clock_value); - BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value); + ret = bt_event_set_clock_snapshot(writer_event, writer_clock_snapshot); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_snapshot); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 00ec45b7..fa0298b2 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -1721,11 +1721,11 @@ end: } static -int set_event_clock_value(FILE *err, const bt_event *event, +int set_event_clock_snapshot(FILE *err, const bt_event *event, const bt_event *writer_event) { const bt_clock_class *clock_class = NULL; - bt_clock_value *clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL; int ret = 0; clock_class = event_get_clock_class(err, event); @@ -1734,8 +1734,8 @@ int set_event_clock_value(FILE *err, const bt_event *event, goto end; } - clock_value = bt_event_get_clock_value(event, clock_class); - if (!clock_value) { + clock_snapshot = bt_event_get_clock_snapshot(event, clock_class); + if (!clock_snapshot) { ret = 0; goto end; } @@ -1744,7 +1744,7 @@ int set_event_clock_value(FILE *err, const bt_event *event, * We share the same clocks, so we can assign the clock value to the * writer event. */ - ret = bt_event_set_clock_value(writer_event, clock_value); + ret = bt_event_set_clock_snapshot(writer_event, clock_snapshot); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; @@ -1757,7 +1757,7 @@ error: ret = -1; end: bt_clock_class_put_ref(clock_class); - bt_object_put_ref(clock_value); + bt_object_put_ref(clock_snapshot); return ret; } @@ -1777,7 +1777,7 @@ const bt_event *debug_info_copy_event(FILE *err, const bt_event *event, goto error; } - ret = set_event_clock_value(err, event, writer_event); + ret = set_event_clock_snapshot(err, event, writer_event); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index c85eb16a..8a80df3b 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -518,7 +518,7 @@ skip_ts: BT_ASSERT(event); if (dmesg_comp->clock_class) { - bt_event_set_default_clock_value(event, ts); + bt_event_set_default_clock_snapshot(event, ts); } goto end; diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index d0639817..cdbbc1b6 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -46,7 +46,7 @@ struct timestamp { int64_t real_timestamp; /* Relative to UNIX epoch. */ - uint64_t clock_value; /* In cycles. */ + uint64_t clock_snapshot; /* In cycles. */ }; static @@ -80,17 +80,17 @@ static void print_timestamp_cycles(struct pretty_component *pretty, const bt_event *event) { - const bt_clock_value *clock_value; + const bt_clock_snapshot *clock_snapshot; uint64_t cycles; - enum bt_clock_value_status cv_status; + enum bt_clock_snapshot_status cv_status; - cv_status = bt_event_borrow_default_clock_value_const(event, &clock_value); - if (cv_status != BT_CLOCK_VALUE_STATUS_KNOWN || !clock_value) { + cv_status = bt_event_borrow_default_clock_snapshot_const(event, &clock_snapshot); + if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) { g_string_append(pretty->string, "????????????????????"); return; } - cycles = bt_clock_value_get_value(clock_value); + cycles = bt_clock_snapshot_get_value(clock_snapshot); g_string_append_printf(pretty->string, "%020" PRIu64, cycles); if (pretty->last_cycles_timestamp != -1ULL) { @@ -101,7 +101,7 @@ void print_timestamp_cycles(struct pretty_component *pretty, static void print_timestamp_wall(struct pretty_component *pretty, - const bt_clock_value *clock_value) + const bt_clock_snapshot *clock_snapshot) { int ret; int64_t ts_nsec = 0; /* add configurable offset */ @@ -109,12 +109,12 @@ void print_timestamp_wall(struct pretty_component *pretty, uint64_t ts_sec_abs, ts_nsec_abs; bool is_negative; - if (!clock_value) { + if (!clock_snapshot) { g_string_append(pretty->string, "??:??:??.?????????"); return; } - ret = bt_clock_value_get_ns_from_origin(clock_value, &ts_nsec); + ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, &ts_nsec); if (ret) { // TODO: log, this is unexpected g_string_append(pretty->string, "Error"); @@ -222,8 +222,8 @@ int print_event_timestamp(struct pretty_component *pretty, int ret = 0; const bt_stream *stream = NULL; const bt_stream_class *stream_class = NULL; - const bt_clock_value *clock_value = NULL; - enum bt_clock_value_status cv_status; + const bt_clock_snapshot *clock_snapshot = NULL; + enum bt_clock_snapshot_status cv_status; stream = bt_event_borrow_stream_const(event); if (!stream) { @@ -237,9 +237,9 @@ int print_event_timestamp(struct pretty_component *pretty, goto end; } - cv_status = bt_event_borrow_default_clock_value_const(event, - &clock_value); - if (cv_status != BT_CLOCK_VALUE_STATUS_KNOWN || !clock_value) { + cv_status = bt_event_borrow_default_clock_snapshot_const(event, + &clock_snapshot); + if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) { /* No default clock value: skip the timestamp without an error */ goto end; } @@ -255,10 +255,10 @@ int print_event_timestamp(struct pretty_component *pretty, if (pretty->options.print_timestamp_cycles) { print_timestamp_cycles(pretty, event); } else { - clock_value = NULL; - cv_status = bt_event_borrow_default_clock_value_const(event, - &clock_value); - print_timestamp_wall(pretty, clock_value); + clock_snapshot = NULL; + cv_status = bt_event_borrow_default_clock_snapshot_const(event, + &clock_snapshot); + print_timestamp_wall(pretty, clock_snapshot); } if (pretty->use_colors) { g_string_append(pretty->string, COLOR_RST); @@ -1262,8 +1262,8 @@ int print_discarded_elements_msg( const unsigned char *trace_uuid; int64_t stream_class_id; int64_t stream_id; - bt_clock_value *begin_clock_value = NULL; - bt_clock_value *end_clock_value = NULL; + bt_clock_snapshot *begin_clock_snapshot = NULL; + bt_clock_snapshot *end_clock_snapshot = NULL; /* Stream name */ BT_ASSERT(packet); @@ -1291,10 +1291,10 @@ int print_discarded_elements_msg( trace_uuid = bt_trace_get_uuid(trace); /* Beginning and end times */ - (void) bt_packet_borrow_previous_packet_default_end_clock_value_const( - packet, &begin_clock_value); - (void) bt_packet_borrow_default_end_clock_value_const(packet, - &end_clock_value); + (void) bt_packet_borrow_previous_packet_default_end_clock_snapshot_const( + packet, &begin_clock_snapshot); + (void) bt_packet_borrow_default_end_clock_snapshot_const(packet, + &end_clock_snapshot); /* Format message */ g_string_assign(pretty->string, ""); @@ -1306,11 +1306,11 @@ int print_discarded_elements_msg( bt_common_color_fg_yellow(), count, elem_type, count == 1 ? "" : "s"); - if (begin_clock_value && end_clock_value) { + if (begin_clock_snapshot && end_clock_snapshot) { g_string_append(pretty->string, "between ["); - print_timestamp_wall(pretty, begin_clock_value); + print_timestamp_wall(pretty, begin_clock_snapshot); g_string_append(pretty->string, "] and ["); - print_timestamp_wall(pretty, end_clock_value); + print_timestamp_wall(pretty, end_clock_snapshot); g_string_append(pretty->string, "]"); } else { g_string_append(pretty->string, "(unknown time range)"); diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index bb786ed9..077a8f8d 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -603,12 +603,12 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, int64_t *ts_ns) { const bt_clock_class *clock_class = NULL; - const bt_clock_value *clock_value = NULL; + const bt_clock_snapshot *clock_snapshot = NULL; const bt_event *event = NULL; int ret = 0; const unsigned char *cc_uuid; const char *cc_name; - enum bt_clock_value_status cv_status = BT_CLOCK_VALUE_STATUS_KNOWN; + enum bt_clock_snapshot_status cv_status = BT_CLOCK_SNAPSHOT_STATUS_KNOWN; BT_ASSERT(msg); BT_ASSERT(ts_ns); @@ -622,13 +622,13 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, case BT_MESSAGE_TYPE_EVENT: event = bt_message_event_borrow_event_const(msg); BT_ASSERT(event); - cv_status = bt_event_borrow_default_clock_value_const(event, - &clock_value); + cv_status = bt_event_borrow_default_clock_snapshot_const(event, + &clock_snapshot); break; case BT_MESSAGE_TYPE_INACTIVITY: - clock_value = - bt_message_inactivity_borrow_default_clock_value_const( + clock_snapshot = + bt_message_inactivity_borrow_default_clock_snapshot_const( msg); break; default: @@ -638,25 +638,25 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, goto end; } - if (cv_status != BT_CLOCK_VALUE_STATUS_KNOWN) { - BT_LOGE_STR("Unsupported unknown clock value."); + if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN) { + BT_LOGE_STR("Unsupported unknown clock snapshot."); ret = -1; goto end; } /* - * If the clock value is missing, then we consider that this + * If the clock snapshot is missing, then we consider that this * message has no time. In this case it's always the * youngest. */ - if (!clock_value) { - BT_LOGV_STR("Message's default clock value is missing: " + if (!clock_snapshot) { + BT_LOGV_STR("Message's default clock snapshot is missing: " "using the last returned timestamp."); *ts_ns = last_returned_ts_ns; goto end; } - clock_class = bt_clock_value_borrow_clock_class_const(clock_value); + clock_class = bt_clock_snapshot_borrow_clock_class_const(clock_snapshot); BT_ASSERT(clock_class); cc_uuid = bt_clock_class_get_uuid(clock_class); cc_name = bt_clock_class_get_name(clock_class); @@ -809,10 +809,10 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, } } - ret = bt_clock_value_get_ns_from_origin(clock_value, ts_ns); + ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, ts_ns); if (ret) { - BT_LOGE("Cannot get nanoseconds from Epoch of clock value: " - "clock-value-addr=%p", clock_value); + BT_LOGE("Cannot get nanoseconds from Epoch of clock snapshot: " + "clock-snapshot-addr=%p", clock_snapshot); goto error; } diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 0e015119..82f3410e 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -188,7 +188,7 @@ const bt_message *evaluate_event_message( const bt_trace *trace = NULL; const bt_stream *stream = NULL; const bt_stream_class *stream_class = NULL; - bt_clock_value *clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL; bool lazy_update = false; const bt_message *new_message = NULL; bt_clock_class_priority_map *cc_prio_map; @@ -219,14 +219,14 @@ const bt_message *evaluate_event_message( goto end; } - clock_value = bt_event_get_clock_value(event, clock_class); - if (!clock_value) { + clock_snapshot = bt_event_get_clock_snapshot(event, clock_class); + if (!clock_snapshot) { BT_LOGE_STR("Failed to retrieve clock value."); goto error; } - clock_ret = bt_clock_value_get_value_ns_from_epoch( - clock_value, &ts); + clock_ret = bt_clock_snapshot_get_value_ns_from_epoch( + clock_snapshot, &ts); if (clock_ret) { BT_LOGE_STR("Failed to retrieve clock value timestamp."); goto error; @@ -262,7 +262,7 @@ end: bt_trace_put_ref(trace); bt_stream_put_ref(stream); bt_stream_class_put_ref(stream_class); - bt_object_put_ref(clock_value); + bt_object_put_ref(clock_snapshot); *_event_in_range = in_range; return new_message; } @@ -272,10 +272,10 @@ int ns_from_integer_field(const bt_field *integer, int64_t *ns) { int ret = 0; int is_signed; - uint64_t raw_clock_value; + uint64_t raw_clock_snapshot; const bt_field_class *integer_class = NULL; const bt_clock_class *clock_class = NULL; - bt_clock_value *clock_value = NULL; + bt_clock_snapshot *clock_snapshot = NULL; integer_class = bt_field_get_class(integer); BT_ASSERT(integer_class); @@ -289,7 +289,7 @@ int ns_from_integer_field(const bt_field *integer, int64_t *ns) is_signed = bt_field_class_integer_is_signed(integer_class); if (!is_signed) { ret = bt_field_unsigned_integer_get_value(integer, - &raw_clock_value); + &raw_clock_snapshot); if (ret) { goto end; } @@ -299,16 +299,16 @@ int ns_from_integer_field(const bt_field *integer, int64_t *ns) goto end; } - clock_value = bt_clock_value_create(clock_class, raw_clock_value); - if (!clock_value) { + clock_snapshot = bt_clock_snapshot_create(clock_class, raw_clock_snapshot); + if (!clock_snapshot) { goto end; } - ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns); + ret = bt_clock_snapshot_get_value_ns_from_epoch(clock_snapshot, ns); end: bt_field_class_put_ref(integer_class); bt_clock_class_put_ref(clock_class); - bt_object_put_ref(clock_value); + bt_object_put_ref(clock_snapshot); return ret; } -- 2.34.1