`ctf` plugin: add `ctf::src::MsgIter` class
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 22 May 2024 16:00:59 +0000 (12:00 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
commitaf6b76faf16e949af1fd9639eb1303c58980e2a6
treea0ee1cb6737bc61655f6a80a1d0eba52cea55d7e
parentfb9a08c30c8bc0073dfe91be775aceee0951ac18
`ctf` plugin: add `ctf::src::MsgIter` class

Original patch by Simon.

Philippe's changes over original patch (no functional change intended):

• Conform to the Babeltrace 2 coding style for new C++11 code and to
  some naming conventions of the common part of the `ctf` plugin.

• Add many public and internal comments.

• Rename `Quirks` class to `MsgIterQuirks`.

  Also, rename the quirks to the generic `pktEndDefClkValZero`,
  `eventRecordDefClkValGtNextPktBeginDefClkVal`, and
  `eventRecordDefClkValLtPktBeginDefClkVal` names to decouple this API
  from specific tracers.

• Remove `MsgIterItemVisitor`.

  Instead, MsgIter::_handleItem() dispatches the item to a specific
  handling method based on its numeric type.

  Move the relevant members of `MsgIterItemVisitor` into
  `MsgIter` itself.

• In `_StackFrame`, rename everything named "field" to "sub-field" so as
  to remove some ambiguity.

• Add MsgIter::_stackTop*() helper methods which defer to the
  corresponding method on the top stack frame.

• Add MsgIter::_stackPush() and MsgIter::_stackPop() helper methods.

• Add MsgIter::_addMsgToQueue() helper method.

• Only log item details when the `TRACE` level is enabled.

• Handle `PktMagicNumberItem`: validate the magic number value.

• Handle `MetadataStreamUuidItem`: validate the UUID.

  The `MsgIter` constructor now accepts an `expectedMetadataStreamUuid`
  parameter (optional UUID) which is the expected metadata stream UUID
  to compare to.

• Handle variable-length integer field items, adding the
  MsgIter::_handleUIntFieldItem() and MsgIter::_handleSIntFieldItem()
  helper method templates to do so.

• Handle BLOB field items.

  A new data member, `_mCurBlobFieldDataOffset`, tracks the current BLOB
  field data offset to write to when handling the next
  `BlobFieldSectionItem` (we can't append to a BLOB field like when
  handling `StrFieldSubstrItem`).

• Handle optional field items, adding a member
  to `MsgIter::_StackFrame::_Field`.

• In MsgIter::_StackFrame::goToNextSubField(), unconditionally increment
  `_mSubFieldIndex`: curSubField() doesn't care about `_mSubFieldIndex`
  for the variant/option field cases anyway.

  Therefore, make curSubFieldAndGoToNextSubField() reuse curSubField()
  and goToNextSubField() to remove some almost duplicate code.

• Handle UTF-16 and UTF-32 string data.

Change-Id: If2dd82b43f4d19a16ec4420c13c9a3686034766d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8227
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12716
src/Makefile.am
src/cpp-common/bt2c/uuid.hpp
src/plugins/ctf/common/src/msg-iter.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/msg-iter.hpp [new file with mode: 0644]
This page took 0.024872 seconds and 4 git commands to generate.