clines.append(_CLine(line))
clines.append(_CLine(''))
+ # reset bit position to write the packet context (after packet header)
+ spc_offset = self._get_stream_packet_context_offset(stream)
+ fmt = '{} = {};'
+ line = fmt.format(self._CTX_AT, spc_offset)
+ clines.append(_CLine(line))
+
+ # bit position at beginning of event (to reset in case we run
+ # out of space)
+ line = 'uint32_t ctx_at_begin = {};'.format(self._CTX_AT)
+ clines.append(_CLine(line))
+
# packet context fields
fcline_groups = []
scope_name = 'stream.packet.context'
line = 'uint32_t ctx_at_bkup;'
clines.append(_CLine(line))
+ # bit position at beginning of event (to reset in case we run
+ # out of space)
+ line = 'uint32_t ctx_at_begin = {};'.format(self._CTX_AT)
+ clines.append(_CLine(line))
+
# set context parameters
clines.append(_CLine(''))
clines.append(_CLine("/* barectf context parameters */"))
def _stream_has_timestamp_begin_end(self, stream):
return self._has_timestamp_begin_end[stream.id]
+ # Returns the packet context offset (from the beginning of the
+ # packet) of a given TSDL stream
+ #
+ # stream: TSDL stream
+ def _get_stream_packet_context_offset(self, stream):
+ return self._packet_context_offsets[stream.id]
+
# Generates the C lines to write a barectf context field, saving
# and restoring the current bit position accordingly.
#
line = 'uint32_t ctx_at_bkup;'
clines.append(_CLine(line))
+ # bit position at beginning of event (to reset in case we run
+ # out of space)
+ line = 'uint32_t ctx_at_begin = {};'.format(self._CTX_AT)
+ clines.append(_CLine(line))
+
# update timestamp end if present
if self._stream_has_timestamp_begin_end(stream):
clines.append(_CLine(''))
def _gen_barectf_func_trace_event_body(self, stream, event):
clines = []
- clines.append(_CLine('uint32_t ctx_at_bkup;'))
-
# get clock value ASAP
clk_type = self._get_clock_ctype(stream)
clk = self._gen_get_clock_value()
clines.append(_CLine(line))
clines.append(_CLine(''))
+ # bit position backup (could be used)
+ clines.append(_CLine('uint32_t ctx_at_bkup;'))
+
+ # bit position at beginning of event (to reset in case we run
+ # out of space)
+ line = 'uint32_t ctx_at_begin = {};'.format(self._CTX_AT)
+ clines.append(_CLine(line))
+
# event header
fcline_groups = []
scope_name = 'event.header'
has = 'timestamp_begin' in stream.packet_context.fields
self._has_timestamp_begin_end[stream.id] = has
+ # packet header size with alignment
+ self._packet_context_offsets = {}
+
+ tph_size = self._get_struct_size(self._doc.trace.packet_header)
+
+ for stream in self._doc.streams.values():
+ spc_alignment = self._get_obj_alignment(stream.packet_context)
+ spc_offset = self._get_alignment(tph_size, spc_alignment)
+ self._packet_context_offsets[stream.id] = spc_offset
+
# Generates barectf C files.
#
# metadata: metadata path