{
struct {{ ctx_struct_name }} * const ctx = _FROM_VOID_PTR(struct {{ ctx_struct_name }}, vctx);
- /* event _cannot_ fit? */
+ /* Event _cannot_ fit? */
if (ev_size > (ctx->packet_size - ctx->off_content)) {
ctx->events_discarded++;
return 0;
}
- /* packet is full? */
+ /* Packet is full? */
if ({{ prefix }}packet_is_full(ctx)) {
- /* yes: is back-end full? */
+ /* Yes: is the back-end full? */
if (ctx->cbs.is_backend_full(ctx->data)) {
- /* yes: discard event */
+ /* Yes: discard event */
ctx->events_discarded++;
return 0;
}
- /* back-end is not full: open new packet */
+ /* Back-end is _not_ full: open new packet */
ctx->use_cur_last_event_ts = 1;
ctx->cbs.open_packet(ctx->data);
ctx->use_cur_last_event_ts = 0;
}
- /* event fits the current packet? */
+ /* Event fits the current packet? */
if (ev_size > (ctx->packet_size - ctx->at)) {
- /* no: close packet now */
+ /* No: close packet now */
ctx->use_cur_last_event_ts = 1;
ctx->cbs.close_packet(ctx->data);
ctx->use_cur_last_event_ts = 0;
- /* is back-end full? */
+ /* Is the back-end full? */
if (ctx->cbs.is_backend_full(ctx->data)) {
- /* yes: discard event */
+ /* Yes: discard event */
ctx->events_discarded++;
return 0;
}
- /* back-end is not full: open new packet */
+ /* Back-end is _not_ full: open new packet */
ctx->use_cur_last_event_ts = 1;
ctx->cbs.open_packet(ctx->data);
ctx->use_cur_last_event_ts = 0;
{
struct {{ ctx_struct_name }} * const ctx = _FROM_VOID_PTR(struct {{ ctx_struct_name }}, vctx);
- /* is packet full? */
+ /* Is the packet full? */
if ({{ prefix }}packet_is_full(ctx)) {
- /* yes: close it now */
+ /* Yes: close it now */
ctx->cbs.close_packet(ctx->data);
}
}
return;
}
- /* we can alter the packet */
+ /* We can alter the packet */
ctx->in_tracing_section = 1;
- /* do not open a packet that is already open */
+ /* Do not open a packet that is already open */
if (ctx->packet_is_open) {
ctx->in_tracing_section = saved_in_tracing_section;
return;
{% set pkt_header_ops = this_stream_ops.pkt_header_ops %}
{% if pkt_header_ops %}
- /* serialize packet header */
+ /* Serialize packet header */
{
{% for op in pkt_header_ops %}
{{ op.serialize_str(stream_type=stream_type) | indent_tab(2) }}
}
{% endif %}
- /* serialize packet context */
+ /* Serialize packet context */
{
{% for op in this_stream_ops.pkt_ctx_ops %}
{{ op.serialize_str(stream_type=stream_type) | indent_tab(2) }}
{% endfor %}
}
- /* save content beginning's offset */
+ /* Save content beginning's offset */
ctx->off_content = ctx->at;
- /* mark current packet as open */
+ /* Mark current packet as open */
ctx->packet_is_open = 1;
- /* not tracing anymore */
+ /* Not tracing anymore */
ctx->in_tracing_section = saved_in_tracing_section;
}
return;
}
- /* we can alter the packet */
+ /* We can alter the packet */
ctx->in_tracing_section = 1;
- /* do not close a packet that is not open */
+ /* Do not close a packet that is not open */
if (!ctx->packet_is_open) {
ctx->in_tracing_section = saved_in_tracing_section;
return;
}
- /* save content size */
+ /* Save content size */
ctx->content_size = ctx->at;
{% set name = 'timestamp_end' %}
{% if name in stream_type._pkt_ctx_ft.members %}
{% set op = stream_op_pkt_ctx_op(stream_type, name) %}
- /* go back to `timestamp_end` field offset */
+ /* Go back to `timestamp_end` field offset */
ctx->at = sctx->off_{{ c_common.op_src(op) }};
{% set src = 'ts' %}
{% if name in stream_type._pkt_ctx_ft.members %}
{% set op = stream_op_pkt_ctx_op(stream_type, name) %}
- /* go back to `content_size` field offset */
+ /* Go back to `content_size` field offset */
ctx->at = sctx->off_{{ c_common.op_src(op) }};
{% set src %}ctx->{{ name }}{% endset %}
{% if name in stream_type._pkt_ctx_ft.members %}
{% set op = stream_op_pkt_ctx_op(stream_type, name) %}
- /* go back to `events_discarded` field offset */
+ /* Go back to `events_discarded` field offset */
ctx->at = sctx->off_{{ c_common.op_src(op) }};
{% set src %}ctx->{{ name }}{% endset %}
{% endfilter %}
{% endif %}
- /* go back to end of packet */
+ /* Go back to end of packet */
ctx->at = ctx->packet_size;
- /* mark packet as closed */
+ /* Mark packet as closed */
ctx->packet_is_open = 0;
- /* not tracing anymore */
+ /* Not tracing anymore */
ctx->in_tracing_section = saved_in_tracing_section;
}
{% if stream_type._ev_header_ft %}
const {{ cg_opts.clock_type_c_types[def_clk_type] }} ts = sctx->cur_last_event_ts;
{% endif %}
- /* serialize event header */
+ /* Serialize event header */
{
{% for op in this_stream_ops.ev_header_ops %}
{{ op.serialize_str(stream_type=stream_type) | indent_tab(2) }}
{
struct {{ ctx_struct_name }} * const ctx = _FROM_VOID_PTR(struct {{ ctx_struct_name }}, vctx);
- /* serialize event common context */
+ /* Serialize event common context */
{
{% for op in this_stream_ops.ev_common_ctx_ops %}
{{ op.serialize_str(stream_type=stream_type) | indent_tab(2) }}
struct {{ ctx_struct_name }} * const ctx = _FROM_VOID_PTR(struct {{ ctx_struct_name }}, vctx);
{% if stream_type._ev_header_ft %}
- /* serialize header */
+ /* Serialize header */
_serialize_ev_header_{{ stream_type.name }}(ctx, {{ ev_type.id }});
{% endif %}
{% if stream_type.event_common_context_field_type %}
- /* serialize common context */
+ /* Serialize common context */
{% set params = macros.ft_call_params(root_ft_prefixes.ECC, stream_type.event_common_context_field_type) %}
_serialize_ev_common_ctx_{{ stream_type.name }}(ctx{{ params }});
{% endif %}
{% set this_ev_ops = this_stream_ops.ev_ops[ev_type] %}
{% if this_ev_ops.spec_ctx_ops %}
- /* serialize specific context */
+ /* Serialize specific context */
{
{% for op in this_ev_ops.spec_ctx_ops %}
{{ op.serialize_str(stream_type=stream_type, ev_type=ev_type) | indent_tab(2) }}
{% endif %}
{% if this_ev_ops.payload_ops %}
- /* serialize payload */
+ /* Serialize payload */
{
{% for op in this_ev_ops.payload_ops %}
{{ op.serialize_str(stream_type=stream_type, ev_type=ev_type) | indent_tab(2) }}
uint32_t at = ctx->at;
{% if this_stream_ops.ev_header_ops %}
- /* add header size */
+ /* Add header size */
{
{% for op in this_stream_ops.ev_header_ops %}
{{ op.size_str(stream_type=stream_type) | indent_tab(2) }}
{% endif %}
{% if this_stream_ops.ev_common_ctx_ops %}
- /* add common context size */
+ /* Add common context size */
{
{% for op in this_stream_ops.ev_common_ctx_ops %}
{{ op.size_str(stream_type=stream_type) | indent_tab(2) }}
{% endif %}
{% if this_ev_ops.spec_ctx_ops %}
- /* add specific context size */
+ /* Add specific context size */
{
{% for op in this_ev_ops.spec_ctx_ops %}
{{ op.size_str(stream_type=stream_type, ev_type=ev_type) | indent_tab(2) }}
{% endif %}
{% if this_ev_ops.payload_ops %}
- /* add payload size */
+ /* Add payload size */
{
{% for op in this_ev_ops.payload_ops %}
{{ op.size_str(stream_type=stream_type, ev_type=ev_type) | indent_tab(2) }}
uint32_t ev_size;
{% if def_clk_type %}
- /* save time */
+ /* Save time */
sctx->cur_last_event_ts = ctx->cbs.{{ def_clk_type.name }}_clock_get_value(ctx->data);
{% endif %}
return;
}
- /* we can alter the packet */
+ /* We can alter the packet */
ctx->in_tracing_section = 1;
- /* compute event size */
+ /* Compute event size */
{% set ev_common_ctx_params = macros.ft_call_params(root_ft_prefixes.ECC, stream_type.event_common_context_field_type) %}
{% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.SC, ev_type.specific_context_field_type) %}
{% set payload_params = macros.ft_call_params(root_ft_prefixes.P, ev_type.payload_field_type) %}
{% set params %}{{ ev_common_ctx_params }}{{ spec_ctx_params }}{{ payload_params }}{% endset %}
ev_size = _ev_size_{{ stream_type.name }}_{{ ev_type.name }}(_TO_VOID_PTR(ctx){{ params }});
- /* do we have enough space to serialize? */
+ /* Is there enough space to serialize? */
if (!_reserve_ev_space(_TO_VOID_PTR(ctx), ev_size)) {
/* no: forget this */
ctx->in_tracing_section = 0;
return;
}
- /* serialize event */
+ /* Serialize event */
_serialize_ev_{{ stream_type.name }}_{{ ev_type.name }}(_TO_VOID_PTR(ctx){{ params }});
- /* commit event */
+ /* Commit event */
_commit_ev(_TO_VOID_PTR(ctx));
- /* not tracing anymore */
+ /* Not tracing anymore */
ctx->in_tracing_section = 0;
}
{% endfor %}
struct {{ prefix }}platform_callbacks {
{% set clk_types = trace_type.clock_types %}
{% if clk_types %}
- /* clock callbacks */
+ /* Clock callbacks */
{% for clk_type in clk_types | sort %}
{{ cg_opts.clock_type_c_types[clk_type] }} (*{{ clk_type.name }}_clock_get_value)(void *);
{% endfor %}
{% endif %}
- /* is back-end full? */
+ /* Is the back-end full? */
int (*is_backend_full)(void *);
- /* open packet */
+ /* Open packet */
void (*open_packet)(void *);
- /* close packet */
+ /* Close packet */
void (*close_packet)(void *);
};
-/* common barectf context */
+/* Common barectf context */
struct {{ prefix }}ctx {
- /* platform callbacks */
+ /* Platform callbacks */
struct {{ prefix }}platform_callbacks cbs;
- /* platform data (passed to callbacks) */
+ /* Platform data (passed to callbacks) */
void *data;
- /* output buffer (will contain a CTF binary packet) */
+ /* Output buffer (will contain a CTF binary packet) */
uint8_t *buf;
- /* packet's total size (bits) */
+ /* Packet's total size (bits) */
uint32_t packet_size;
- /* packet's content size (bits) */
+ /* Packet's content size (bits) */
uint32_t content_size;
- /* current position from beginning of packet (bits) */
+ /* Current position from beginning of packet (bits) */
uint32_t at;
- /* size of packet header + context fields (content offset) */
+ /* Size of packet header + context fields (content offset) */
uint32_t off_content;
- /* discarded event counter */
+ /* Discarded event counter */
uint32_t events_discarded;
- /* current packet is open? */
+ /* Current packet is open? */
int packet_is_open;
- /* in tracing code? */
+ /* In tracing code? */
volatile int in_tracing_section;
- /* tracing is enabled? */
+ /* Tracing is enabled? */
volatile int is_tracing_enabled;
- /* use current/last event time when opening/closing packets */
+ /* Use current/last event time when opening/closing packets */
int use_cur_last_event_ts;
};
{% for stream_type in trace_type.stream_types | sort %}
-/* context for stream type `{{ stream_type.name }}` */
+/* Context for stream type `{{ stream_type.name }}` */
struct {{ prefix }}{{ stream_type.name }}_ctx {
- /* parent */
+ /* Parent */
struct {{ prefix }}ctx parent;
- /* config-specific members follow */
+ /* Config-specific members follow */
{% if trace_type._pkt_header_ft %}
{% for member_name in trace_type._pkt_header_ft.members %}
uint32_t off_ph_{{ member_name }};